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(); } } }
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); }
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; } }