Back to Devexpress

RangeBarSeriesLabel Class

corelibraries-devexpress-dot-xtracharts-97e7d449.md

latest10.2 KB
Original Source

RangeBarSeriesLabel Class

Defines label settings for Side-by-Side Range Bar, Overlapped Range Bar and Gantt series.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public class RangeBarSeriesLabel :
    SeriesLabelBase
vb
Public Class RangeBarSeriesLabel
    Inherits SeriesLabelBase

Remarks

The RangeBarSeriesLabel class provides label functionality for series of the range bar and gantt series view types (namely, side-by-side range bars, overlapped range bars, side-by-side gantt and overlapped gantt).

In addition to the common label settings inherited from the base SeriesLabelBase class, the RangeBarSeriesLabel class declares a range bars specific setting that allows you to specify the labels kind (RangeBarSeriesLabel.Kind), labels position (RangeBarSeriesLabel.Position) and indent from range bars (RangeBarSeriesLabel.Indent).

An instance of the RangeBarSeriesLabel class can be obtained via the SeriesBase.Label property of a series whose view type is either SideBySideRangeBarSeriesView, OverlappedRangeBarSeriesView, SideBySideGanttSeriesView or OverlappedGanttSeriesView.

Example

The following example demonstrates how to create a ChartControl with two series of the SideBySideRangeBarSeriesView type, and add this chart to a form at runtime. Before proceeding with this example, first create a Windows Forms Application in Visual Studio, and include all necessary assemblies to the References list of your project.

Then, add the following code to the Form.Load event handler.

csharp
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
namespace RangeBarChart {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
            // Create a new chart.
            ChartControl rangeBarChart = new ChartControl();

            // Create two range bar series.
            Series series1 = new Series("Series 1", ViewType.SideBySideRangeBar);
            Series series2 = new Series("Series 2", ViewType.SideBySideRangeBar);

            // Add points to them.
            series1.Points.Add(new SeriesPoint("A", 10, 15));
            series1.Points.Add(new SeriesPoint("B", 4, 7));
            series1.Points.Add(new SeriesPoint("C", 3, 13));
            series1.Points.Add(new SeriesPoint("D", 2, 11));
            series1.Points.Add(new SeriesPoint("E", 1, 8));

            series2.Points.Add(new SeriesPoint("A", 9, 13));
            series2.Points.Add(new SeriesPoint("B", 5, 10));
            series2.Points.Add(new SeriesPoint("C", 1, 9));
            series2.Points.Add(new SeriesPoint("D", 3, 7));
            series2.Points.Add(new SeriesPoint("E", 2, 10));

            // Add both series to the chart.
            rangeBarChart.Series.AddRange(new Series[] { series1, series2 });

            // Specify series label options.
            series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            RangeBarSeriesLabel seriesLabel = (RangeBarSeriesLabel)series2.Label;
            seriesLabel.Position = RangeBarLabelPosition.Outside;
            seriesLabel.Kind = RangeBarLabelKind.TwoLabels;
            seriesLabel.Indent = 10;

            // Access the view-type-specific options of the series.
            SideBySideRangeBarSeriesView myView1 = (SideBySideRangeBarSeriesView)series1.View;
            myView1.MaxValueMarkerVisibility = DevExpress.Utils.DefaultBoolean.True;
            myView1.MinValueMarkerVisibility = DevExpress.Utils.DefaultBoolean.True;
            myView1.MinValueMarker.Kind = MarkerKind.Circle;
            myView1.MaxValueMarker.Kind = MarkerKind.Star;
            myView1.MaxValueMarker.StarPointCount = 5;
            ((SideBySideRangeBarSeriesView)series2.View).BarWidth = 0.4;

            // Access the type-specific options of the diagram.
            ((XYDiagram)rangeBarChart.Diagram).EnableAxisXZooming = true;

            // Hide the legend (if necessary).
            rangeBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;

            // Add a title to the chart (if necessary).
            rangeBarChart.Titles.Add(new ChartTitle());
            rangeBarChart.Titles[0].Text = "A Side-by-Side Range Bar Chart";
            rangeBarChart.Titles[0].WordWrap = true;

            // Add the chart to the form.
            rangeBarChart.Dock = DockStyle.Fill;
            this.Controls.Add(rangeBarChart);
        }
    }
}
vb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraEditors
Imports System
Imports System.Windows.Forms

Namespace RangeBarChart
    Public Partial Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Create a new chart.
            Dim rangeBarChart As ChartControl = New ChartControl()

            ' Create two range bar series.
            Dim series1 As Series = New Series("Series 1", ViewType.SideBySideRangeBar)
            Dim series2 As Series = New Series("Series 2", ViewType.SideBySideRangeBar)

            ' Add points to them.
            series1.Points.Add(New SeriesPoint("A", 10, 15))
            series1.Points.Add(New SeriesPoint("B", 4, 7))
            series1.Points.Add(New SeriesPoint("C", 3, 13))
            series1.Points.Add(New SeriesPoint("D", 2, 11))
            series1.Points.Add(New SeriesPoint("E", 1, 8))

            series2.Points.Add(New SeriesPoint("A", 9, 13))
            series2.Points.Add(New SeriesPoint("B", 5, 10))
            series2.Points.Add(New SeriesPoint("C", 1, 9))
            series2.Points.Add(New SeriesPoint("D", 3, 7))
            series2.Points.Add(New SeriesPoint("E", 2, 10))

            ' Add both series to the chart.
            rangeBarChart.Series.AddRange(New Series() {series1, series2})

            ' Specify series label options.
            series2.LabelsVisibility = DevExpress.Utils.DefaultBoolean.[True]
            Dim seriesLabel As RangeBarSeriesLabel = CType(series2.Label, RangeBarSeriesLabel)
            seriesLabel.Position = RangeBarLabelPosition.Outside
            seriesLabel.Kind = RangeBarLabelKind.TwoLabels
            seriesLabel.Indent = 10

            ' Access the view-type-specific options of the series.
            Dim myView1 As SideBySideRangeBarSeriesView = CType(series1.View, SideBySideRangeBarSeriesView)
            myView1.MaxValueMarkerVisibility = DevExpress.Utils.DefaultBoolean.[True]
            myView1.MinValueMarkerVisibility = DevExpress.Utils.DefaultBoolean.[True]
            myView1.MinValueMarker.Kind = MarkerKind.Circle
            myView1.MaxValueMarker.Kind = MarkerKind.Star
            myView1.MaxValueMarker.StarPointCount = 5
            (CType(series2.View, SideBySideRangeBarSeriesView)).BarWidth = 0.4

            ' Access the type-specific options of the diagram.
            (CType(rangeBarChart.Diagram, XYDiagram)).EnableAxisXZooming = True
            rangeBarChart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.[True]

            ' Add a title to the chart (if necessary).
            rangeBarChart.Titles.Add(New ChartTitle())
            rangeBarChart.Titles(0).Text = "A Side-by-Side Range Bar Chart"
            rangeBarChart.Titles(0).WordWrap = True

            ' Add the chart to the form.
            rangeBarChart.Dock = DockStyle.Fill
            Me.Controls.Add(rangeBarChart)
        End Sub
    End Class
End Namespace

Implements

IXtraSerializable

Inheritance

Object ChartElement SeriesLabelBase RangeBarSeriesLabel

See Also

RangeBarSeriesLabel Members

SeriesLabelBase

DevExpress.XtraCharts Namespace