Back to Devexpress

NumericIntervalOptions.Count Property

corelibraries-devexpress-dot-xtracharts-dot-numericintervaloptions-8fc26ef5.md

latest7.5 KB
Original Source

NumericIntervalOptions.Count Property

Gets or sets the number of intervals when DivisionMode is Count.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public int? Count { get; set; }
vb
Public Property Count As Integer?

Property Value

TypeDescription
Nullable<Int32>

The integer that specifies the number of intervals.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to Count
NumericScaleOptions

.IntervalOptions .Count

|

Example

This example demonstrates how to create a histogram chart with a given number of bins.

csharp
private void Form1_Load(object sender, EventArgs e) {
    // Load data to a chart.
    chartControl1.DataSource = LoadDataTableFromXml("..\\..\\Data\\CityWeather.xml", "CityWeather");
    Series series = new Series();
    series.ArgumentDataMember = "Temperature";
    SideBySideBarSeriesView view = series.View as SideBySideBarSeriesView;
    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
    view.BarWidth = 1;
    chartControl1.Series.Add(series);
    // Configure histogram options.
    XYDiagram diagram = chartControl1.Diagram as XYDiagram;
    NumericScaleOptions scaleOptions = diagram.AxisX.NumericScaleOptions;
    scaleOptions.AggregateFunction = AggregateFunction.Histogram;
    scaleOptions.ScaleMode = ScaleMode.Interval;
    scaleOptions.IntervalOptions.DivisionMode = IntervalDivisionMode.Count;
    scaleOptions.IntervalOptions.Count = 5;
    scaleOptions.IntervalOptions.GridLayoutMode = GridLayoutMode.GridAndLabelShifted;
    diagram.AxisX.Label.TextPattern = "{A:F0}°C";
    diagram.AxisX.GridLines.Visible = true;    
}
static DataTable LoadDataTableFromXml(string fileName, string tableName) {
    DataSet xmlDataSet = new DataSet();
    xmlDataSet.ReadXml(fileName);
    return xmlDataSet.Tables[tableName];
}
vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    ' Load data to a chart.
    chartControl1.DataSource = LoadDataTableFromXml("..\..\Data\CityWeather.xml", "CityWeather")
    Dim series As Series = New Series()
    series.ArgumentDataMember = "Temperature"
    Dim view As SideBySideBarSeriesView = TryCast(series.View, SideBySideBarSeriesView)
    view.Border.Visibility = DevExpress.Utils.DefaultBoolean.[True]
    view.BarWidth = 1
    chartControl1.Series.Add(series)
    ' Configure histogram options.
    Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, XYDiagram)
    Dim scaleOptions As NumericScaleOptions = diagram.AxisX.NumericScaleOptions
    scaleOptions.AggregateFunction = AggregateFunction.Histogram
    scaleOptions.ScaleMode = ScaleMode.Interval
    scaleOptions.IntervalOptions.DivisionMode = IntervalDivisionMode.Count
    scaleOptions.IntervalOptions.Count = 5
    scaleOptions.IntervalOptions.GridLayoutMode = GridLayoutMode.GridAndLabelShifted
    diagram.AxisX.Label.TextPattern = "{A:F0}°C"
    diagram.AxisX.GridLines.Visible = True
End Sub

Private Shared Function LoadDataTableFromXml(ByVal fileName As String, ByVal tableName As String) As DataTable
    Dim xmlDataSet As DataSet = New DataSet()
    xmlDataSet.ReadXml(fileName)
    Return xmlDataSet.Tables(tableName)
End Function

The following API members configure the histogram options:

MemberDescription
ScaleGridOptionsBase.AggregateFunctionGets or sets the value indicating the aggregate function that should be used to relieve data.
ScaleOptionsBase.ScaleModeGets or sets the scale mode for an axis.
NumericScaleOptions.IntervalOptionsStores options for numeric axis when its ScaleMode is Interval.
NumericIntervalOptions.DivisionModeSpecifies how to divide axis scale into intervals.
NumericIntervalOptions.CountGets or sets the number of intervals when DivisionMode is Count.
NumericIntervalOptions.GridLayoutModeGets or sets the value that specifies the alignment of grid lines, major tickmarks and axis labels.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Count property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-charts-plot-xy-series-with-histogram/CS/Form1.cs#L44

csharp
diagram.AxisX.NumericScaleOptions.IntervalOptions.GridLayoutMode = GridLayoutMode.GridShiftedLabelCentered;
diagram.AxisX.NumericScaleOptions.IntervalOptions.Count = BinCount;
diagram.AxisX.NumericScaleOptions.IntervalOptions.DivisionMode = IntervalDivisionMode.Count;

winforms-charts-plot-xy-series-with-histogram/VB/Form1.vb#L71

vb
diagram.AxisX.NumericScaleOptions.IntervalOptions.GridLayoutMode = GridLayoutMode.GridShiftedLabelCentered
diagram.AxisX.NumericScaleOptions.IntervalOptions.Count = BinCount
diagram.AxisX.NumericScaleOptions.IntervalOptions.DivisionMode = IntervalDivisionMode.Count

See Also

NumericIntervalOptions Class

NumericIntervalOptions Members

DevExpress.XtraCharts Namespace