Skip to main content

OptionsBase

Namespace: Wisej.Web.Ext.ChartJS4.Models

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

Base class for Chart.js option groups (e.g. legend, title, scales) that can detect and restore their default state.

public abstract class OptionsBase : ChartModelBase

Default values are determined from a fresh instance of the concrete type with every DefaultValueAttribute applied. Only public, readable, writable properties that are not marked [Browsable(false)] are considered. The designer uses IsDefault in the ShouldSerializeX() methods of the parent options to skip serializing unchanged option groups.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
legend.Position = "bottom";
if (!legend.IsDefault)
legend.Reset();

Properties​

Instance member IsDefault​

Boolean: Returns whether all the options in this group still have their default values.

Value: true if every relevant property equals its default value and every nested OptionsBase is either null or itself default; otherwise false.

Compares the public, readable, writable and browsable properties with the values of a default instance (with the DefaultValueAttribute values applied). The property is excluded from JSON serialization and hidden from the property grid.

Example:

var title = chart.ChartOptions.Plugins.Title;
bool unchanged = title.IsDefault; // true
title.Text = "Sales";
unchanged = title.IsDefault; // false

Methods​

Instance member Reset()​

Sets all properties back to their default values.

Assigns to every public, readable, writable and browsable property the value it has on a default instance (with the DefaultValueAttribute values applied). Nested option-group properties are assigned the value read from that default instance. Derived classes can override this method to reset additional state.

Example:

chart.ChartOptions.Plugins.Legend.Reset();

Inherited By​

NameDescription
AnimationsOptionsAnimation options.
ArcElementOptionsRepresents the default styling options of the arc elements used by pie, doughnut and polar area charts (Chart.js options.elements.arc).
AxisOptionsRepresents the configuration of a chart axis (scale), serialized as a Chart.js scales[id] entry.
AxisTitleOptionsRepresents the options of an axis title, the label displayed along an axis (Chart.js scales[id].title).
BarElementOptionsRepresents the default styling options of the bar elements used by bar charts (Chart.js options.elements.bar).
BorderOptionsRepresents the options of the axis border line, drawn at the edge between the axis and the chart area (Chart.js scales[id].border).
DataLabelsOptionsRepresents the options of the chartjs-plugin-datalabels plugin (Chart.js options.plugins.datalabels), which draws labels next to or on top of the data elements.
DecimationOptionsRepresents the options of the Chart.js decimation plugin (options.plugins.decimation), used to downsample large line chart datasets for faster rendering.
ElementsOptionsRepresents the default styling options of the chart elements (Chart.js options.elements): points, lines, bars and arcs.
FillerOptionsRepresents the options of the Chart.js filler plugin (options.plugins.filler), which fills the area of line and radar datasets that have the fill option set.
FontOptionsRepresents the font options used to render text elements of the chart (Chart.js font object with family, size, style, weight and lineHeight).
GridOptionsRepresents the grid line options of an axis (Chart.js scales[id].grid).
InteractionOptionsRepresents the Chart.js interaction options (options.interaction) that control how hover and tooltip interactions select chart elements.
LayoutOptionsRepresents the chart layout options (Chart.js options.layout).
LegendLabelsOptionsRepresents the configuration of the legend labels (Chart.js options.plugins.legend.labels), which controls the colored boxes and text of each legend item.
LegendOptionsRepresents the configuration of the Chart.js legend plugin (options.plugins.legend), which displays the datasets of the chart and lets the user toggle them.
LegendTitleOptionsRepresents the configuration of the legend title (Chart.js options.plugins.legend.title).
LineElementOptionsRepresents the default styling options of the line elements used by line and radar charts (Chart.js options.elements.line).
PaddingOptionsRepresents padding values, in pixels, for each side of an element (Chart.js padding object with top, right, bottom and left).
PluginsOptionsRepresents the configuration of the built-in Chart.js plugins (Chart.js options.plugins): legend, title, subtitle, tooltip, decimation, filler and the chartjs-plugin-datalabels plugin.
PointElementOptionsRepresents the default styling options of the point elements used by line, radar, scatter and bubble charts (Chart.js options.elements.point).
ScalesOptionsScales options (Chart.js options.scales).
SubtitleOptionsRepresents the configuration of the Chart.js subtitle plugin (options.plugins.subtitle), which draws a second line of text below the chart title.
TickOptionsRepresents the options of the tick labels of an axis (Chart.js scales[id].ticks).
TitleOptionsRepresents the configuration of the Chart.js title plugin (options.plugins.title), which draws a title above (or beside) the chart.
TooltipOptionsRepresents the configuration of the Chart.js tooltip plugin (options.plugins.tooltip), which controls when tooltips are shown, how they are positioned and how they look.
TransitionsOptionsTransitions options (Chart.js options.transitions).