public StripChartXPlotArea GetHitPlotArea(HitTestResult result) { ChartElementType hitObject = result.ChartElementType; ChartArea hitChartArea = result.ChartArea; if (null == hitChartArea || (hitObject != ChartElementType.PlottingArea && hitObject != ChartElementType.Gridlines && hitObject != ChartElementType.StripLines && hitObject != ChartElementType.DataPoint && hitObject != ChartElementType.Axis)) { return(null); } StripChartXPlotArea hitPlotArea = null; if (ReferenceEquals(MainPlotArea.ChartArea, hitChartArea)) { hitPlotArea = MainPlotArea; } else { int plotAreaIndex = SplitPlotAreas.FindIndexByBaseChartArea(hitChartArea); if (plotAreaIndex >= 0 && plotAreaIndex < SplitPlotAreas.Count) { hitPlotArea = SplitPlotAreas[plotAreaIndex]; } } return(hitPlotArea); }
private double GetMinYInterval(StripChartXPlotArea plotArea) { if (double.IsNaN(plotArea.AxisY.Maximum) || double.IsNaN(plotArea.AxisY.Minimum)) { return(1E-3); } return((plotArea.AxisY.Maximum - plotArea.AxisY.Minimum) / Constants.AutoYIntervalPrecision); }
public void RefreshAxesRange(StripChartXPlotArea plotArea) { if (ReferenceEquals(MainPlotArea, plotArea)) { AdaptMainPlotAreaAxesRange(); } else { int areaIndex = SplitPlotAreas.IndexOf(plotArea); if (areaIndex >= 0) { AdaptSplitPlotAreaAxesRange(areaIndex); } } }
public void GetMaxAndMinYValue(StripChartXPlotArea plotArea, out double maxYValue, out double minYValue, int seriesIndex) { maxYValue = double.NaN; minYValue = double.NaN; double tmpMaxYValue, tmpMinYValue; if (seriesIndex <= -1) { AxisType yAxisType = PlotSeries[0].YAxisType; // 所有的类型都相同则计算全局最大值 if (PlotSeries.All(item => item.YAxisType == yAxisType)) { DataEntity.GetMaxAndMinYValue(out maxYValue, out minYValue); } else { maxYValue = double.MinValue; minYValue = double.MaxValue; for (int index = 0; index < PlotSeries.Count; index++) { if (PlotSeries[index].YAxisType != AxisType.Primary) { continue; } DataEntity.GetMaxAndMinYValue(index, out tmpMaxYValue, out tmpMinYValue); if (tmpMaxYValue > maxYValue) { maxYValue = tmpMaxYValue; } if (tmpMinYValue < minYValue) { minYValue = tmpMinYValue; } } if (Math.Abs(double.MaxValue - maxYValue) < Constants.MinDoubleValue) { maxYValue = double.NaN; minYValue = double.NaN; } } } else { // 无论是副坐标轴还是主坐标轴,都给主坐标轴赋最大值 DataEntity.GetMaxAndMinYValue(seriesIndex, out maxYValue, out minYValue); } }
public PositionAdapter(Chart baseChart, StripChartXPlotArea plotArea) { this._baseChart = baseChart; this._chartArea = plotArea; ChartArea chartArea = plotArea.ChartArea; this._chartSize = new Size(_baseChart.Width, _baseChart.Height); this._areaPosition = new ElementPosition(chartArea.Position.X, chartArea.Position.Y, chartArea.Position.Width, chartArea.Position.Height); this._plotPosition = new ElementPosition(chartArea.InnerPlotPosition.X, chartArea.InnerPlotPosition.Y, chartArea.InnerPlotPosition.Width, chartArea.InnerPlotPosition.Height); this._maxX = chartArea.AxisX.ScaleView.ViewMaximum; this._minX = chartArea.AxisX.ScaleView.ViewMinimum; CalculatePointPosition(); }
public void GetMaxAndMinY2Value(StripChartXPlotArea plotArea, out double maxYValue, out double minYValue, int seriesIndex) { maxYValue = double.NaN; minYValue = double.NaN; // 副坐标轴没有数据则返回 if (!HasSeriesInYAxis(plotArea, StripChartXAxis.PlotAxis.Secondary)) { return; } double tmpMaxYValue, tmpMinYValue; if (seriesIndex <= -1) { maxYValue = double.MinValue; minYValue = double.MaxValue; for (int index = 0; index < PlotSeries.Count; index++) { if (PlotSeries[index].YAxisType != AxisType.Secondary) { continue; } DataEntity.GetMaxAndMinYValue(index, out tmpMaxYValue, out tmpMinYValue); if (tmpMaxYValue > maxYValue) { maxYValue = tmpMaxYValue; } if (tmpMinYValue < minYValue) { minYValue = tmpMinYValue; } } if (Math.Abs(double.MaxValue - maxYValue) < Constants.MinDoubleValue) { maxYValue = double.NaN; minYValue = double.NaN; } } else { DataEntity.GetMaxAndMinYValue(seriesIndex, out maxYValue, out minYValue); } }
public bool HasSeriesInYAxis(StripChartXPlotArea plotArea, StripChartXAxis.PlotAxis plotAxis) { return(PlotSeries.Any(item => item.ChartArea.Equals(plotArea.Name) && item.YAxisType == (AxisType)plotAxis)); }