Example #1
0
 public override void ApplyOption()
 {
     for (int i = 0; i < labels.Length; i += 3)
     {
         GUIChartEditor.PushValueLabel(labels[i], labels[i + 1], labels[i + 2], format);
     }
 }
Example #2
0
        public override void ApplyOption()
        {
            ChartInstance chart = GUIChartEditor.CurrentChart;

            // Draws vertical lines.
            float x = chart.minX + (Mathf.Abs(chart.minX) % hSize);

            while (x < chart.maxX)
            {
                GUIChartEditor.PushLineChart(new Vector2[]
                {
                    new Vector2(x, chart.minY),
                    new Vector2(x, chart.maxY)
                }, gridColor);

                if (addLabels && x != 0 && x > chart.minX)
                {
                    float minHeight = Mathf.Ceil(GUIChartEditor.sprites.Digits["0"].height / 2 + 2);
                    float vOffset   = minHeight * GUIChartEditor.CurrentChart.userDefinedRect.height
                                      / GUIChartEditor.CurrentChart.pixelSizeRect.height;
                    GUIChartEditor.PushValueLabel(x, x, -vOffset, "0.0#");
                }

                x += hSize;
            }

            // Draws horizontal lines.
            float y = chart.minY + (Mathf.Abs(chart.minY) % vSize);

            while (y < chart.maxY)
            {
                GUIChartEditor.PushLineChart(new Vector2[]
                {
                    new Vector2(chart.minX, y),
                    new Vector2(chart.maxX, y)
                }, gridColor);

                if (addLabels && y != 0 && y > chart.minY)
                {
                    string label = y.ToString("0.0#").Replace(',', '.');
                    float  hSize = 0f;
                    foreach (char c in label)
                    {
                        hSize += GUIChartEditor.sprites.Digits[c.ToString()].width + 1;
                    }
                    float hOffset = hSize / 2 * GUIChartEditor.CurrentChart.userDefinedRect.width
                                    / GUIChartEditor.CurrentChart.pixelSizeRect.width;
                    GUIChartEditor.PushValueLabel(y, -hOffset, y, "0.0#");
                }

                y += vSize;
            }
        }