示例#1
0
    public void CreateSeriesSet(CSVObject csvObject)
    {
        csvList.Add (csvObject);

        if (csvList.Count == 1) {
            return;
        }

        //csvObject = SubtractCSVs (csvList [0], csvObject);
        Dictionary<string, int> diffList = csvObject.AverageDifferenceCSVs (csvList [0]);

        string label = seriesSets.Count == 0 ? "Initial" : seriesSets.Count.ToString ();
        SeriesSet seriesSet = new SeriesSet (label, new DynamicRect (0, 0, 0, barWidth));
        int seriesScore = 1;

        foreach (KeyValuePair<string, List<string>> entry in csvObject.csvList) {
            string name = entry.Key;
            // Designate color for Series (only used if no convergeManager)
            if (!colorList.ContainsKey (name)) {
                if (convergeManager == null) {
                    colorList [name] = new Color (
                        Random.Range (0.4f, 0.7f),
                        Random.Range (0.4f, 0.7f),
                        Random.Range (0.4f, 0.7f));
                } else {
                    colorList [name] = convergeManager.seriesColors [name];
                }
            }
            // Convert values from String to Float. -1 to represent empty.
            //List<string> strValues = entry.Value;
            //List<float> values = new List<float> ();
            //for (int i = 0; i < strValues.Count; i++) {
            //	float value = (strValues [i] == "" ? -1f : float.Parse (strValues [i]));
            //	values.Add (value);
            //}
            int score = diffList [name];
            seriesScore += score;

            // Create a Series to store series
            BarSeries series = new BarSeries (
                name,
                score, //values,
                new DynamicRect (0, 0, 0, seriesSet.rect.height),
                colorList [name]);
            seriesSet.Add (series);

        }

        //sort seriesList in seriesSet
        seriesSet.Sort (convergeManager.seriesLabels);
        seriesSets.Add (seriesSet);

        // Adjust Max Y-Range
        //UpdateRange ();
        yRange = Mathf.Max (yRange, seriesScore);
        // Adjust init slider val; exclude initial (default) bar
        maxSliderValue = Mathf.Max (0, seriesSets.Count - perPage);
        sliderValue = maxSliderValue;
    }
    public void CreateSeriesSet(CSVObject csvObject)
    {
        csvList.Add(csvObject);

        if (csvList.Count == 1)
        {
            return;
        }

        //csvObject = SubtractCSVs (csvList [0], csvObject);
        Dictionary <string, int> diffList = csvObject.AverageDifferenceCSVs(csvList [0]);

        string    label       = seriesSets.Count == 0 ? "Initial" : seriesSets.Count.ToString();
        SeriesSet seriesSet   = new SeriesSet(label, new DynamicRect(0, 0, 0, barWidth));
        int       seriesScore = 1;

        foreach (KeyValuePair <string, List <string> > entry in csvObject.csvList)
        {
            string name = entry.Key;
            // Designate color for Series (only used if no convergeManager)
            if (!colorList.ContainsKey(name))
            {
                if (convergeManager == null)
                {
                    colorList [name] = new Color(
                        Random.Range(0.4f, 0.7f),
                        Random.Range(0.4f, 0.7f),
                        Random.Range(0.4f, 0.7f));
                }
                else
                {
                    colorList [name] = convergeManager.seriesColors [name];
                }
            }
            // Convert values from String to Float. -1 to represent empty.
            //List<string> strValues = entry.Value;
            //List<float> values = new List<float> ();
            //for (int i = 0; i < strValues.Count; i++) {
            //	float value = (strValues [i] == "" ? -1f : float.Parse (strValues [i]));
            //	values.Add (value);
            //}
            int score = diffList [name];
            seriesScore += score;

            // Create a Series to store series
            BarSeries series = new BarSeries(
                name,
                score,                 //values,
                new DynamicRect(0, 0, 0, seriesSet.rect.height),
                colorList [name]);
            seriesSet.Add(series);
        }

        //sort seriesList in seriesSet
        seriesSet.Sort(convergeManager.seriesLabels);
        seriesSets.Add(seriesSet);

        // Adjust Max Y-Range
        //UpdateRange ();
        yRange = Mathf.Max(yRange, seriesScore);
        // Adjust init slider val; exclude initial (default) bar
        maxSliderValue = Mathf.Max(0, seriesSets.Count - perPage);
        sliderValue    = maxSliderValue;
    }
示例#3
0
    private void DrawSeriesSet(SeriesSet seriesSet, int index = 0)
    {
        float xPos;

        xPos = hStart.x + interBarWidth/2 + (index * (barWidth + interBarWidth));

        seriesSet.rect.x = xPos;
        seriesSet.rect.y = hStart.y - 1;

        GUI.color = (seriesSet.label == selected) ? Color.gray : Color.white;

        // Rotate -90 degrees to allow Rect to expand upwards by adjusting the width
        Matrix4x4 matrix = GUI.matrix;
        Vector2 origin = new Vector2 (seriesSet.rect.x, seriesSet.rect.y);
        GUIUtility.RotateAroundPivot (-90, origin);
        // Draw Series Set
        GUI.BeginGroup (seriesSet.rect.GetRect ());
        float yNext = 0;

        foreach (BarSeries series in seriesSet.seriesList) {
            float barHeight = ((float) series.score / (float) yRange) * yAxisLength;  //prev series.GetSum()
            // Draw horizontally, then rotate vertically
            DynamicRect barRect = series.GetRect ();
            barRect.x = yNext;
            barRect.width = barHeight;
            // Next stacking position
            yNext += barHeight - 1f;

            Functions.DrawBackground (barRect.GetRect (), barTexture, series.color);
        }
        GUI.EndGroup ();
        // Restore Rotation
        GUI.matrix = matrix;
        // Expand "Animation"
        if (Mathf.Abs (seriesSet.rect.width - yAxisLength) > 0.1f) {
            seriesSet.rect.width = Mathf.Lerp (0, yAxisLength, seriesSet.rect.deltaTime += Time.deltaTime * 0.4f);
        } else {
            // Create labels
            GUIStyle style = new GUIStyle (GUI.skin.label);
            style.richText = true;
            style.alignment = TextAnchor.LowerCenter;

            foreach (BarSeries series in seriesSet.seriesList) {
                DynamicRect barRect = series.GetRect ();

                string text = series.score.ToString ();   //GetSum ().ToString ("F2");
        //				GUI.Label(new Rect(seriesSet.rect.x - 65, yAxisLength - barRect.x - barRect.width / 2 - 9, 200, 60), text, style);
            }
        }

        {
            GUIStyle style = new GUIStyle (GUI.skin.label);
            style.richText = true;
            style.alignment = TextAnchor.UpperCenter;

            string xLabel = seriesSet.label;
            GUI.Label (new Rect (seriesSet.rect.x + (seriesSet.rect.height - 200) / 2, seriesSet.rect.y + 10, 200, 60), xLabel, style);
        }
    }
    private void DrawSeriesSet(SeriesSet seriesSet, int index = 0)
    {
        float xPos;

        xPos = hStart.x + interBarWidth / 2 + (index * (barWidth + interBarWidth));

        seriesSet.rect.x = xPos;
        seriesSet.rect.y = hStart.y - 1;

        GUI.color = (seriesSet.label == selected) ? Color.gray : Color.white;

        // Rotate -90 degrees to allow Rect to expand upwards by adjusting the width
        Matrix4x4 matrix = GUI.matrix;
        Vector2   origin = new Vector2(seriesSet.rect.x, seriesSet.rect.y);

        GUIUtility.RotateAroundPivot(-90, origin);
        // Draw Series Set
        GUI.BeginGroup(seriesSet.rect.GetRect());
        float yNext = 0;

        foreach (BarSeries series in seriesSet.seriesList)
        {
            float barHeight = ((float)series.score / (float)yRange) * yAxisLength;                //prev series.GetSum()
            // Draw horizontally, then rotate vertically
            DynamicRect barRect = series.GetRect();
            barRect.x     = yNext;
            barRect.width = barHeight;
            // Next stacking position
            yNext += barHeight - 1f;

            Functions.DrawBackground(barRect.GetRect(), barTexture, series.color);
        }
        GUI.EndGroup();
        // Restore Rotation
        GUI.matrix = matrix;
        // Expand "Animation"
        if (Mathf.Abs(seriesSet.rect.width - yAxisLength) > 0.1f)
        {
            seriesSet.rect.width = Mathf.Lerp(0, yAxisLength, seriesSet.rect.deltaTime += Time.deltaTime * 0.4f);
        }
        else
        {
            // Create labels
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.richText  = true;
            style.alignment = TextAnchor.LowerCenter;

            foreach (BarSeries series in seriesSet.seriesList)
            {
                DynamicRect barRect = series.GetRect();

                string text = series.score.ToString();                    //GetSum ().ToString ("F2");
//				GUI.Label(new Rect(seriesSet.rect.x - 65, yAxisLength - barRect.x - barRect.width / 2 - 9, 200, 60), text, style);
            }
        }

        {
            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.richText  = true;
            style.alignment = TextAnchor.UpperCenter;

            string xLabel = seriesSet.label;
            GUI.Label(new Rect(seriesSet.rect.x + (seriesSet.rect.height - 200) / 2, seriesSet.rect.y + 10, 200, 60), xLabel, style);
        }
    }
    public void SetSeriesSetActive(int index, bool active)
    {
        SeriesSet seriesSet = seriesSets [index];

        seriesSet.SetActive(active);
    }
    private void DrawGrid(Rect rect)
    {
        Color color = Color.white;

        GUI.BeginGroup(rect, GUI.skin.box);
        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.normal.textColor = Color.white;
        style.richText         = true;

        // X-Axis
        Drawing.DrawLine(hStart, hEnd, color, thickness, false);

        // X-Axis Markers
        for (int i = 0; i < xNumMarkers; i++)
        {
            float xPos = hStart.x + xUnitLength * (i + 1), yPos = hStart.y - 5;
            // Unit Line
//				Drawing.DrawLine(new Vector2(xPos, yPos), new Vector2(xPos, yPos + 10), color, thickness, false);
            // Unit Label
            style.alignment = TextAnchor.UpperCenter;

            if (i < xAxisLabels.Count)
            {
//					GUI.Label(new Rect(xPos - 42, yPos + 10, 80, 70), xAxisLabels[xMin + i], style);
            }
        }
        // X-Axis Label
        style.alignment = TextAnchor.UpperCenter;
        GUI.Label(new Rect(hStart.x + (xAxisLength - 80) / 2, hStart.y + 35, 80, 30), "<color=yellow>" + xTitle + "</color>", style);

        // Y-Axis
        Drawing.DrawLine(vStart, vEnd, color, thickness, false);
        // Y-Axis Markers
        for (int i = 0; i <= yNumMarkers; i++)
        {
            float xPos = vStart.x - 5, yPos = vStart.y - yUnitLength * i;
            // Unit Line
            Drawing.DrawLine(new Vector2(xPos, yPos), new Vector2(xPos + 10, yPos), color, thickness, false);
            // Unit Label
            style.alignment = TextAnchor.UpperRight;
            GUI.Label(new Rect(xPos - 85, yPos - 11, 80, 30), (i * yRange / 5).ToString(), style);
        }
        // Y-Axis Label
        style.alignment = TextAnchor.UpperCenter;

        Matrix4x4 matrix = GUI.matrix;

        GUIUtility.RotateAroundPivot(-90, new Vector2(hStart.x - 35, (rect.height) / 2));
        GUI.Label(new Rect(hStart.x - 100, (rect.height - 60) / 2, 200, 30),
                  "<color=orange>" + yTitle + "</color>",
                  style
                  );
        GUI.matrix = matrix;

        // Draw Series Sets
//			for (int i = 0; i < Mathf.Min(seriesSets.Count, 3); i++) {
//				SeriesSet seriesSet = seriesSets[sliderValue + i];
//				DrawSeriesSet(seriesSet, i);
//			}
        if (seriesSets.Count > 0)
        {
            //draw default vs target
            SeriesSet seriesSet = seriesSets [0];
            DrawSeriesSet(seriesSet, 0);
            Vector2 v1 = new Vector2(
                seriesSet.rect.x + barWidth + (interBarWidth / 2),
                seriesSet.rect.y
                );
            Vector2 v2 = new Vector2(
                v1.x,
                seriesSet.rect.y - yAxisLength
                );
            //separate default from player attempts with a line
            Drawing.DrawLine(v1, v2, color, thickness, false);
            //draw attempts vs target
            for (int series = 1; series < Mathf.Min(perPage, seriesSets.Count); series++)
            {
                seriesSet = seriesSets [sliderValue + series];
                DrawSeriesSet(seriesSet, series);
            }
        }
        GUI.EndGroup();
    }
示例#7
0
        private static void CreateSamples(ref AnimlDocument document)
        {
            //// Initialize the SampleSet of the AnimlDocument
            document.SampleSet = new SampleSet();

            //// Create a sample with some dummy data
            Sample sample = new Sample("SampleName", "S-1234")
            {
                Barcode             = "B-1234",
                Comment             = "This is a comment",
                ContainerId         = "C-1234",
                ContainerType       = ContainerType.Simple,
                Derived             = false,
                Id                  = "SampleId",
                LocationInContainer = "A1",
                SourceDataLocation  = @"c:\test\1",
            };

            //// Initialize the TagSet for the Sample and add a Tag to it
            sample.TagSet = new TagSet();
            sample.TagSet.Tags.Add(new Tag("123", "456"));

            //// Create a category and a sub-category
            Category category = new Category("TestCategory")
            {
                Id = "CategoryId",
            };

            Category subCategory = new Category("SubCategory")
            {
                Id = "SubCategoryId",
            };

            //// Create a new Parameter with a double as value and assign it to the sub-categorys
            Parameter parameter = new Parameter("Param X1", 123.05);

            subCategory.Parameters.Add(parameter);

            //// Create a SeriesSet with two IndividualValueSets
            SeriesSet          seriesSet = new SeriesSet("TestSeriesSetInd", 5);
            Series             xData     = new Series("xData", "xS", Dependency.Independent, SeriesType.Int32);
            IndividualValueSet xDataVals = new IndividualValueSet(new List <int>()
            {
                1, 2, 3, 4, 5
            });

            xData.ValueSets.Add(xDataVals);
            Series             yData     = new Series("yData", "yS", Dependency.Dependent, SeriesType.Int32);
            IndividualValueSet yDataVals = new IndividualValueSet(new List <int>()
            {
                2, 8, 9, 2, 0
            });

            yData.ValueSets.Add(yDataVals);
            seriesSet.Series.Add(xData);
            seriesSet.Series.Add(yData);

            //// Create a SeriesSet with two EncodedValueSets
            SeriesSet       encSeriesSet = new SeriesSet("TestSeriesSetEnc", 4);
            Series          xDataEnc     = new Series("xDataEnc", "xSE", Dependency.Independent, SeriesType.Int32);
            EncodedValueSet xDataSetEnc  = new EncodedValueSet(new List <int>()
            {
                0, 1, 2, 3, 4, 5
            });

            xDataEnc.ValueSets.Add(xDataSetEnc);
            Series          yDataEnc    = new Series("yDataEnc", "ySE", Dependency.Dependent, SeriesType.Float32);
            EncodedValueSet yDataSetEnc = new EncodedValueSet(new List <float>()
            {
                0.1f, 0.2f, 0.3f, 3f, 4f, 5f
            });

            yDataEnc.ValueSets.Add(yDataSetEnc);
            encSeriesSet.Series.Add(xDataEnc);
            encSeriesSet.Series.Add(yDataEnc);

            //// Create a SeriesSet with two AutoIncrementedValueSets
            SeriesSet aincSeriesSet = new SeriesSet("TestSeriesSetAInc", 4);
            Series    xDataAInc     = new Series("xDataAInc", "xSAInc", Dependency.Independent, SeriesType.Int32);
            AutoIncrementedValueSet xDataSetAInc = new AutoIncrementedValueSet(0, 1);

            xDataAInc.ValueSets.Add(xDataSetAInc);
            Series yDataAInc = new Series("yDataAInc", "ySAInc", Dependency.Dependent, SeriesType.Float32);
            AutoIncrementedValueSet yDataSetAInc = new AutoIncrementedValueSet(0.0, 0.1);

            yDataAInc.ValueSets.Add(yDataSetAInc);
            aincSeriesSet.Series.Add(xDataAInc);
            aincSeriesSet.Series.Add(yDataAInc);

            //// Add the three ValueSets to the sub-categry
            subCategory.SeriesSets.Add(seriesSet);
            subCategory.SeriesSets.Add(encSeriesSet);
            subCategory.SeriesSets.Add(aincSeriesSet);

            //// Add the sub-categgory to the category
            category.Categories.Add(subCategory);

            /// Add the category to the sample
            sample.Categories.Add(category);

            //// Add the Sample to the SampleSet
            document.SampleSet.Samples.Add(sample);
        }
示例#8
0
 public ResultBuilder WithSeriesSet(SeriesSet seriesSet)
 {
     this.result.SeriesSet = seriesSet;
     return(this);
 }
示例#9
0
 public CategoryBuilder WithSeriesSet(SeriesSet seriesSet)
 {
     this.category.SeriesSets.Add(seriesSet);
     return(this);
 }
示例#10
0
 public SeriesSetBuilder(string name, int length)
 {
     this.seriesSet = new SeriesSet(name, length);
 }