Skip to main content

BarOptions

Namespace: Wisej.Web.Ext.ChartJS3

Assembly: Wisej.Web.Ext.ChartJS3 (4.1.0.0)

Options for the Bar chart.

public class BarOptions : Options

The Options property returns an instance of this class when ChartType is Bar or HorizontalBar.

Example:

this.chartJS31.ChartType = ChartType.Bar;

var options = (BarOptions)this.chartJS31.Options;
options.IndexAxis = "y";
options.Plugins.Legend.Display = false;

Constructors​

Instance member BarOptions()​

Default constructor.

Creates a standalone BarOptions set that is not yet attached to a ChartJS3 control. Assign it to the Options property of a bar chart.

Example:

var options = new BarOptions();
options.Plugins.Title.Text = "Orders by Region";

this.chartJS31.ChartType = ChartType.Bar;
this.chartJS31.Options = options;

Instance member BarOptions(chart, defaults)​

Constructs a new instance of the BarOptions set.

NameTypeDescription
chartChartJS3The ChartJS3 that owns this set of options.
defaultsOptionsDefault options to copy from. Can be null.

When defaults is not null, the properties shared with it (for example Plugins, Scales or IndexAxis) are copied into the new instance, which is how the chart preserves the common settings when ChartType changes. Nested option sets are copied into new instances, other properties are copied only when they have a non-default value. The ChartJS3 control creates this instance automatically when ChartType is Bar or HorizontalBar.

Example:

var options = new BarOptions(this.chartJS31, this.chartJS31.Options);
options.Stacked = true;
options.Scales.xAxes[0].Stacked = true;
options.Scales.yAxes[0].Stacked = true;
this.chartJS31.Options = options;

Properties​

Instance member Stacked​

Boolean: Returns or sets whether the bars stack on top of each other along the y axis. (Default: False)

Value: true to stack the bars; otherwise, false. The default is false.

Serialized as the top level stacked option of the chart. In Chart.js 3 stacking is configured on the axes, use Stacked on the axes in Scales to stack the bars. Changing the value calls Update.

Example:

var options = (BarOptions)this.chartJS31.Options;
options.Stacked = true;
options.Scales.xAxes[0].Stacked = true;
options.Scales.yAxes[0].Stacked = true;