private double GetAxis(IChartItem item, bool x, double axisSize) { if (this._axisData == null) { return(double.NaN); } object obj = ChartHelper.GetChartItemAxisValue(item, x); if (item == null) { return(double.NaN); } DateTime?value = ChartHelper.ConvertToDateTime(obj); if (value == null) { return(double.NaN); } //计算AxisOrientation.LeftToRight或TopToBottom double result = axisSize * (value.Value - this._axisData.MinValue).TotalMilliseconds / this._axisData.Area.TotalMilliseconds; if (base.Orientation == AxisLabelOrientation.RightToLeft || base.Orientation == AxisLabelOrientation.BottomToTop) { result = axisSize - result; } return(result); }
private DateTimeMinAndMaxValue GetMinAndMaxValue(ChartCollection <ISeries> seriesCollection) { if (seriesCollection == null || seriesCollection.Count == 0) { return(new DateTimeMinAndMaxValue(null, null)); } DateTime? min = null, max = null; IChartAxisValue chartAxisValue; object obj; DateTime? time; foreach (var series in seriesCollection) { if (series.AxisX != this && series.AxisY != this || series.Values == null || series.Values.Count == 0) { continue; } foreach (var value in series.Values) { chartAxisValue = value as IChartAxisValue; if (chartAxisValue == null) { continue; } switch (this.AxisType) { case AxisType.X: obj = chartAxisValue.GetXValue(); break; case AxisType.Y: obj = chartAxisValue.GetYValue(); break; default: throw new NotImplementedException(this.AxisType.ToString()); } time = ChartHelper.ConvertToDateTime(obj); if (time == null) { continue; } if (min == null || time.Value < min.Value) { min = time.Value; } if (max == null || time.Value > max.Value) { max = time.Value; } } } return(new DateTimeMinAndMaxValue(min, max)); }