public EasyChartXPlotArea 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); } EasyChartXPlotArea 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(EasyChartXPlotArea 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 Initialize(Color color, int markerSize, EasyChartXAxis.PlotAxis xAxis, EasyChartXAxis.PlotAxis yAxis, EasyChartXPlotArea plotArea) { this._xAxis = xAxis; this._yAxis = yAxis; this._parentPlotArea = plotArea; this.Color = color; this.MarkerSize = markerSize; InitializeMoveParameter(); InitializePaintComponent(color); }
public PositionAdapter(Chart baseChart, EasyChartXPlotArea 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(EasyChartXPlotArea plotArea, out double maxYValue, out double minYValue, int seriesIndex) { maxYValue = double.NaN; minYValue = double.NaN; // 副坐标轴没有数据则返回 if (!HasSeriesInYAxis(plotArea, EasyChartXAxis.PlotAxis.Secondary)) { return; } double tmpMaxYValue, tmpMinYValue; if (seriesIndex <= -1) { maxYValue = double.MinValue; minYValue = double.MaxValue; int lineIndex; for (int index = 0; index < PlotSeries.Count; index++) { if (PlotSeries[index].YAxisType != AxisType.Secondary) { continue; } DataEntity dataEntity = GetDataEntityBySeriesIndex(index, out lineIndex); dataEntity.GetMaxAndMinYValue(out tmpMaxYValue, out tmpMinYValue, lineIndex); 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 { int lineIndex; DataEntity dataEntity = GetDataEntityBySeriesIndex(seriesIndex, out lineIndex); dataEntity.GetMaxAndMinYValue(out maxYValue, out minYValue, lineIndex); } }
public void RefreshAxesRange(EasyChartXPlotArea plotArea) { double maxXRange = _plotManager.GetMaxXData(); double minXRange = _plotManager.GetMinXData(); if (ReferenceEquals(MainPlotArea, plotArea)) { AdaptMainPlotAreaAxesRange(maxXRange, minXRange); } else { int areaIndex = SplitPlotAreas.IndexOf(plotArea); if (areaIndex >= 0) { AdaptSplitPlotAreaAxesRange(areaIndex, maxXRange, minXRange); } } }
internal DataMarkerManager(EasyChartX parentChart, Chart baseChart, EasyChartXPlotArea parentPlotArea) { this._parentChart = parentChart; this._parentPlotArea = parentPlotArea; this._baseChart = baseChart; this._adapter = new PositionAdapter(baseChart, parentPlotArea); const int defaultMarkerSeries = 4; this._painters = new List <MarkerPainter>(defaultMarkerSeries); this._markerSize = 7; this._shownCount = 0; this._isShown = false; this._enabled = true; RefreshChartPaintEvent(); }
public bool HasSeriesInYAxis(EasyChartXPlotArea plotArea, EasyChartXAxis.PlotAxis plotAxis) { return(PlotSeries.Any(item => item.ChartArea.Equals(plotArea.Name) && item.YAxisType == (AxisType)plotAxis)); }
public void GetMaxAndMinYValue(EasyChartXPlotArea 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)) { PlotDatas[0].GetMaxAndMinYValue(out maxYValue, out minYValue, -1); for (int i = 1; i < PlotDatas.Count; i++) { PlotDatas[i].GetMaxAndMinYValue(out tmpMaxYValue, out tmpMinYValue, -1); if (tmpMaxYValue > maxYValue) { maxYValue = tmpMaxYValue; } if (tmpMinYValue < minYValue) { minYValue = tmpMinYValue; } } } else { maxYValue = double.MinValue; minYValue = double.MaxValue; int lineIndex; for (int index = 0; index < PlotSeries.Count; index++) { if (PlotSeries[index].YAxisType != AxisType.Primary) { continue; } DataEntity dataEntity = GetDataEntityBySeriesIndex(index, out lineIndex); dataEntity.GetMaxAndMinYValue(out tmpMaxYValue, out tmpMinYValue, lineIndex); 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 { // 无论是副坐标轴还是主坐标轴,都给主坐标轴赋最大值 int lineIndex; DataEntity dataEntity = GetDataEntityBySeriesIndex(seriesIndex, out lineIndex); dataEntity?.GetMaxAndMinYValue(out maxYValue, out minYValue, lineIndex); } }