private List <double> DrawY(Canvas axisCanvas) { if (this._axisData == null) { axisCanvas.Width = ChartConstant.AXIS_DEFAULT_SIZE; return(null); } List <double> yList; switch (base.Orientation) { case AxisLabelOrientation.BottomToTop: yList = this.DrawYAxisBottomToTop(axisCanvas, this._axisData); break; case AxisLabelOrientation.TopToBottom: yList = this.DrawYAxisTopToBottom(axisCanvas, this._axisData); break; default: throw new ArgumentException($"未知的{base.Orientation.ToString()}"); } ChartHelper.DrawYAxisLabelLine(this, axisCanvas, yList); return(yList); }
private List <double> DrawY(Canvas axisCanvas) { if (this._axisData == null) { return(null); } double labelStepMilliseconds = this.CalculateYLabelStep(this._axisData); double labelStepSize = ChartHelper.CalculateLabelStepSize(this._axisData.Area.TotalMilliseconds, axisCanvas.Height, labelStepMilliseconds); List <double> yList; switch (base.Orientation) { case AxisLabelOrientation.BottomToTop: yList = this.DrawYAxisBottomToTop(axisCanvas, this._axisData, labelStepMilliseconds, labelStepSize); break; case AxisLabelOrientation.TopToBottom: yList = this.DrawXAxisTopToBottom(axisCanvas, this._axisData, labelStepMilliseconds, labelStepSize); break; default: throw new ArgumentException($"未知的{base.Orientation.ToString()}"); } ChartHelper.DrawYAxisLabelLine(this, axisCanvas, yList); return(yList); }
private List <double> DrawY(Canvas axisCanvas) { double labelStepSize = this.CalculateLabelStepSize(this._axisData.Count, axisCanvas.Height); double columnSeriesOffset = this.CalculateSeriesSize(this._seriesSizeDic, labelStepSize); TextBlock label; Size labelTextSize; double top = 0d, labelTextOffset; AxisLabelLocation labelLocation = AxisLabelLocation.First; object labelObj; LabelSeriesItem labelItem; double y; List <double> yList = new List <double>(); double labelStepSizeHalf = labelStepSize / 2; for (int i = 0; i < this._axisData.Count; i++) { labelObj = this._axisData.ElementAt(i).Key; labelItem = this._axisData.ElementAt(i).Value; label = ChartHelper.CreateLabelControl(this, this.CreateAxisText(labelObj)); labelTextSize = UITextHelper.MeasureTextSize(label); axisCanvas.Children.Add(label); labelTextOffset = (labelStepSize - labelTextSize.Height) / 2; Canvas.SetTop(label, top + labelTextOffset); if (this.IsAxisYLeft()) { Canvas.SetRight(label, ChartConstant.LABEL_TEXT_INTERVAL); } else { Canvas.SetLeft(label, ChartConstant.LABEL_TEXT_INTERVAL); } switch (labelLocation) { case AxisLabelLocation.First: y = columnSeriesOffset; labelLocation = AxisLabelLocation.Middle; break; case AxisLabelLocation.Middle: case AxisLabelLocation.Last: y = top + columnSeriesOffset; break; default: throw new NotImplementedException(labelLocation.ToString()); } foreach (var key in labelItem.Keys.ToArray()) { labelItem[key] = y; y += labelItem.Series.Size; } yList.Add(top + labelStepSizeHalf); top += labelStepSize; } ChartHelper.DrawYAxisLabelLine(this, axisCanvas, ChartConstant.ZERO_D, axisCanvas.Height); return(yList); }