Ejemplo n.º 1
0
        private List <double> DrawX(Canvas axisCanvas)
        {
            if (this._axisData == null)
            {
                return(null);
            }

            List <double> xList;

            switch (base.Orientation)
            {
            case AxisLabelOrientation.LeftToRight:
                xList = this.DrawXAxisLeftToRight(axisCanvas, this._axisData);
                break;

            case AxisLabelOrientation.RightToLeft:
                xList = this.DrawXAxisRightToLeft(axisCanvas, this._axisData);
                break;

            default:
                throw new ArgumentException($"未知的{base.Orientation.ToString()}");
            }
            ChartHelper.DrawXAxisLabelLine(this, axisCanvas, xList);
            return(xList);
        }
Ejemplo n.º 2
0
        private List <double> DrawX(Canvas axisCanvas)
        {
            if (this._axisData == null)
            {
                return(null);
            }

            List <double> xList;
            double        labelStepMilliseconds = this.CalculateXLabelStep(this._axisData);
            double        labelStepSize         = ChartHelper.CalculateLabelStepSize(this._axisData.Area.TotalMilliseconds, axisCanvas.Width, labelStepMilliseconds);

            switch (base.Orientation)
            {
            case AxisLabelOrientation.LeftToRight:
                xList = this.DrawXAxisLeftToRight(axisCanvas, this._axisData, labelStepMilliseconds, labelStepSize);
                break;

            case AxisLabelOrientation.RightToLeft:
                xList = this.DrawXAxisRightToLeft(axisCanvas, this._axisData, labelStepMilliseconds, labelStepSize);
                break;

            default:
                throw new ArgumentException($"未知的{base.Orientation.ToString()}");
            }
            ChartHelper.DrawXAxisLabelLine(this, axisCanvas, xList);
            return(xList);
        }
Ejemplo n.º 3
0
        private List <double> DrawX(Canvas axisCanvas)
        {
            double            labelStepSize      = this.CalculateLabelStepSize(this._axisData.Count, axisCanvas.Width);
            double            columnSeriesOffset = this.CalculateSeriesSize(this._seriesSizeDic, labelStepSize);
            TextBlock         label;
            var               angleQuadrantInfo = new AngleQuadrantInfo(this._angle, base._PRE);
            Size              labelTextSize;
            double            left = 0d, labelTextOffset;
            AxisLabelLocation labelLocation = AxisLabelLocation.First;
            object            labelObj;
            LabelSeriesItem   labelItem;
            List <double>     xList             = new List <double>();
            double            labelStepSizeHalf = labelStepSize / 2;
            double            x;

            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.Width) / 2;
                Canvas.SetLeft(label, left + labelTextOffset);
                if (this.IsAxisXBottom())
                {
                    Canvas.SetTop(label, ChartConstant.LABEL_TEXT_INTERVAL);
                    this.RotateLabelBottom(label, angleQuadrantInfo, labelTextSize);
                }
                else
                {
                    Canvas.SetBottom(label, ChartConstant.LABEL_TEXT_INTERVAL);
                    this.RotateLabelTop(label, angleQuadrantInfo, labelTextSize);
                }

                switch (labelLocation)
                {
                case AxisLabelLocation.First:
                    x             = columnSeriesOffset;
                    labelLocation = AxisLabelLocation.Middle;
                    break;

                case AxisLabelLocation.Middle:
                case AxisLabelLocation.Last:
                    x = left + columnSeriesOffset;
                    break;

                default:
                    throw new NotImplementedException(labelLocation.ToString());
                }

                foreach (var key in labelItem.Keys.ToArray())
                {
                    labelItem[key] = x;
                    x += labelItem.Series.Size;
                }

                xList.Add(left + labelStepSizeHalf);
                left += labelStepSize;
            }

            ChartHelper.DrawXAxisLabelLine(this, axisCanvas, ChartConstant.ZERO_D, axisCanvas.Height);
            return(xList);
        }