Ejemplo n.º 1
0
        private void UpdateAxisMinMaxValue(AngleAxis axis, bool updateChart = true)
        {
            if (axis.IsCategory() || !axis.show)
            {
                return;
            }
            double tempMinValue = 0;
            double tempMaxValue = 0;

            SeriesHelper.GetYMinMaxValue(chart.series, null, axis.polarIndex, true, axis.inverse, out tempMinValue,
                                         out tempMaxValue, true);
            AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
            if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
            {
                axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
                axis.context.offset           = 0;
                axis.context.lastCheckInverse = axis.inverse;
                UpdateAxisTickValueList(axis);

                if (updateChart)
                {
                    UpdateAxisLabelText(axis);
                    chart.RefreshChart();
                }
            }
        }
Ejemplo n.º 2
0
 public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
 {
     if (IsAllAxisValue())
     {
         if (axis is XAxis)
         {
             SeriesHelper.GetXMinMaxValue(m_Series, null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
         }
         else
         {
             SeriesHelper.GetYMinMaxValue(m_Series, null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
         }
     }
     else
     {
         SeriesHelper.GetYMinMaxValue(m_Series, null, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
     }
     AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
 }
Ejemplo n.º 3
0
        private void DrawVerticalDataZoomSlider(VertexHelper vh, DataZoom dataZoom)
        {
            if (!dataZoom.enable || !dataZoom.supportSlider)
            {
                return;
            }

            var p1              = new Vector3(dataZoom.context.x, dataZoom.context.y);
            var p2              = new Vector3(dataZoom.context.x, dataZoom.context.y + dataZoom.context.height);
            var p3              = new Vector3(dataZoom.context.x + dataZoom.context.width, dataZoom.context.y + dataZoom.context.height);
            var p4              = new Vector3(dataZoom.context.x + dataZoom.context.width, dataZoom.context.y);
            var lineColor       = dataZoom.lineStyle.GetColor(chart.theme.dataZoom.dataLineColor);
            var lineWidth       = dataZoom.lineStyle.GetWidth(chart.theme.dataZoom.dataLineWidth);
            var borderWidth     = dataZoom.borderWidth == 0 ? chart.theme.dataZoom.borderWidth : dataZoom.borderWidth;
            var borderColor     = dataZoom.GetBorderColor(chart.theme.dataZoom.borderColor);
            var backgroundColor = dataZoom.GetBackgroundColor(chart.theme.dataZoom.backgroundColor);
            var areaColor       = dataZoom.areaStyle.GetColor(chart.theme.dataZoom.dataAreaColor);

            UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
            var centerPos = new Vector3(dataZoom.context.x + dataZoom.context.width / 2,
                                        dataZoom.context.y + dataZoom.context.height / 2);

            UGL.DrawBorder(vh, centerPos, dataZoom.context.width, dataZoom.context.height, borderWidth, borderColor);

            if (dataZoom.showDataShadow && chart.series.Count > 0)
            {
                Serie   serie    = chart.series[0];
                Axis    axis     = chart.GetChartComponent <YAxis>(0);
                var     showData = serie.GetDataList(null);
                float   scaleWid = dataZoom.context.height / (showData.Count - 1);
                Vector3 lp       = Vector3.zero;
                Vector3 np       = Vector3.zero;
                double  minValue = 0;
                double  maxValue = 0;
                SeriesHelper.GetYMinMaxValue(chart.series, null, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue);
                AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);

                int rate       = 1;
                var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
                var maxCount   = showData.Count;
                if (sampleDist > 0)
                {
                    rate = (int)((maxCount - serie.minShow) / (dataZoom.context.height / sampleDist));
                }
                if (rate < 1)
                {
                    rate = 1;
                }

                var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
                                   DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
                var dataChanging = false;

                for (int i = 0; i < maxCount; i += rate)
                {
                    double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
                                                          serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
                    float pY      = dataZoom.context.y + i * scaleWid;
                    float dataHig = (maxValue - minValue) == 0 ? 0 :
                                    (float)((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
                    np = new Vector3(chart.chartX + chart.chartWidth - dataZoom.right - dataHig, pY);
                    if (i > 0)
                    {
                        UGL.DrawLine(vh, lp, np, lineWidth, lineColor);
                        Vector3 alp = new Vector3(lp.x, lp.y - lineWidth);
                        Vector3 anp = new Vector3(np.x, np.y - lineWidth);

                        Vector3 tnp = new Vector3(np.x, chart.chartY + dataZoom.bottom + lineWidth);
                        Vector3 tlp = new Vector3(lp.x, chart.chartY + dataZoom.bottom + lineWidth);
                        UGL.DrawQuadrilateral(vh, alp, anp, tnp, tlp, areaColor);
                    }
                    lp = np;
                }
                if (dataChanging)
                {
                    chart.RefreshTopPainter();
                }
            }
            switch (dataZoom.rangeMode)
            {
            case DataZoom.RangeMode.Percent:
                var start       = dataZoom.context.y + dataZoom.context.height * dataZoom.start / 100;
                var end         = dataZoom.context.y + dataZoom.context.height * dataZoom.end / 100;
                var fillerColor = dataZoom.GetFillerColor(chart.theme.dataZoom.fillerColor);

                p1 = new Vector2(dataZoom.context.x, start);
                p2 = new Vector2(dataZoom.context.x + dataZoom.context.width, start);
                p3 = new Vector2(dataZoom.context.x + dataZoom.context.width, end);
                p4 = new Vector2(dataZoom.context.x, end);
                UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, fillerColor);
                UGL.DrawLine(vh, p1, p2, lineWidth, fillerColor);
                UGL.DrawLine(vh, p3, p4, lineWidth, fillerColor);
                break;
            }
        }
        private void UpdateParallelAxisMinMaxValue()
        {
            var list = chart.GetChartComponents <ParallelAxis>();

            if (list.Count != component.context.parallelAxes.Count)
            {
                component.context.parallelAxes.Clear();
                foreach (var com in chart.GetChartComponents <ParallelAxis>())
                {
                    var axis = com as ParallelAxis;
                    if (axis.parallelIndex == component.index)
                    {
                        component.context.parallelAxes.Add(axis);
                    }
                }
            }
            m_SerieDimMin.Clear();
            m_SerieDimMax.Clear();
            foreach (var serie in chart.series)
            {
                if ((serie is Parallel) && serie.parallelIndex == component.index)
                {
                    foreach (var serieData in serie.data)
                    {
                        for (int i = 0; i < serieData.data.Count; i++)
                        {
                            var value = serieData.data[i];
                            if (!m_SerieDimMin.ContainsKey(i))
                            {
                                m_SerieDimMin[i] = value;
                            }
                            else if (m_SerieDimMin[i] > value)
                            {
                                m_SerieDimMin[i] = value;
                            }

                            if (!m_SerieDimMax.ContainsKey(i))
                            {
                                m_SerieDimMax[i] = value;
                            }
                            else if (m_SerieDimMax[i] < value)
                            {
                                m_SerieDimMax[i] = value;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < component.context.parallelAxes.Count; i++)
            {
                var axis = component.context.parallelAxes[i];
                if (axis.IsCategory())
                {
                    m_SerieDimMax[i] = axis.data.Count > 0 ? axis.data.Count - 1 : 0;
                    m_SerieDimMin[i] = 0;
                }
                else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
                {
                    m_SerieDimMin[i] = axis.min;
                    m_SerieDimMax[i] = axis.max;
                }
                else if (m_SerieDimMax.ContainsKey(i))
                {
                    var tempMinValue = m_SerieDimMin[i];
                    var tempMaxValue = m_SerieDimMax[i];
                    AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
                    m_SerieDimMin[i] = tempMinValue;
                    m_SerieDimMax[i] = tempMaxValue;
                }
            }
            for (int i = 0; i < component.context.parallelAxes.Count; i++)
            {
                if (m_SerieDimMax.ContainsKey(i))
                {
                    var axis         = component.context.parallelAxes[i];
                    var tempMinValue = m_SerieDimMin[i];
                    var tempMaxValue = m_SerieDimMax[i];

                    if (tempMinValue != axis.context.minValue ||
                        tempMaxValue != axis.context.maxValue ||
                        m_LastInterval != axis.interval ||
                        m_LastSplitNumber != axis.splitNumber)
                    {
                        m_LastSplitNumber = axis.splitNumber;
                        m_LastInterval    = axis.interval;

                        axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
                        axis.context.offset           = 0;
                        axis.context.lastCheckInverse = axis.inverse;

                        (axis.handler as ParallelAxisHander).UpdateAxisTickValueList(axis);
                        (axis.handler as ParallelAxisHander).UpdateAxisLabelText(axis);
                        chart.RefreshChart();
                    }
                }
            }
        }