Example #1
0
        private Style GetStyle()
        {
            var style = this.Style;

            if (style == null)
            {
                style = ChartStyleHelper.GetSegmentSeriesDefaultStyle();
            }

            return(style);
        }
Example #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public LineSeriesBase()
            : base()
        {
            var style = base.Style;

            if (style == null)
            {
                style = ChartStyleHelper.GetLineSeriesDefaultStyle();
            }
            this.StyleChanged(style);
            this.EnableTooltipChanged(base.EnableTooltip);
            this.VisibilityChanged(Visibility.Visible, base.Visibility);
        }
Example #3
0
        /// <summary>
        /// 创建坐标轴Label控件
        /// </summary>
        /// <param name="axis">坐标轴</param>
        /// <param name="labelText">标签文本</param>
        /// <returns>Label控件</returns>
        public static TextBlock CreateLabelControl(AxisAbs axis, string labelText)
        {
            var textBlock = new TextBlock();

            textBlock.Text = labelText;
            if (axis.LabelStyle == null)
            {
                textBlock.Style = ChartStyleHelper.GetAxisLabelStyle(axis.DockOrientation);
            }
            else
            {
                textBlock.Style = axis.LabelStyle;
            }

            return(textBlock);
        }
Example #4
0
        private Path CreateBackgroundLabelLine(List <BackgroundLabelLineSegment> labelLineSegments)
        {
            if (!this._enableBackgroundLabelLine ||
                labelLineSegments == null ||
                labelLineSegments.Count == 0)
            {
                return(null);
            }

            var handler = this.CreateBackgroundLabelLineFunc;

            if (handler != null)
            {
                return(handler(labelLineSegments));
            }

            Path backgroundLabelLine = new Path();

            if (this._backgroundLabelLineStyle == null)
            {
                backgroundLabelLine.Style = ChartStyleHelper.GetDefaultBackgroundLabelLineStyle();
            }
            else
            {
                backgroundLabelLine.Style = this._backgroundLabelLineStyle;
            }

            GeometryGroup geometryGroup = new GeometryGroup();

            foreach (var labelLineSegment in labelLineSegments)
            {
                PathFigure segmentFigure = new PathFigure();
                segmentFigure.StartPoint = labelLineSegment.Point1;
                segmentFigure.Segments.Add(new LineSegment(labelLineSegment.Point2, true));
                geometryGroup.Children.Add(new PathGeometry()
                {
                    Figures = new PathFigureCollection(new PathFigure[] { segmentFigure })
                });
            }

            backgroundLabelLine.Data = geometryGroup;
            return(backgroundLabelLine);
        }
Example #5
0
        /// <summary>
        /// 绘制X轴坐标刻度线
        /// </summary>
        /// <param name="axis">X轴坐标</param>
        /// <param name="canvas">画布</param>
        /// <param name="x1">第一个X</param>
        /// <param name="x2">第二个X</param>
        public static void DrawXAxisLabelLine(AxisAbs axis, Canvas canvas, double x1, double x2)
        {
            if (!axis.DrawAxisLine || !DoubleHasValue(x1) || !DoubleHasValue(x2))
            {
                return;
            }

            var labelLinePath = new Path();

            labelLinePath.Style = axis.AxisLineStyle;
            if (labelLinePath.Style == null)
            {
                labelLinePath.Style = ChartStyleHelper.GetDefaultAxisLabelLineStyle();
            }

            Point point1, point2;

            if (axis.IsAxisXBottom())
            {
                point1 = new Point(ChartConstant.ZERO_D, ChartConstant.ZERO_D);
                point2 = new Point(canvas.Width, ChartConstant.ZERO_D);
            }
            else
            {
                point1 = new Point(ChartConstant.ZERO_D, canvas.Height);
                point2 = new Point(canvas.Width, canvas.Height);
            }

            PathFigure labelPathFigure = new PathFigure();

            labelPathFigure.StartPoint = point1;
            labelPathFigure.Segments.Add(new LineSegment(point2, true));
            labelLinePath.Data = new PathGeometry()
            {
                Figures = new PathFigureCollection(new PathFigure[] { labelPathFigure })
            };
            canvas.Children.Add(labelLinePath);
        }
Example #6
0
        private TextBlock GetTitleControl()
        {
            if (string.IsNullOrWhiteSpace(this._title))
            {
                return(null);
            }

            if (this._titleControl == null)
            {
                TextBlock titleControl = new TextBlock();

                titleControl.Style = this._titleStyle;
                if (titleControl.Style == null)
                {
                    titleControl.Style = ChartStyleHelper.CreateAxisTitleStyle(this._dockOrientation);
                }

                titleControl.Text  = this._title;
                this._titleControl = titleControl;
            }

            return(this._titleControl);
        }
Example #7
0
        /// <summary>
        /// 测量标签文本大小
        /// </summary>
        /// <param name="axis">坐标轴</param>
        /// <param name="labelText">标签文本</param>
        /// <returns>标签文本大小</returns>
        public static Size MeasureLabelTextSize(AxisAbs axis, string labelText)
        {
            if (_measureTextLabel == null)
            {
                _measureTextLabel = new TextBlock();
            }

            TextBlock measureTextLabel = _measureTextLabel;

            measureTextLabel.Text = labelText;
            if (axis.LabelStyle == null)
            {
                measureTextLabel.Style = ChartStyleHelper.GetAxisLabelStyle(axis.DockOrientation);
            }
            else
            {
                measureTextLabel.Style = axis.LabelStyle;
            }

            var size = UITextHelper.MeasureTextSize(measureTextLabel);

            measureTextLabel.Style = null;
            return(size);
        }
Example #8
0
        /// <summary>
        /// 绘制Y轴坐标刻度线
        /// </summary>
        /// <param name="axis">Y轴坐标</param>
        /// <param name="canvas">画布</param>
        /// <param name="yList">Y轴刻度集合</param>
        public static void DrawYAxisLabelLine(AxisAbs axis, Canvas canvas, List <double> yList)
        {
            if (!axis.DrawAxisLine || yList == null || yList.Count == 0)
            {
                return;
            }

            var labelLinePath = new Path();

            labelLinePath.Style = axis.AxisLineStyle;
            if (labelLinePath.Style == null)
            {
                labelLinePath.Style = ChartStyleHelper.GetDefaultAxisLabelLineStyle();
            }

            GeometryGroup geometryGroup = new GeometryGroup();
            Point         point1, point2;
            double        y;
            int           lastIndex = yList.Count - 1;

            for (int i = 0; i < yList.Count; i++)
            {
                y = yList[i];
                if (axis.IsAxisYLeft())
                {
                    point1 = new Point(canvas.Width - axis.LabelSize, y);
                    point2 = new Point(canvas.Width, y);
                }
                else
                {
                    point1 = new Point(ChartConstant.ZERO_D, y);
                    point2 = new Point(axis.LabelSize, y);
                }

                PathFigure labelPathFigure = new PathFigure();
                labelPathFigure.StartPoint = point1;
                labelPathFigure.Segments.Add(new LineSegment(point2, true));
                geometryGroup.Children.Add(new PathGeometry()
                {
                    Figures = new PathFigureCollection(new PathFigure[] { labelPathFigure })
                });
            }

            //坐标轴
            if (axis.IsAxisYLeft())
            {
                point1 = new Point(canvas.Width, yList.First());
                point2 = new Point(canvas.Width, yList.Last());
            }
            else
            {
                point1 = new Point(ChartConstant.ZERO_D, yList.First());
                point2 = new Point(ChartConstant.ZERO_D, yList.Last());
            }
            PathFigure axisPathFigure = new PathFigure();

            axisPathFigure.StartPoint = point1;
            axisPathFigure.Segments.Add(new LineSegment(point2, true));
            geometryGroup.Children.Add(new PathGeometry()
            {
                Figures = new PathFigureCollection(new PathFigure[] { axisPathFigure })
            });


            labelLinePath.Data = geometryGroup;
            canvas.Children.Add(labelLinePath);
        }