public BarSeries(string label, int score, DynamicRect rect, Color color)    //param 2: List<float> values
        {
            this.label = label;
            //this.values = values;
            this.score = score;
            this.rect  = rect;
            this.color = color;

            this.colorHex = Functions.ColorToHex(color);
        }
        public SeriesSet(string label, DynamicRect rect, bool isActive = true)
        {
            this.label    = label;
            this.rect     = rect;
            this.isActive = isActive;
            this.color    = new Color(Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f));

            this.colorHex = Functions.ColorToHex(color);

            seriesList = new List <BarSeries>();
        }
        public SeriesSet(string label, DynamicRect rect, bool isActive = true)
        {
            this.label = label;
            this.rect = rect;
            this.isActive = isActive;
            this.color = new Color(Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f), Random.Range(0.4f, 0.7f));

            this.colorHex = Functions.ColorToHex(color);

            seriesList = new List<BarSeries>();
        }
        public BarSeries(string label, int score, DynamicRect rect, Color color)
        {
            //param 2: List<float> values
            this.label = label;
            //this.values = values;
            this.score = score;
            this.rect = rect;
            this.color = color;

            this.colorHex = Functions.ColorToHex(color);
        }
Beispiel #5
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);
            }
        }