示例#1
0
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }

            if (axis is not Axis axis2D)
            {
                throw new Exception("Only 2D axis except SwiftPlot support scale breaks.");
            }

            var scaleBreak = new ScaleBreak();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                scaleBreak.Name = Name;
            }

            scaleBreak.Edge1 = Edge1;
            scaleBreak.Edge2 = Edge2;

            scaleBreak.Visible = true;

            axis2D.ScaleBreaks.Add(scaleBreak);
        }
示例#2
0
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }


            var axis2D = axis as Axis2D ?? throw new Exception("Strips are supported only in 2D charts.");

            var strip = new Strip();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                strip.Name = Name;
            }

            strip.AxisLabelText = AxisLabelText;

            var backColor = Utils.ColorFromString(Color);

            if (backColor != System.Drawing.Color.Empty)
            {
                strip.Color = backColor;
            }

            if (FillMode.HasValue)
            {
                strip.FillStyle.FillMode = FillMode.Value;
                switch (FillMode.Value)
                {
                case DevExpress.XtraCharts.FillMode.Empty:
                    break;

                case DevExpress.XtraCharts.FillMode.Solid:
                    break;

                case DevExpress.XtraCharts.FillMode.Gradient:
                    if (strip.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                    {
                        var backColor2 = Utils.ColorFromString(Color2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            gradientOptions.Color2 = backColor2;
                        }
                        if (FillGradientMode.HasValue)
                        {
                            gradientOptions.GradientMode = FillGradientMode.Value;
                        }
                    }
                    break;

                case DevExpress.XtraCharts.FillMode.Hatch:
                    if (strip.FillStyle.Options is HatchFillOptions hatchOptions)
                    {
                        var backColor2 = Utils.ColorFromString(Color2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            hatchOptions.Color2 = backColor2;
                        }
                        if (FillHatchStyle.HasValue)
                        {
                            hatchOptions.HatchStyle = FillHatchStyle.Value;
                        }
                    }
                    break;
                }
            }

            if (!string.IsNullOrWhiteSpace(LegendName))
            {
                var legend = ChartContext.Chart.Legends[LegendName] ?? throw new Exception($"Invalid legend name: '{LegendName}'");
                strip.Legend = legend;
            }

            if (MinLimit != null)
            {
                strip.MinLimit.AxisValue = MinLimit;
                strip.MinLimit.Enabled   = true;
            }
            if (MaxLimit != null)
            {
                strip.MaxLimit.AxisValue = MaxLimit;
                strip.MaxLimit.Enabled   = true;
            }

            strip.ShowAxisLabel = ShowAxisLabel;
            strip.ShowInLegend  = ShowInLegend;

            axis2D.Strips.Add(strip);
        }
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }

            if (axis is not Axis2D axis2D)
            {
                throw new Exception("Only 2D axis support custom labels.");
            }

            var label = new CustomAxisLabel();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                label.Name = Name;
            }

            label.AxisValue = Value;

            var backColor = Utils.ColorFromString(BackColor);

            if (backColor != Color.Empty)
            {
                label.BackColor = backColor;
            }

            var borderColor = Utils.ColorFromString(BorderColor);

            if (borderColor != Color.Empty)
            {
                label.Border.Color      = borderColor;
                label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
            if (BorderThickness.HasValue)
            {
                label.Border.Thickness  = BorderThickness.Value;
                label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
            if (BorderVisible.HasValue)
            {
                label.Border.Visibility = BorderVisible.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.Default;
            }

            if (FillMode.HasValue)
            {
                label.FillStyle.FillMode = FillMode.Value;
                switch (FillMode.Value)
                {
                case DevExpress.XtraCharts.FillMode.Empty:
                    break;

                case DevExpress.XtraCharts.FillMode.Solid:
                    break;

                case DevExpress.XtraCharts.FillMode.Gradient:
                    if (label.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                    {
                        var backColor2 = Utils.ColorFromString(BackColor2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            gradientOptions.Color2 = backColor2;
                        }
                        if (FillGradientMode.HasValue)
                        {
                            gradientOptions.GradientMode = FillGradientMode.Value;
                        }
                    }
                    break;

                case DevExpress.XtraCharts.FillMode.Hatch:
                    if (label.FillStyle.Options is HatchFillOptions hatchOptions)
                    {
                        var backColor2 = Utils.ColorFromString(BackColor2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            hatchOptions.Color2 = backColor2;
                        }
                        if (FillHatchStyle.HasValue)
                        {
                            hatchOptions.HatchStyle = FillHatchStyle.Value;
                        }
                    }
                    break;
                }
            }

            var font = Utils.StringToFont(Font, out Color textColor);

            if (font != null)
            {
                label.Font = font;
            }
            if (textColor != Color.Empty)
            {
                label.TextColor = textColor;
            }

            if (ShowGridLine)
            {
                label.GridLineVisible = true;
            }

            label.Visible = true;


            axis2D.CustomLabels.Add(label);
        }
示例#4
0
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }

            if (axis is not Axis2D axis2D)
            {
                throw new Exception("Only 2D axis support constant lines.");
            }

            var line = new ConstantLine();

            if (!string.IsNullOrWhiteSpace(Name))
            {
                line.Name = Name;
            }

            var color = Utils.ColorFromString(Color);

            if (color != System.Drawing.Color.Empty)
            {
                line.Color = color;
            }

            if (!string.IsNullOrWhiteSpace(LegendName))
            {
                var legend = ChartContext.Chart.Legends[LegendName] ?? throw new Exception($"Invalid legend name: '{LegendName}'");
                line.Legend = legend;
            }

            if (!string.IsNullOrWhiteSpace(LegendText))
            {
                line.LegendText = LegendText;
            }

            if (LineDashStyle.HasValue)
            {
                line.LineStyle.DashStyle = LineDashStyle.Value;
            }
            if (LineJoin.HasValue)
            {
                line.LineStyle.LineJoin = LineJoin.Value;
            }
            if (LineThickness.HasValue)
            {
                line.LineStyle.Thickness = LineThickness.Value;
            }

            line.ShowBehind   = ShowBehind;
            line.ShowInLegend = ShowInLegend;

            if (!string.IsNullOrWhiteSpace(Title))
            {
                line.Title.Text    = Title;
                line.Title.Visible = true;
            }
            if (TitleAlignment.HasValue)
            {
                line.Title.Alignment = TitleAlignment.Value;
            }
            var titleFont = Utils.StringToFont(TitleFont, out Color titleColor);

            if (titleFont != null)
            {
                line.Title.Font = titleFont;
            }
            if (titleColor != System.Drawing.Color.Empty)
            {
                line.Title.TextColor = titleColor;
            }
            line.Title.ShowBelowLine      = TitleBelowLine;
            line.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

            line.Visible = true;

            axis2D.ConstantLines.Add(line);
        }
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }

            if (axis is not Axis2D axis2D)
            {
                throw new Exception("Only 2D axis support title.");
            }

            var title = axis2D.Title;

            title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

            if (Alignment.HasValue)
            {
                title.Alignment = Alignment.Value;
            }

            var font = Utils.StringToFont(Font, out Color textColor);

            if (font != null)
            {
                title.Font = font;
            }
            if (textColor != Color.Empty)
            {
                title.TextColor = textColor;
            }

            if (MaxLineCount.HasValue)
            {
                title.MaxLineCount = MaxLineCount.Value;
            }

            if (!string.IsNullOrWhiteSpace(Text))
            {
                title.Text       = Text;
                title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }

            if (Visible.HasValue)
            {
                title.Visibility = Visible.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
            }

            title.WordWrap = WordWrap;
        }
示例#6
0
        protected override void UpdateChart()
        {
            AxisBase axis;

            if (!string.IsNullOrWhiteSpace(AxisName))
            {
                axis = BaseAxisCmdlet.GetSecondaryAxis(ChartContext.Chart.Diagram, AxisType, AxisName);
                if (axis == null)
                {
                    throw new Exception($"Cannot find axis '{AxisName}'.");
                }
            }
            else
            {
                axis = BaseAxisCmdlet.GetPrimaryAxis(ChartContext.Chart.Diagram, AxisType);
                if (axis == null)
                {
                    throw new Exception("Cannot find primary axis.");
                }
            }

            var label = axis.Label;

            label.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;

            if (Angle.HasValue)
            {
                label.Angle = Angle.Value;
            }

            var backColor = Utils.ColorFromString(BackColor);

            if (backColor != Color.Empty)
            {
                label.BackColor = backColor;
            }

            var borderColor = Utils.ColorFromString(BorderColor);

            if (borderColor != Color.Empty)
            {
                label.Border.Color      = borderColor;
                label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
            if (BorderThickness.HasValue)
            {
                label.Border.Thickness  = BorderThickness.Value;
                label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
            }
            if (BorderVisible.HasValue)
            {
                label.Border.Visibility = BorderVisible.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.Default;
            }

            if (FillMode.HasValue)
            {
                label.FillStyle.FillMode = FillMode.Value;
                switch (FillMode.Value)
                {
                case DevExpress.XtraCharts.FillMode.Empty:
                    break;

                case DevExpress.XtraCharts.FillMode.Solid:
                    break;

                case DevExpress.XtraCharts.FillMode.Gradient:
                    if (label.FillStyle.Options is RectangleGradientFillOptions gradientOptions)
                    {
                        var backColor2 = Utils.ColorFromString(BackColor2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            gradientOptions.Color2 = backColor2;
                        }
                        if (FillGradientMode.HasValue)
                        {
                            gradientOptions.GradientMode = FillGradientMode.Value;
                        }
                    }
                    break;

                case DevExpress.XtraCharts.FillMode.Hatch:
                    if (label.FillStyle.Options is HatchFillOptions hatchOptions)
                    {
                        var backColor2 = Utils.ColorFromString(BackColor2);
                        if (backColor2 != System.Drawing.Color.Empty)
                        {
                            hatchOptions.Color2 = backColor2;
                        }
                        if (FillHatchStyle.HasValue)
                        {
                            hatchOptions.HatchStyle = FillHatchStyle.Value;
                        }
                    }
                    break;
                }
            }

            var font = Utils.StringToFont(Font, out Color textColor);

            if (font != null)
            {
                label.Font = font;
            }
            if (textColor != Color.Empty)
            {
                label.TextColor = textColor;
            }

            if (MaxLineCount.HasValue)
            {
                label.MaxLineCount = MaxLineCount.Value;
            }
            if (MaxWidth.HasValue)
            {
                label.MaxWidth = MaxWidth.Value;
            }
            if (Staggered.HasValue)
            {
                label.Staggered = Staggered.Value;
            }
            if (TextAlignment.HasValue)
            {
                label.TextAlignment = TextAlignment.Value;
            }
            if (!string.IsNullOrWhiteSpace(TextPattern))
            {
                label.TextPattern = TextPattern;
            }
            if (Visible.HasValue)
            {
                label.Visible = Visible.Value;
            }
            label.ResolveOverlappingOptions.AllowHide    = !DoNotAutoHide;
            label.ResolveOverlappingOptions.AllowRotate  = !DoNotAutoRotate;
            label.ResolveOverlappingOptions.AllowStagger = !DoNotAutoStagger;
            if (MinIndent.HasValue)
            {
                label.ResolveOverlappingOptions.MinIndent = MinIndent.Value;
            }
        }