public SCChart SetAxis(ChartAxisType axisType, AxisOptions options = null) { options ??= new AxisOptions(); var axis = AxisOptions.GetPrimaryAxis(Chart.Diagram, axisType); axis.Tag = options; options.SetupXtraChartAxis(this, axis); CurrentAxis = axis; return(this); }
public SCChart AddScaleBreak(ChartAxisType axisType, string axisName, string name, object edge1, object edge2) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(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); return(this); }
protected internal virtual void SetupXtraChartStrip(SCChart chart, ChartAxisType axisType, string axisName) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(chart.Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(chart.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 = (DevExpress.XtraCharts.FillMode)FillMode.Value; switch (FillMode.Value) { case Chart.FillMode.Empty: break; case Chart.FillMode.Solid: break; case Chart.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 = (DevExpress.XtraCharts.RectangleGradientMode)FillGradientMode.Value; } } break; case Chart.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 = chart.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 internal virtual void SetupXtraChartAxisTitle(SCChart chart, ChartAxisType axisType, string axisName, string text) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(chart.Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(chart.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; }
protected internal virtual void SetupXtraChartAxisLabel(SCChart chart, ChartAxisType axisType, string axisName) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(chart.Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(chart.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 = (DevExpress.XtraCharts.FillMode)FillMode.Value; switch (FillMode.Value) { case Chart.FillMode.Empty: break; case Chart.FillMode.Solid: break; case Chart.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 = (DevExpress.XtraCharts.RectangleGradientMode)FillGradientMode.Value; } } break; case Chart.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 = AutoHide; label.ResolveOverlappingOptions.AllowRotate = AutoRotate; label.ResolveOverlappingOptions.AllowStagger = AutoStagger; if (MinIndent.HasValue) { label.ResolveOverlappingOptions.MinIndent = MinIndent.Value; } }
protected internal virtual void SetupXtraChartCustomLabel(SCChart chart, ChartAxisType axisType, string axisName, string name, object value) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(chart.Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(chart.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 != System.Drawing.Color.Empty) { label.BackColor = backColor; } var borderColor = Utils.ColorFromString(BorderColor); if (borderColor != System.Drawing.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 = (DevExpress.XtraCharts.FillMode)FillMode.Value; switch (FillMode.Value) { case Chart.FillMode.Empty: break; case Chart.FillMode.Solid: break; case Chart.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 = (DevExpress.XtraCharts.RectangleGradientMode)FillGradientMode.Value; } } break; case Chart.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 System.Drawing.Color textColor); if (font != null) { label.Font = font; } if (textColor != System.Drawing.Color.Empty) { label.TextColor = textColor; } if (ShowGridLine) { label.GridLineVisible = true; } label.Visible = true; axis2D.CustomLabels.Add(label); }
protected internal virtual void SetupXtraChartConstantLine(SCChart chart, ChartAxisType axisType, string axisName, string name, object value) { AxisBase axis; if (!string.IsNullOrWhiteSpace(axisName)) { axis = AxisOptions.GetSecondaryAxis(chart.Chart.Diagram, axisType, axisName); if (axis == null) { throw new Exception($"Cannot find axis '{axisName}'."); } } else { axis = AxisOptions.GetPrimaryAxis(chart.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 = chart.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 = (DevExpress.XtraCharts.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 = (DevExpress.XtraCharts.ConstantLineTitleAlignment)TitleAlignment.Value; } var titleFont = Utils.StringToFont(TitleFont, out System.Drawing.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); }