示例#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;
        }
示例#2
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);
            }
        }