public static Color32 GetLineGradientColor(VisualMap visualMap, Vector3 pos, CoordinateChart chart, Axis axis,
                                                   Color32 defaultColor)
        {
            float value = 0;
            var   min   = 0f;
            var   max   = 0f;

            if (visualMap.dimension == 0)
            {
                min = axis.runtimeMinValue;
                max = axis.runtimeMaxValue;
                var grid = chart.GetAxisGridOrDefault(axis);
                if (axis.IsCategory() && axis.boundaryGap)
                {
                    float startX = grid.runtimeX + axis.runtimeScaleWidth / 2;
                    value = (int)(min + (pos.x - startX) / (grid.runtimeWidth - axis.runtimeScaleWidth) * (max - min));
                }
                else
                {
                    value = min + (pos.x - grid.runtimeX) / grid.runtimeWidth * (max - min);
                }
            }
            else
            {
                Axis yAxis;
                if (axis is YAxis)
                {
                    yAxis = chart.xAxes[axis.index];
                    min   = yAxis.runtimeMinValue;
                    max   = yAxis.runtimeMaxValue;
                }
                else
                {
                    yAxis = chart.yAxes[axis.index];
                    min   = yAxis.runtimeMinValue;
                    max   = yAxis.runtimeMaxValue;
                }
                var grid = chart.GetAxisGridOrDefault(axis);
                if (yAxis.IsCategory() && yAxis.boundaryGap)
                {
                    float startY = grid.runtimeY + yAxis.runtimeScaleWidth / 2;
                    value = (int)(min + (pos.y - startY) / (grid.runtimeHeight - yAxis.runtimeScaleWidth) * (max - min));
                }
                else
                {
                    value = min + (pos.y - grid.runtimeY) / grid.runtimeHeight * (max - min);
                }
            }
            var color = visualMap.GetColor(value);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
Example #2
0
 void Awake()
 {
     chart   = gameObject.GetComponentInChildren <CoordinateChart>();
     timeNow = System.DateTime.Now;
     chart.ClearAxisData();
     chart.series.ClearData();
     chart.SetMaxCache(maxCacheDataNumber);
     chart.title.text = maxCacheDataNumber + "数据";
 }
Example #3
0
        private static void ExportCoordinateChart(StringBuilder sb, CoordinateChart chart)
        {
            var instanceId = chart.GetInstanceID();

            if (chart.visualMap.show)
            {
                AppendColor(sb, instanceId, "visualMap", chart.visualMap.inRange);
            }
            if (chart.xAxis0.show)
            {
                if (chart.xAxis0.splitArea.show)
                {
                    AppendColor(sb, instanceId, "xAxis0_splitArea", chart.xAxis0.splitArea.color);
                }
                if (chart.xAxis0.splitLine.show)
                {
                    AppendColor(sb, instanceId, "xAxis0_splitLine", chart.xAxis0.splitLine.lineStyle.color);
                }
            }
            if (chart.xAxis1.show)
            {
                if (chart.xAxis1.splitArea.show)
                {
                    AppendColor(sb, instanceId, "xAxis1_splitArea", chart.xAxis1.splitArea.color);
                }
                if (chart.xAxis1.splitLine.show)
                {
                    AppendColor(sb, instanceId, "xAxis1_splitLine", chart.xAxis1.splitLine.lineStyle.color);
                }
            }
            if (chart.yAxis0.show)
            {
                if (chart.yAxis0.splitArea.show)
                {
                    AppendColor(sb, instanceId, "yAxis0_splitArea", chart.yAxis0.splitArea.color);
                }
                if (chart.yAxis0.splitLine.show)
                {
                    AppendColor(sb, instanceId, "yAxis0_splitLine", chart.yAxis0.splitLine.lineStyle.color);
                }
            }
            if (chart.yAxis1.show)
            {
                if (chart.yAxis1.splitArea.show)
                {
                    AppendColor(sb, instanceId, "yAxis1_splitArea", chart.yAxis1.splitArea.color);
                }
                if (chart.yAxis1.splitLine.show)
                {
                    AppendColor(sb, instanceId, "yAxis1_splitLine", chart.yAxis1.splitLine.lineStyle.color);
                }
            }
            ExportSeries(sb, chart);
        }
Example #4
0
        void Awake()
        {
            chart = gameObject.GetComponentInChildren <CoordinateChart>();
            chart.RemoveData();
            var serie = chart.AddSerie(SerieType.Line);

            serie.symbol.type         = SerieSymbolType.None;
            serie.maxCache            = maxCacheDataNumber;
            chart.xAxises[0].maxCache = maxCacheDataNumber;
            timeNow = DateTime.Now;
            timeNow = timeNow.AddSeconds(-maxCacheDataNumber);
        }
Example #5
0
        public static void UpdateDataZoomRuntimeStartEndValue(CoordinateChart chart, SerieType serieType)
        {
            foreach (var dataZoom in chart.dataZooms)
            {
                if (!dataZoom.enable)
                {
                    continue;
                }
                double min = double.MaxValue;
                double max = double.MinValue;
                foreach (var serie in chart.series.list)
                {
                    if (!serie.show || serie.type != serieType)
                    {
                        continue;
                    }
                    if (!dataZoom.IsContainsXAxis(serie.xAxisIndex))
                    {
                        continue;
                    }
                    var axis = chart.GetXAxis(serie.xAxisIndex);

                    if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
                    {
                        if (axis.min < min)
                        {
                            min = axis.min;
                        }
                        if (axis.max > max)
                        {
                            max = axis.max;
                        }
                    }
                    else
                    {
                        double serieMinValue = 0;
                        double serieMaxValue = 0;
                        SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, null, 2);
                        if (serieMinValue < min)
                        {
                            min = serieMinValue;
                        }
                        if (serieMaxValue > max)
                        {
                            max = serieMaxValue;
                        }
                    }
                }
                dataZoom.runtimeStartValue = min + (max - min) * dataZoom.start / 100;
                dataZoom.runtimeEndValue   = min + (max - min) * dataZoom.end / 100;
            }
        }
        public static Color32 GetLineGradientColor(VisualMap visualMap, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor)
        {
            float value = 0;

            switch (visualMap.direction)
            {
            case VisualMap.Direction.Default:
            case VisualMap.Direction.X:
                var min  = axis.runtimeMinValue;
                var max  = axis.runtimeMaxValue;
                var grid = chart.GetAxisGridOrDefault(axis);
                value = min + (pos.x - grid.runtimeX) / grid.runtimeWidth * (max - min);
                break;

            case VisualMap.Direction.Y:
                if (axis is YAxis)
                {
                    var yAxis = chart.xAxes[axis.index];
                    min = yAxis.runtimeMinValue;
                    max = yAxis.runtimeMaxValue;
                }
                else
                {
                    var yAxis = chart.yAxes[axis.index];
                    min = yAxis.runtimeMinValue;
                    max = yAxis.runtimeMaxValue;
                }
                grid  = chart.GetAxisGridOrDefault(axis);
                value = min + (pos.y - grid.runtimeY) / grid.runtimeHeight * (max - min);
                break;
            }
            var color = visualMap.GetColor(value);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
Example #7
0
        internal static Color32 GetLineStyleGradientColor(LineStyle lineStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor)
        {
            var min   = axis.runtimeMinValue;
            var max   = axis.runtimeMaxValue;
            var value = min + (pos.x - chart.coordinateX) / chart.coordinateWidth * (max - min);
            var rate  = (value - min) / (max - min);
            var color = lineStyle.GetGradientColor(rate, defaultColor);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
        internal static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor)
        {
            var min   = axis.runtimeMinValue;
            var max   = axis.runtimeMaxValue;
            var grid  = chart.GetAxisGridOrDefault(axis);
            var value = min + (pos.x - grid.runtimeX) / grid.runtimeWidth * (max - min);
            var rate  = (value - min) / (max - min);
            var color = itemStyle.GetGradientColor(rate, defaultColor);

            if (ChartHelper.IsClearColor(color))
            {
                return(defaultColor);
            }
            else
            {
                return(color);
            }
        }
Example #9
0
 public MarkLineHandler(CoordinateChart chart)
 {
     this.chart = chart;
 }
Example #10
0
 public DataZoomHandler(BaseChart chart)
 {
     this.chart = chart as CoordinateChart;
 }