protected internal virtual void SetupXtraChartTitle(SCChart chart, string text, DevExpress.XtraCharts.ChartTitle title) { title.Alignment = Alignment; title.EnableAntialiasing = DefaultBoolean.True; title.Text = text; title.Visibility = DefaultBoolean.True; title.WordWrap = WordWrap; if (Dock.HasValue) { title.Dock = (DevExpress.XtraCharts.ChartTitleDockStyle)Dock.Value; } if (Indent.HasValue) { title.Indent = Indent.Value; } var font = Utils.StringToFont(Font, out Color fontColor); if (font != null) { title.Font = font; } if (fontColor != Color.Empty) { title.TextColor = fontColor; } }
protected internal virtual void BoundDataChanged(SCChart chart, Annotation annotation) { if (string.IsNullOrWhiteSpace(SeriesName) || Argument == null) { return; } var series = chart.Chart.Series[SeriesName] ?? throw new Exception($"Cannot find series '{SeriesName}'."); SeriesPoint annotationPoint = null; switch (series.ActualArgumentScaleType) { case DevExpress.XtraCharts.ScaleType.Qualitative: var strArgument = Convert.ToString(Argument); foreach (SeriesPoint point in series.Points) { if (point.Argument == strArgument) { annotationPoint = point; break; } } break; case DevExpress.XtraCharts.ScaleType.Numerical: var numArgument = Convert.ToDouble(Argument); foreach (SeriesPoint point in series.Points) { if (point.NumericalArgument == numArgument) { annotationPoint = point; break; } } break; case DevExpress.XtraCharts.ScaleType.DateTime: var dateArgument = Convert.ToDateTime(Argument); foreach (SeriesPoint point in series.Points) { if (point.DateTimeArgument == dateArgument) { annotationPoint = point; break; } } break; case DevExpress.XtraCharts.ScaleType.Auto: throw new Exception("Cannot determine series scale type to add annotation."); } if (annotationPoint == null) { throw new Exception("Cannot find anchor point for annotation."); } annotation.AnchorPoint = new SeriesPointAnchorPoint(annotationPoint); }
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 SetupXtraChartLegend(SCChart chart, Legend legend) { legend.EnableAntialiasing = DefaultBoolean.True; legend.AlignmentHorizontal = (DevExpress.XtraCharts.LegendAlignmentHorizontal)AlignmentHorizontal; legend.AlignmentVertical = (DevExpress.XtraCharts.LegendAlignmentVertical)AlignmentVertical; legend.MarkerMode = HideMarkers ? LegendMarkerMode.None : LegendMarkerMode.Marker; legend.MarkerOffset = MarkerOffset; legend.MaxHorizontalPercentage = MaxHorizontalPercentage; legend.MaxVerticalPercentage = MaxVerticalPercentage; if (Direction.HasValue) { legend.Direction = (DevExpress.XtraCharts.LegendDirection)Direction.Value; } if (legend.Direction == DevExpress.XtraCharts.LegendDirection.RightToLeft || legend.Direction == DevExpress.XtraCharts.LegendDirection.LeftToRight) { legend.EquallySpacedItems = true; } if (HorizontalIndent.HasValue) { legend.HorizontalIndent = HorizontalIndent.Value; } if (MarkerSize.HasValue) { legend.MarkerSize = MarkerSize.Value; } if (TextOffset.HasValue) { legend.TextOffset = TextOffset.Value; } if (VerticalIndent.HasValue) { legend.VerticalIndent = VerticalIndent.Value; } if (Visibility.HasValue) { legend.Visibility = Visibility.Value ? DefaultBoolean.True : DefaultBoolean.False; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { legend.BackColor = backColor; } var borderColor = Utils.ColorFromString(BorderColor); if (borderColor != Color.Empty) { legend.Border.Color = borderColor; legend.Border.Visibility = DefaultBoolean.True; } if (BorderThickness.HasValue) { legend.Border.Thickness = BorderThickness.Value; legend.Border.Visibility = DefaultBoolean.True; } var font = Utils.StringToFont(Font, out Color fontColor); if (font != null) { legend.Font = font; } if (fontColor != Color.Empty) { legend.TextColor = fontColor; } var shadowColor = Utils.ColorFromString(ShadowColor); if (shadowColor != Color.Empty) { legend.Shadow.Color = shadowColor; legend.Shadow.Visible = true; } if (ShadowSize.HasValue) { legend.Shadow.Size = ShadowSize.Value; legend.Shadow.Visible = true; } if (FillMode.HasValue) { legend.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 (legend.FillStyle.Options is RectangleGradientFillOptions gradientOptions) { var backColor2 = Utils.ColorFromString(BackColor2); if (backColor2 != Color.Empty) { gradientOptions.Color2 = backColor2; } if (FillGradientMode.HasValue) { gradientOptions.GradientMode = (DevExpress.XtraCharts.RectangleGradientMode)FillGradientMode.Value; } } break; case Chart.FillMode.Hatch: if (legend.FillStyle.Options is HatchFillOptions hatchOptions) { var backColor2 = Utils.ColorFromString(BackColor2); if (backColor2 != Color.Empty) { hatchOptions.Color2 = backColor2; } if (FillHatchStyle.HasValue) { hatchOptions.HatchStyle = FillHatchStyle.Value; } } break; } } if (TitleAlignment.HasValue) { legend.Title.Alignment = TitleAlignment.Value; } var titleFont = Utils.StringToFont(TitleFont, out Color titleColor); if (titleFont != null) { legend.Title.Font = titleFont; } if (titleColor != Color.Empty) { legend.Title.TextColor = titleColor; } legend.Title.WordWrap = TitleWordWrap; if (TitleMargins != null && TitleMargins.Length == 1) { legend.Title.Margins.All = TitleMargins[0]; } else if (TitleMargins != null && TitleMargins.Length == 4) { legend.Title.Margins.Left = TitleMargins[0]; legend.Title.Margins.Top = TitleMargins[1]; legend.Title.Margins.Right = TitleMargins[2]; legend.Title.Margins.Bottom = TitleMargins[3]; } if (!string.IsNullOrEmpty(TitleText)) { legend.Title.Text = TitleText; legend.Title.Visible = true; } if (Margins != null && Margins.Length == 1) { legend.Margins.All = Margins[0]; } else if (Margins != null && Margins.Length == 4) { legend.Margins.Left = Margins[0]; legend.Margins.Top = Margins[1]; legend.Margins.Right = Margins[2]; legend.Margins.Bottom = Margins[3]; } if (Padding != null && Padding.Length == 1) { legend.Padding.All = Padding[0]; } else if (Padding != null && Padding.Length == 4) { legend.Padding.Left = Padding[0]; legend.Padding.Top = Padding[1]; legend.Padding.Right = Padding[2]; legend.Padding.Bottom = Padding[3]; } else if (Padding != null) { throw new Exception("Invalid padding. Padding shall be an array with 1 or 4 integer values."); } }
protected internal virtual void SetupXtraChartTotalLabel(SCChart chart, TotalLabel label) { label.EnableAntialiasing = DefaultBoolean.True; label.Visible = true; 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 = DefaultBoolean.True; } if (BorderThickness.HasValue) { label.Border.Thickness = BorderThickness.Value; label.Border.Visibility = DefaultBoolean.True; } var font = Utils.StringToFont(Font, out Color fontColor); if (font != null) { label.Font = font; } if (fontColor != Color.Empty) { label.TextColor = fontColor; } if (MaxLineCount.HasValue) { label.MaxLineCount = MaxLineCount.Value; } if (MaxWidth.HasValue) { label.MaxWidth = MaxWidth.Value; } var shadowColor = Utils.ColorFromString(ShadowColor); if (shadowColor != Color.Empty) { label.Shadow.Color = shadowColor; label.Shadow.Visible = true; } if (ShadowSize.HasValue) { label.Shadow.Size = ShadowSize.Value; label.Shadow.Visible = true; } label.TextAlignment = TextAlignment; if (!string.IsNullOrWhiteSpace(TextPattern)) { label.TextPattern = TextPattern; } if (label is StackedBarTotalLabel stackedBarLabel) { if (ResolveOverlappingMinIndent.HasValue) { stackedBarLabel.ResolveOverlappingMinIndent = ResolveOverlappingMinIndent.Value; } stackedBarLabel.ResolveOverlappingMode = (DevExpress.XtraCharts.ResolveOverlappingMode)ResolveOverlappingMode; if (ConnectorDashStyle.HasValue) { stackedBarLabel.ConnectorLineStyle.DashStyle = ConnectorDashStyle.Value; stackedBarLabel.ShowConnector = true; } if (ConnectorLineJoin.HasValue) { stackedBarLabel.ConnectorLineStyle.LineJoin = ConnectorLineJoin.Value; stackedBarLabel.ShowConnector = true; } if (ConnectorThickness.HasValue) { stackedBarLabel.ConnectorLineStyle.Thickness = ConnectorThickness.Value; stackedBarLabel.ShowConnector = true; } if (ShowConnector) { stackedBarLabel.ShowConnector = true; } if (Indent.HasValue) { stackedBarLabel.Indent = Indent.Value; } } 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 != 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 != Color.Empty) { hatchOptions.Color2 = backColor2; } if (FillHatchStyle.HasValue) { hatchOptions.HatchStyle = FillHatchStyle.Value; } } break; } } }
protected internal virtual void SetupXtraChartSeriesLabel(SCChart chart, DevExpress.XtraCharts.Series series) { var label = series.Label; label.EnableAntialiasing = DefaultBoolean.True; 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 = DefaultBoolean.True; } if (BorderThickness.HasValue) { label.Border.Thickness = BorderThickness.Value; label.Border.Visibility = DefaultBoolean.True; } var font = Utils.StringToFont(Font, out Color fontColor); if (font != null) { label.Font = font; } if (fontColor != Color.Empty) { label.TextColor = fontColor; } var lineColor = Utils.ColorFromString(LineColor); if (lineColor != Color.Empty) { label.LineColor = lineColor; } if (LineLength.HasValue) { label.LineLength = LineLength.Value; } if (LineVisibility.HasValue) { label.LineVisibility = LineVisibility.Value ? DefaultBoolean.True : DefaultBoolean.False; } if (MaxLineCount.HasValue) { label.MaxLineCount = MaxLineCount.Value; } if (MaxWidth.HasValue) { label.MaxWidth = MaxWidth.Value; } if (ResolveOverlappingMinIndent.HasValue) { label.ResolveOverlappingMinIndent = ResolveOverlappingMinIndent.Value; } if (ResolveOverlappingMode.HasValue) { label.ResolveOverlappingMode = (DevExpress.XtraCharts.ResolveOverlappingMode)ResolveOverlappingMode.Value; } var shadowColor = Utils.ColorFromString(ShadowColor); if (shadowColor != Color.Empty) { label.Shadow.Color = shadowColor; label.Shadow.Visible = true; } if (ShadowSize.HasValue) { label.Shadow.Size = ShadowSize.Value; label.Shadow.Visible = true; } if (TextAlignment.HasValue) { label.TextAlignment = TextAlignment.Value; } if (TextOrientation.HasValue) { label.TextOrientation = (DevExpress.XtraCharts.TextOrientation)TextOrientation.Value; } if (TextPattern != null) //allow empty string pattern { label.TextPattern = TextPattern; } if (ShowLabels.HasValue) { series.LabelsVisibility = ShowLabels.Value ? DefaultBoolean.True : DefaultBoolean.False; } 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 != 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 != Color.Empty) { hatchOptions.Color2 = backColor2; } if (FillHatchStyle.HasValue) { hatchOptions.HatchStyle = FillHatchStyle.Value; } } break; } } if (label is BarSeriesLabel labelBar) { if (Indent.HasValue) { labelBar.Indent = Indent.Value; } } if (label is PointSeriesLabel labelPoint) { if (Angle.HasValue) { labelPoint.Angle = Angle.Value; } } if (label is RangeAreaSeriesLabel labelRangeArea) { if (RangeAreaLabelKind.HasValue) { labelRangeArea.Kind = (DevExpress.XtraCharts.RangeAreaLabelKind)RangeAreaLabelKind.Value; } if (RangeAreaMaxValueAngle.HasValue) { labelRangeArea.MaxValueAngle = RangeAreaMaxValueAngle.Value; } if (RangeAreaMinValueAngle.HasValue) { labelRangeArea.MinValueAngle = RangeAreaMinValueAngle.Value; } } if (label is RangeBarSeriesLabel labelRangeBar) { if (RangeBarLabelKind.HasValue) { labelRangeBar.Kind = (DevExpress.XtraCharts.RangeBarLabelKind)RangeBarLabelKind.Value; } if (RangeBarLabelPosition.HasValue) { labelRangeBar.Position = (DevExpress.XtraCharts.RangeBarLabelPosition)RangeBarLabelPosition.Value; } } }
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 SetupXtraChartAxis(SCChart chart, AxisBase axis) { var axisX = axis as AxisXBase; var axisX3D = axis as AxisX3D; var axisXRadar = axis as RadarAxisX; //Y axis does not use QualitativeScaleOptions /* * var axisY = axis as AxisYBase; * var axisY3D = axis as AxisY3D; * var axisYRadar = axis as RadarAxisY; */ if (AggregateFunction.HasValue) { axis.DateTimeScaleOptions.AggregateFunction = (DevExpress.XtraCharts.AggregateFunction)AggregateFunction.Value; axis.NumericScaleOptions.AggregateFunction = (DevExpress.XtraCharts.AggregateFunction)AggregateFunction.Value; if (axisX != null) { axisX.QualitativeScaleOptions.AggregateFunction = (DevExpress.XtraCharts.AggregateFunction)AggregateFunction.Value; } } axis.DateTimeScaleOptions.AutoGrid = AutoGrid; axis.NumericScaleOptions.AutoGrid = AutoGrid; if (axisX != null) { axisX.QualitativeScaleOptions.AutoGrid = AutoGrid; } if (axisX3D != null) { axisX3D.QualitativeScaleOptions.AutoGrid = AutoGrid; } if (axisXRadar != null) { axisXRadar.QualitativeScaleOptions.AutoGrid = AutoGrid; } if (ScaleMode.HasValue) { axis.DateTimeScaleOptions.ScaleMode = (DevExpress.XtraCharts.ScaleMode)ScaleMode.Value; axis.NumericScaleOptions.ScaleMode = (DevExpress.XtraCharts.ScaleMode)ScaleMode.Value; } if (GridOffset.HasValue) { axis.DateTimeScaleOptions.GridOffset = GridOffset.Value; axis.NumericScaleOptions.GridOffset = GridOffset.Value; if (axisX != null) { axisX.QualitativeScaleOptions.GridOffset = GridOffset.Value; } if (axisX3D != null) { axisX3D.QualitativeScaleOptions.GridOffset = GridOffset.Value; } if (axisXRadar != null) { axisXRadar.QualitativeScaleOptions.GridOffset = GridOffset.Value; } } if (GridSpacing.HasValue) { axis.DateTimeScaleOptions.GridSpacing = GridSpacing.Value; axis.NumericScaleOptions.GridSpacing = GridSpacing.Value; if (axisX != null) { axisX.QualitativeScaleOptions.GridSpacing = GridSpacing.Value; } if (axisX3D != null) { axisX3D.QualitativeScaleOptions.GridSpacing = GridSpacing.Value; } if (axisXRadar != null) { axisXRadar.QualitativeScaleOptions.GridSpacing = GridSpacing.Value; } } if (MeasureUnitMultiplier.HasValue) { axis.DateTimeScaleOptions.MeasureUnitMultiplier = MeasureUnitMultiplier.Value; } if (MinGridSpacingLength.HasValue) { axis.DateTimeScaleOptions.MinGridSpacingLength = MinGridSpacingLength.Value; axis.NumericScaleOptions.MinGridSpacingLength = MinGridSpacingLength.Value; if (axisX != null) { axisX.QualitativeScaleOptions.MinGridSpacingLength = MinGridSpacingLength.Value; } if (axisX3D != null) { axisX3D.QualitativeScaleOptions.MinGridSpacingLength = MinGridSpacingLength.Value; } if (axisXRadar != null) { axisXRadar.QualitativeScaleOptions.MinGridSpacingLength = MinGridSpacingLength.Value; } } if (ProcessMissingPoints.HasValue) { axis.DateTimeScaleOptions.ProcessMissingPoints = (DevExpress.XtraCharts.ProcessMissingPointsMode)ProcessMissingPoints.Value; axis.NumericScaleOptions.ProcessMissingPoints = (DevExpress.XtraCharts.ProcessMissingPointsMode)ProcessMissingPoints.Value; } if (DateTimeGridAlignment.HasValue) { axis.DateTimeScaleOptions.GridAlignment = (DevExpress.XtraCharts.DateTimeGridAlignment)DateTimeGridAlignment.Value; } if (DateTimeMeasureUnit.HasValue) { axis.DateTimeScaleOptions.MeasureUnit = (DevExpress.XtraCharts.DateTimeMeasureUnit)DateTimeMeasureUnit.Value; } if (NumericGridAlignment.HasValue) { axis.NumericScaleOptions.CustomGridAlignment = NumericGridAlignment.Value; } if (NumericMeasureUnit.HasValue) { axis.NumericScaleOptions.CustomMeasureUnit = NumericMeasureUnit.Value; } var majorLineColor = Utils.ColorFromString(MajorLineColor); if (majorLineColor != System.Drawing.Color.Empty) { axis.GridLines.Color = majorLineColor; axis.GridLines.Visible = true; } if (MajorLineDashStyle.HasValue) { axis.GridLines.LineStyle.DashStyle = (DevExpress.XtraCharts.DashStyle)MajorLineDashStyle.Value; axis.GridLines.Visible = true; } if (MajorLineJoin.HasValue) { axis.GridLines.LineStyle.LineJoin = MajorLineJoin.Value; axis.GridLines.Visible = true; } if (MajorLineThickness.HasValue) { axis.GridLines.LineStyle.Thickness = MajorLineThickness.Value; axis.GridLines.Visible = true; } var minorLineColor = Utils.ColorFromString(MinorLineColor); if (minorLineColor != System.Drawing.Color.Empty) { axis.GridLines.MinorColor = minorLineColor; axis.GridLines.MinorVisible = true; } if (MinorLineDashStyle.HasValue) { axis.GridLines.MinorLineStyle.DashStyle = (DevExpress.XtraCharts.DashStyle)MinorLineDashStyle.Value; axis.GridLines.MinorVisible = true; } if (MinorLineJoin.HasValue) { axis.GridLines.MinorLineStyle.LineJoin = MinorLineJoin.Value; axis.GridLines.MinorVisible = true; } if (MinorLineThickness.HasValue) { axis.GridLines.MinorLineStyle.Thickness = MinorLineThickness.Value; axis.GridLines.MinorVisible = true; } if (ShowLines) { axis.GridLines.Visible = true; } if (ShowMinorLines) { axis.GridLines.MinorVisible = true; } if (Interlaced) { axis.Interlaced = true; } var interlacedColor = Utils.ColorFromString(InterlacedColor); if (interlacedColor != System.Drawing.Color.Empty) { axis.InterlacedColor = interlacedColor; } if (Logarithmic) { axis.Logarithmic = true; } if (LogarithmicBase.HasValue) { axis.LogarithmicBase = LogarithmicBase.Value; } if (MinorCount.HasValue) { axis.MinorCount = MinorCount.Value; } if (AlwaysShowZeroLevel) { axis.WholeRange.AlwaysShowZeroLevel = true; } if (MinValue != null) { axis.WholeRange.MinValue = MinValue; } if (MaxValue != null) { axis.WholeRange.MaxValue = MaxValue; } if (SideMarginsValue.HasValue) { axis.WholeRange.SideMarginsValue = SideMarginsValue.Value; axis.WholeRange.AutoSideMargins = false; } if (axis is Axis2D axis2D) { if (Alignment.HasValue) { axis2D.Alignment = (DevExpress.XtraCharts.AxisAlignment)Alignment.Value; } var color = Utils.ColorFromString(Color); if (color != System.Drawing.Color.Empty) { axis2D.Color = color; } if (InterlacedFillMode.HasValue) { axis2D.InterlacedFillStyle.FillMode = (DevExpress.XtraCharts.FillMode)InterlacedFillMode.Value; switch (InterlacedFillMode.Value) { case FillMode.Empty: break; case FillMode.Solid: break; case FillMode.Gradient: if (axis2D.InterlacedFillStyle.Options is RectangleGradientFillOptions gradientOptions) { var color2 = Utils.ColorFromString(InterlacedColor2); if (color2 != System.Drawing.Color.Empty) { gradientOptions.Color2 = color2; } if (InterlacedGradientMode.HasValue) { gradientOptions.GradientMode = (DevExpress.XtraCharts.RectangleGradientMode)InterlacedGradientMode.Value; } } break; case FillMode.Hatch: if (axis2D.InterlacedFillStyle.Options is HatchFillOptions hatchOptions) { var color2 = Utils.ColorFromString(InterlacedColor2); if (color2 != System.Drawing.Color.Empty) { hatchOptions.Color2 = color2; } if (InterlacedHatchStyle.HasValue) { hatchOptions.HatchStyle = InterlacedHatchStyle.Value; } } break; } } if (LabelVisibilityMode.HasValue) { axis2D.LabelVisibilityMode = (DevExpress.XtraCharts.AxisLabelVisibilityMode)LabelVisibilityMode.Value; } if (Thickness.HasValue) { axis2D.Thickness = Thickness.Value; } if (TickmarkCrossAxis) { axis2D.Tickmarks.CrossAxis = true; } if (MajorTickmarkLength.HasValue) { axis2D.Tickmarks.Length = MajorTickmarkLength.Value; } if (MajorTickmarkThickness.HasValue) { axis2D.Tickmarks.Thickness = MajorTickmarkThickness.Value; } if (MinorTickmarkLength.HasValue) { axis2D.Tickmarks.Length = MinorTickmarkLength.Value; } if (MinorTickmarkThickness.HasValue) { axis2D.Tickmarks.Thickness = MinorTickmarkThickness.Value; } if (HideMajorTickmarks) { axis2D.Tickmarks.Visible = false; } if (HideMinorTickmarks) { axis2D.Tickmarks.MinorVisible = false; } if (Visibility.HasValue) { axis2D.Visibility = Visibility.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False; } if (VisibleInPanes != null && VisibleInPanes.Length > 0) { if (chart.Chart.Diagram is not XYDiagram chartDiagram) { throw new Exception("Property VisibleInPanes can be set only in 2D XY charts."); } foreach (var paneName in VisibleInPanes) { var pane = chartDiagram.Panes[paneName]; if (pane == null) { throw new Exception($"Cannot find pane '{paneName}' to setup VisibleInPanes."); } axis2D.SetVisibilityInPane(true, pane); } } if (HiddenInPanes != null && HiddenInPanes.Length > 0) { if (chart.Chart.Diagram is not XYDiagram chartDiagram) { throw new Exception("Property HiddenInPanes can be set only in 2D XY charts."); } foreach (var paneName in HiddenInPanes) { var pane = chartDiagram.Panes[paneName]; if (pane == null) { throw new Exception($"Cannot find pane '{paneName}' to setup HiddenInPanes."); } axis2D.SetVisibilityInPane(false, pane); } } } if (axis is Axis axisEx) { if (AutoScaleBreaks) { axisEx.AutoScaleBreaks.Enabled = true; } if (AutoScaleBreaksMaxCount.HasValue) { axisEx.AutoScaleBreaks.MaxCount = AutoScaleBreaksMaxCount.Value; axisEx.AutoScaleBreaks.Enabled = true; } var scaleBreakColor = Utils.ColorFromString(ScaleBreakColor); if (scaleBreakColor != System.Drawing.Color.Empty) { axisEx.ScaleBreakOptions.Color = scaleBreakColor; } if (ScaleBreakSize.HasValue) { axisEx.ScaleBreakOptions.SizeInPixels = ScaleBreakSize.Value; } if (ScaleBreakStyle.HasValue) { axisEx.ScaleBreakOptions.Style = (DevExpress.XtraCharts.ScaleBreakStyle)ScaleBreakStyle.Value; } if (Reverse) { axisEx.Reverse = Reverse; } } if (axis is RadarAxis axisRadar) { if (InterlacedFillMode.HasValue) { axisRadar.InterlacedFillStyle.FillMode = (DevExpress.XtraCharts.FillMode)InterlacedFillMode.Value; switch (InterlacedFillMode.Value) { case FillMode.Empty: break; case FillMode.Solid: break; case FillMode.Gradient: if (axisRadar.InterlacedFillStyle.Options is PolygonGradientFillOptions polygonOptions) { var color2 = Utils.ColorFromString(InterlacedColor2); if (color2 != System.Drawing.Color.Empty) { polygonOptions.Color2 = color2; } if (InterlacedGradientMode.HasValue) { polygonOptions.GradientMode = (DevExpress.XtraCharts.PolygonGradientMode)InterlacedRadarGradientMode.Value; } } break; case FillMode.Hatch: if (axisRadar.InterlacedFillStyle.Options is HatchFillOptions hatchOptions) { var color2 = Utils.ColorFromString(InterlacedColor2); if (color2 != System.Drawing.Color.Empty) { hatchOptions.Color2 = color2; } if (InterlacedHatchStyle.HasValue) { hatchOptions.HatchStyle = InterlacedHatchStyle.Value; } } break; } } } }
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); }
protected internal virtual void SetupXtraChartAnnotation(SCChart chart, string name, string text, TextAnnotation annotation) { //Need this to link annotation to series point in BoundDataChanged annotation.Tag = this; if (!string.IsNullOrWhiteSpace(name)) { annotation.Name = name; } annotation.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True; if (Angle.HasValue) { annotation.Angle = Angle.Value; } var backColor = Utils.ColorFromString(BackColor); if (backColor != Color.Empty) { annotation.BackColor = backColor; } var borderColor = Utils.ColorFromString(BorderColor); if (borderColor != Color.Empty) { annotation.Border.Color = borderColor; annotation.Border.Visibility = DevExpress.Utils.DefaultBoolean.True; } if (BorderThickness.HasValue) { annotation.Border.Thickness = BorderThickness.Value; annotation.Border.Visibility = DevExpress.Utils.DefaultBoolean.True; } if (BorderVisible.HasValue) { annotation.Border.Visibility = BorderVisible.Value ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.Default; } if (FillMode.HasValue) { annotation.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 (annotation.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 (annotation.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) { annotation.Font = font; } if (textColor != Color.Empty) { annotation.TextColor = textColor; } if (ConnectorStyle.HasValue) { annotation.ConnectorStyle = ConnectorStyle.Value; } if (Width.HasValue) { annotation.Width = Width.Value; annotation.AutoSize = false; } if (Height.HasValue) { annotation.Height = Height.Value; annotation.AutoSize = false; } if (Padding != null && Padding.Length == 1) { annotation.Padding.All = Padding[0]; } else if (Padding != null && Padding.Length == 4) { annotation.Padding.Left = Padding[0]; annotation.Padding.Top = Padding[1]; annotation.Padding.Right = Padding[2]; annotation.Padding.Bottom = Padding[3]; } else if (Padding != null) { throw new Exception("Invalid padding. Padding shall be an array with 1 or 4 integer values."); } var shadowColor = Utils.ColorFromString(ShadowColor); if (shadowColor != Color.Empty) { annotation.Shadow.Color = shadowColor; annotation.Shadow.Visible = true; } if (ShadowSize.HasValue) { annotation.Shadow.Size = ShadowSize.Value; annotation.Shadow.Visible = true; } if (ShapeFillet.HasValue) { annotation.ShapeFillet = ShapeFillet.Value; } if (ShapeKind.HasValue) { annotation.ShapeKind = ShapeKind.Value; } annotation.LabelMode = LabelMode; if (AnchorAngle.HasValue || AnchorConnectorLength.HasValue) { annotation.ShapePosition = new RelativePosition(AnchorAngle ?? 0.0, AnchorConnectorLength ?? 0.0); } else if (AnchorDockCorner.HasValue) { XYDiagramPane pane = null; if (!string.IsNullOrWhiteSpace(AnchorDockPane)) { if (chart.Chart.Diagram is not XYDiagram2D diagramXY) { throw new Exception("Panes are available only in 2D XY charts."); } pane = diagramXY.Panes[AnchorDockPane]; if (pane == null) { throw new Exception($"Cannot find pane '{AnchorDockPane}'."); } } var freePosition = new FreePosition(); if (pane != null) { freePosition.DockTarget = pane; } freePosition.DockCorner = AnchorDockCorner.Value; if (DockInnerIndents != null && DockInnerIndents.Length == 1) { freePosition.InnerIndents.All = DockInnerIndents[0]; } else if (DockInnerIndents != null && DockInnerIndents.Length == 4) { freePosition.InnerIndents.Left = DockInnerIndents[0]; freePosition.InnerIndents.Top = DockInnerIndents[1]; freePosition.InnerIndents.Right = DockInnerIndents[2]; freePosition.InnerIndents.Bottom = DockInnerIndents[3]; } if (DockOuterIndents != null && DockOuterIndents.Length == 1) { freePosition.OuterIndents.All = DockOuterIndents[0]; } else if (DockOuterIndents != null && DockOuterIndents.Length == 4) { freePosition.OuterIndents.Left = DockOuterIndents[0]; freePosition.OuterIndents.Top = DockOuterIndents[1]; freePosition.OuterIndents.Right = DockOuterIndents[2]; freePosition.OuterIndents.Bottom = DockOuterIndents[3]; } annotation.ShapePosition = freePosition; } annotation.Text = text; annotation.Visible = true; if (TextAlignment.HasValue) { annotation.TextAlignment = TextAlignment.Value; } if (ZOrder.HasValue) { annotation.ZOrder = ZOrder.Value; } }