BarElementOptions
Namespace: Wisej.Web.Ext.ChartJS4.Models
Assembly: Wisej.Web.Ext.ChartJS4 (4.1.0.0)
Represents the default styling options of the bar elements used by bar charts (Chart.js options.elements.bar).
- C#
- VB.NET
public class BarElementOptions : OptionsBase
Public Class BarElementOptions
Inherits OptionsBase
An instance is available through Bar. These values apply to all bar datasets unless overridden by the dataset options.
Example:
var chart = new ChartJS4();
var bar = new BarElementOptions();
bar.BorderWidth = 1;
bar.BorderRadius = 6;
chart.ChartOptions.Elements = new ElementsOptions { Bar = bar };
Constructors
BarElementOptions()
Initializes a new instance of BarElementOptions.
Properties
BackgroundColor
Object: Returns or sets the default fill color of the bars (Chart.js option backgroundColor).
Value: A Color, a CSS color string, or an array of colors. The default is null, which uses the Chart.js default color.
Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var bar = new BarElementOptions();
bar.BackgroundColor = "rgba(54, 162, 235, 0.5)";
chart.ChartOptions.Elements = new ElementsOptions { Bar = bar };
BorderRadius
Int32: Returns or sets the default corner radius, in pixels, of the bars (Chart.js option borderRadius).
Value: The corner radius in pixels. The default is 0 (square corners).
Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var bar = new BarElementOptions();
bar.BorderRadius = 8;
chart.ChartOptions.Elements = new ElementsOptions { Bar = bar };
BorderWidth
Int32: Returns or sets the default border width, in pixels, of the bars (Chart.js option borderWidth). (Default: 0)
Value: The border width in pixels. The default is 0 (no border).
Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var bar = new BarElementOptions();
bar.BorderWidth = 2;
chart.ChartOptions.Elements = new ElementsOptions { Bar = bar };
Methods
ResetBackgroundColor()
Resets the BackgroundColor property to its default value.
Sets BackgroundColor to null. This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var bar = new BarElementOptions();
bar.ResetBackgroundColor();
ResetBorderRadius()
Resets the BorderRadius property to its default value.
Sets BorderRadius to 0. This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var bar = new BarElementOptions();
bar.ResetBorderRadius();
ResetBorderWidth()
Resets the BorderWidth property to its default value.
Sets BorderWidth to 0. This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var bar = new BarElementOptions();
bar.ResetBorderWidth();
ShouldSerializeBackgroundColor()
Returns whether the BackgroundColor property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if BackgroundColor is not null; otherwise false.
This method is used by the Visual Studio designer and the property grid to determine whether the property value is persisted in the generated code.
Example:
if (bar.ShouldSerializeBackgroundColor())
bar.ResetBackgroundColor();
ShouldSerializeBorderRadius()
Returns whether the BorderRadius property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if BorderRadius is not 0; otherwise false.
This method is used by the Visual Studio designer and the property grid to determine whether the property value is persisted in the generated code.
Example:
if (bar.ShouldSerializeBorderRadius())
bar.ResetBorderRadius();
ShouldSerializeBorderWidth()
Returns whether the BorderWidth property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if BorderWidth is not 0; otherwise false.
This method is used by the Visual Studio designer and the property grid to determine whether the property value is persisted in the generated code.
Example:
if (bar.ShouldSerializeBorderWidth())
bar.ResetBorderWidth();