コード例 #1
0
        public SCChart SetAxisLabel(ChartAxisType axisType, string axisName, AxisLabelOptions options = null)
        {
            options ??= new AxisLabelOptions();
            options.SetupXtraChartAxisLabel(this, axisType, axisName);

            return(this);
        }
コード例 #2
0
        private void ConfigureCategoricalAxes(object o)
        {
            var pso   = o as SolidPSObjectBase;
            var xtype = GetPropertyType(pso, this.LabelMemberPath);

            ChartAxisType xaxistype = ChartAxisType.CategoryX;
            ChartAxisType yaxistype = ChartAxisType.NumericY;

            if (xtype == typeof(DateTime))
            {
                xaxistype = ChartAxisType.CategoryDateTimeX;
            }

            var x = new ChartAxisViewModel
            {
                AxisType        = xaxistype,
                Name            = LabelMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = LabelMemberPath,
                LabelTemplate   = "{" + LabelMemberPath + "}",
                AxisLocation    = AxisLocation.OutsideBottom,
            };
            var y = new ChartAxisViewModel
            {
                AxisType        = yaxistype,
                Name            = ValueMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = ValueMemberPath,
                AxisLocation    = AxisLocation.OutsideLeft
            };

            XAxis = x;
            YAxis = y;
        }
コード例 #3
0
        public SCChart SetAxisTitle(ChartAxisType axisType, string axisName, string text, AxisTitleOptions options = null)
        {
            options ??= new AxisTitleOptions();
            options.SetupXtraChartAxisTitle(this, axisType, axisName, text);

            return(this);
        }
コード例 #4
0
        private static void AssertChartViewModel <T>(ChartType chartType, ChartAxisType xAxisType, ChartAxisType yAxisType, List <ChartPoint> expectedChartPoints, ChartPointsAssertionDelegate pointsAssertionMethod)
            where T : Series
        {
            // Init
            var chartAlertProperty = new ChartAlertProperty(
                "propertyName",
                "displayName",
                1,
                chartType,
                xAxisType,
                yAxisType,
                expectedChartPoints);

            // Act
            var chartPropertyControlViewModel = new ChartPropertyControlViewModel(chartAlertProperty);

            // Assert
            Assert.AreEqual("displayName", chartPropertyControlViewModel.Title, "Unexpected chart title");

            Assert.IsNotNull(chartPropertyControlViewModel, "View model is expected to be defined");
            Assert.IsNotNull(chartPropertyControlViewModel.SeriesCollection[0], "Series is expected to be defined");

            T series = chartPropertyControlViewModel.SeriesCollection[0] as T;

            Assert.IsNotNull(series, $"Series is from type {chartPropertyControlViewModel.SeriesCollection[0].GetType()}, but expected to be from type {typeof(T)}");

            List <LiveCharts.ChartPoint> actualDataPoints = series.ChartPoints.ToList();

            pointsAssertionMethod(expectedChartPoints, actualDataPoints);

            FormatterAssertMethod(chartPropertyControlViewModel, xAxisType, yAxisType, expectedChartPoints);
        }
コード例 #5
0
        public SCChart AddStrip(ChartAxisType axisType, string axisName, StripOptions options = null)
        {
            options ??= new StripOptions();
            options.SetupXtraChartStrip(this, axisType, axisName);

            return(this);
        }
コード例 #6
0
        public SCChart AddAxisCustomLabel(ChartAxisType axisType, string axisName, string name, object value,
                                          AxisCustomLabelOptions options = null)
        {
            options ??= new AxisCustomLabelOptions();
            options.SetupXtraChartCustomLabel(this, axisType, axisName, name, value);

            return(this);
        }
コード例 #7
0
        public SCChart AddConstantLine(ChartAxisType axisType,
                                       string axisName, string name, object value, ConstantLineOptions options = null)
        {
            options ??= new ConstantLineOptions();
            options.SetupXtraChartConstantLine(this, axisType, axisName, name, value);

            return(this);
        }
コード例 #8
0
        internal static AxisBase GetPrimaryAxis(Diagram diagram, ChartAxisType axisType)
        {
            switch (diagram)
            {
            case XYDiagram xyDiagram:
                switch (axisType)
                {
                case ChartAxisType.X:
                    return(xyDiagram.AxisX);

                case ChartAxisType.Y:
                    return(xyDiagram.AxisY);
                }
                break;

            case SwiftPlotDiagram swiftPlotDiagram:
                switch (axisType)
                {
                case ChartAxisType.X:
                    return(swiftPlotDiagram.AxisX);

                case ChartAxisType.Y:
                    return(swiftPlotDiagram.AxisY);
                }
                break;

            case XYDiagram3D xyDiagram3D:
                switch (axisType)
                {
                case ChartAxisType.X:
                    return(xyDiagram3D.AxisX);

                case ChartAxisType.Y:
                    return(xyDiagram3D.AxisY);
                }
                break;

            case RadarDiagram radarDiagram:
                switch (axisType)
                {
                case ChartAxisType.X:
                    return(radarDiagram.AxisX);

                case ChartAxisType.Y:
                    return(radarDiagram.AxisY);
                }
                break;

            case SimpleDiagram _:
                throw new Exception("Pie chart does not support axes.");

            case SimpleDiagram3D _:
                throw new Exception("Pie chart does not support axes.");
            }

            throw new Exception("Current chart does not support axes.");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AlertPresentationChartAttribute"/> class.
 /// </summary>
 /// <param name="displayName">The display name to use when presenting the property's value.</param>
 /// <param name="chartType">The type of the chart</param>
 /// <param name="xAxistype">The type of the X axis</param>
 /// <param name="yAxisType">The type of the Y axis</param>
 public AlertPresentationChartAttribute(
     string displayName,
     ChartType chartType,
     ChartAxisType xAxistype,
     ChartAxisType yAxisType)
     : base(displayName)
 {
     this.ChartType = chartType;
     this.XAxisType = xAxistype;
     this.YAxisType = yAxisType;
 }
コード例 #10
0
 /// <summary>
 /// Create an axis, default is range 0 - 100 evenly spaced. You can create multiple axes of the same ChartAxisType.
 /// </summary>
 /// <param name="axisType">Axis position</param>
 /// <param name="labels">These labels will be added to the axis without position information</param>
 public ChartAxis(ChartAxisType axisType, string[] labels)
 {
     this.axisType = axisType;
     if (labels != null)
     {
         foreach (string label in labels)
         {
             this.axisLabels.Add(new ChartAxisLabel(label, -1));
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartPropertyAttribute"/> class.
 /// </summary>
 /// <param name="displayName">The display name to use when presenting the property's value.</param>
 /// <param name="chartType">The type of the chart</param>
 /// <param name="xAxisType">The type of the X axis</param>
 /// <param name="yAxisType">The type of the Y axis</param>
 public ChartPropertyAttribute(
     string displayName,
     ChartType chartType,
     ChartAxisType xAxisType,
     ChartAxisType yAxisType)
     : base(displayName)
 {
     this.ChartType = chartType;
     this.XAxisType = xAxisType;
     this.YAxisType = yAxisType;
 }
コード例 #12
0
 public ChartAxisValueMemberDoesNotExistException(ChartSeriesType seriesType, ChartAxisType axisType, string valueMemberPath)
     : base(String.Format(
                "The value member [{0}] for axis type [{2}] series type [{1}] does not exist in the data",
                valueMemberPath,
                seriesType,
                axisType
                ))
 {
     SeriesType      = seriesType;
     AxisType        = axisType;
     ValueMemberPath = valueMemberPath;
 }
コード例 #13
0
 public ChartAxisValueMemberDoesNotExistException(ChartSeriesType seriesType, ChartAxisType axisType, string valueMemberPath)
     : base(String.Format(
         "The value member [{0}] for axis type [{2}] series type [{1}] does not exist in the data",
         valueMemberPath,
         seriesType,
         axisType
     ))
 {
     SeriesType = seriesType;
     AxisType = axisType;
     ValueMemberPath = valueMemberPath;
 }
コード例 #14
0
        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);
        }
コード例 #15
0
 public InvalidChartAxisValueMemberException(ChartSeriesType seriesType, ChartAxisType axisType, SolidPSObjectBase data, string valueMemberPath)
     : base(String.Format(
                "The value member [{0}] of data type [{3}] is invalid for axis type [{2}] series type [{1}]",
                valueMemberPath,
                seriesType,
                axisType,
                null == data ? "null" : data.GetPropTypeName(valueMemberPath)
                ))
 {
     SeriesType      = seriesType;
     AxisType        = axisType;
     Data            = data;
     ValueMemberPath = valueMemberPath;
 }
コード例 #16
0
        internal static AxisBase GetSecondaryAxis(Diagram diagram, ChartAxisType axisType, string name)
        {
            switch (diagram)
            {
            case XYDiagram xyDiagram:
                switch (axisType)
                {
                case ChartAxisType.X:
                    var resultX = new SecondaryAxisX(name);
                    xyDiagram.SecondaryAxesX.Add(resultX);
                    return(resultX);

                case ChartAxisType.Y:
                    var resultY = new SecondaryAxisY(name);
                    xyDiagram.SecondaryAxesY.Add(resultY);
                    return(resultY);
                }
                break;

            case SwiftPlotDiagram swiftPlotDiagram:
                switch (axisType)
                {
                case ChartAxisType.X:
                    var resultX = new SwiftPlotDiagramSecondaryAxisX(name);
                    swiftPlotDiagram.SecondaryAxesX.Add(resultX);
                    return(resultX);

                case ChartAxisType.Y:
                    var resultY = new SwiftPlotDiagramSecondaryAxisY(name);
                    swiftPlotDiagram.SecondaryAxesY.Add(resultY);
                    return(resultY);
                }
                break;

            case XYDiagram3D _:
                throw new Exception("3D charts do not support secondary axes.");

            case RadarDiagram _:
                throw new Exception("Radar chart does not support secondary axes.");

            case SimpleDiagram _:
                throw new Exception("Pie chart does not support axes.");

            case SimpleDiagram3D _:
                throw new Exception("Pie chart does not support axes.");
            }

            throw new Exception("Current chart does not support axes.");
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        private static void FormatterAssertMethod(ChartPropertyControlViewModel chartPropertyControlViewModel, ChartAxisType xAxisType, ChartAxisType yAxisType, List <ChartPoint> expectedChartPoints)
        {
            // Assert Y axis formatter
            for (var i = 0; i < expectedChartPoints.Count(); i++)
            {
                if (yAxisType == ChartAxisType.Percentage)
                {
                    Assert.AreEqual(
                        chartPropertyControlViewModel.YAxisFormatter((double)expectedChartPoints[i].Y),
                        PercentageYFormatter((double)expectedChartPoints[i].Y));
                }
                else
                {
                    Assert.AreEqual(
                        chartPropertyControlViewModel.YAxisFormatter((double)expectedChartPoints[i].Y),
                        NumberFormatter((double)expectedChartPoints[i].Y));
                }
            }

            // Assert X axis formatter
            for (var i = 0; i < expectedChartPoints.Count(); i++)
            {
                if (xAxisType == ChartAxisType.Number)
                {
                    Assert.AreEqual(
                        chartPropertyControlViewModel.XAxisFormatter((double)expectedChartPoints[i].X),
                        NumberFormatter((double)expectedChartPoints[i].X));
                }
                else
                {
                    double xAxisFactor = expectedChartPoints.Count > 1 ?
                                         Now.AddDays(1).Ticks - Now.Ticks :
                                         Now.Ticks;
                    dateXFormatter = value => new DateTime((long)(value * xAxisFactor)).ToString(CultureInfo.InvariantCulture);

                    Assert.AreEqual(
                        chartPropertyControlViewModel.XAxisFormatter((double)((DateTime)expectedChartPoints[i].X).Ticks / xAxisFactor),
                        dateXFormatter((double)((DateTime)expectedChartPoints[i].X).Ticks / xAxisFactor));
                }
            }
        }
コード例 #19
0
 public SCChart AddAxisCustomLabel(ChartAxisType axisType, string name, object value,
                                   AxisCustomLabelOptions options = null) =>
 AddAxisCustomLabel(axisType, null, name, value, options);
コード例 #20
0
 public InvalidChartAxisValueMemberException(ChartSeriesType seriesType, ChartAxisType axisType, SolidPSObjectBase data, string valueMemberPath)
     : base(String.Format(
         "The value member [{0}] of data type [{3}] is invalid for axis type [{2}] series type [{1}]", 
         valueMemberPath, 
         seriesType, 
         axisType, 
         null == data ? "null" : data.GetPropTypeName( valueMemberPath )
     ))
 {
     SeriesType = seriesType;
     AxisType = axisType;
     Data = data;
     ValueMemberPath = valueMemberPath;
 }
コード例 #21
0
        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);
        }
コード例 #22
0
 public InvalidChartAxisTypeException(ChartSeriesType seriesType, ChartAxisType axisType)
     : base(String.Format("Invalid axis type [{0}] for series type [{1}]", axisType, seriesType))
 {
     SeriesType = seriesType;
     AxisType = axisType;
 }
コード例 #23
0
        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);
        }
コード例 #24
0
 public SCChart AddConstantLine(ChartAxisType axisType,
                                string name, object value, ConstantLineOptions options = null) =>
 AddConstantLine(axisType, null, name, value, options);
コード例 #25
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="r">rectangular graphing area</param>
 /// <param name="g">eto graphics object that authors drawings</param>
 /// <param name="t">chart axis</param>
 public ChartAxis(RectangleF r, Graphics g, ChartAxisType t = ChartAxisType.Both)
 {
     AxisType = t;
     Author   = g;
     Canvas   = r;
 }
コード例 #26
0
        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;
            }
        }
コード例 #27
0
 public SCChart AddScaleBreak(ChartAxisType axisType, string name,
                              object edge1, object edge2) =>
 AddScaleBreak(axisType, null, name, edge1, edge2);
コード例 #28
0
 /// <summary>
 /// Create an axis, default is range 0 - 100 evenly spaced. You can create multiple axes of the same ChartAxisType.
 /// </summary>
 /// <param name="axisType">Axis position</param>
 public ChartAxis(ChartAxisType axisType)
     : this(axisType, null)
 {
 }
コード例 #29
0
ファイル: ChartAxis.cs プロジェクト: JakePickle/CompSigh
        /// <summary>
        /// Create an axis, default is range 0 - 100 evenly spaced. You can create multiple axes of the same ChartAxisType.
        /// </summary>
        /// <param name="axisType">Axis position</param>
        /// <param name="labels">These labels will be added to the axis without position information</param>
        public ChartAxis(ChartAxisType axisType, string[] labels)
        {
            this.axisType = axisType;

            if (labels != null)
            {
                foreach (string label in labels)
                {
                    this.axisLabels.Add(new ChartAxisLabel(label, -1));
                }
            }
        }
コード例 #30
0
ファイル: ChartAxis.cs プロジェクト: JakePickle/CompSigh
 /// <summary>
 /// Create an axis, default is range 0 - 100 evenly spaced. You can create multiple axes of the same ChartAxisType.
 /// </summary>
 /// <param name="axisType">Axis position</param>
 public ChartAxis(ChartAxisType axisType) : this(axisType, null)
 {
 }
コード例 #31
0
 public InvalidChartAxisTypeException(ChartSeriesType seriesType, ChartAxisType axisType)
     : base(String.Format("Invalid axis type [{0}] for series type [{1}]", axisType, seriesType))
 {
     SeriesType = seriesType;
     AxisType   = axisType;
 }
コード例 #32
0
        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;
        }
コード例 #33
0
        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);
        }