DecimationOptions
Namespace: Wisej.Web.Ext.ChartJS4.Models
Assembly: Wisej.Web.Ext.ChartJS4 (4.1.0.0)
Represents the options of the Chart.js decimation plugin (options.plugins.decimation), used to downsample large line chart datasets for faster rendering.
- C#
- VB.NET
public class DecimationOptions : OptionsBase
Public Class DecimationOptions
Inherits OptionsBase
According to Chart.js, decimation only applies to line charts with a linear or time x axis, datasets whose indexAxis is "x", and data that does not need parsing (parsing: false). An instance is available through Decimation.
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.Enabled = true;
decimation.Algorithm = "lttb";
decimation.Samples = 500;
Constructors
DecimationOptions()
Initializes a new instance of DecimationOptions.
Properties
Algorithm
String: Returns or sets the decimation algorithm (Chart.js option algorithm).
Value: "min-max" or "lttb", or null (default) to use the Chart.js default ("min-max").
"min-max" preserves peaks by keeping up to 4 points per pixel; "lttb" (Largest Triangle Three Bucket) reduces the data to the number of points specified by Samples. Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.Enabled = true;
decimation.Algorithm = "min-max";
Enabled
Boolean: Returns or sets whether the decimation plugin is enabled (Chart.js option enabled). (Default: False)
Value: true to enable decimation; otherwise false. The default is false.
Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.Enabled = true;
Samples
Int32: Returns or sets the number of samples to keep after decimation when Algorithm is "lttb" (Chart.js option samples). (Default: 0)
Value: The number of points to keep. The default is 0, which is not serialized and lets Chart.js use the width of the chart area in pixels.
Changing this property refreshes the chart.
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.Enabled = true;
decimation.Algorithm = "lttb";
decimation.Samples = 250;
Methods
ResetAlgorithm()
Resets the Algorithm property to its default value.
Sets Algorithm to null (Chart.js default). This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.ResetAlgorithm();
ResetEnabled()
Resets the Enabled property to its default value.
Sets Enabled to false. This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.ResetEnabled();
ResetSamples()
Resets the Samples property to its default value.
Sets Samples to 0 (Chart.js default). This method is used by the Visual Studio designer and the property grid ("Reset" command).
Example:
var chart = new ChartJS4();
var decimation = chart.ChartOptions.Plugins.Decimation;
decimation.ResetSamples();
ShouldSerializeAlgorithm()
Returns whether the Algorithm property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if Algorithm 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 (decimation.ShouldSerializeAlgorithm())
decimation.ResetAlgorithm();
ShouldSerializeEnabled()
Returns whether the Enabled property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if Enabled is true; 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 (decimation.ShouldSerializeEnabled())
decimation.ResetEnabled();
ShouldSerializeSamples()
Returns whether the Samples property has been changed from its default value and should be serialized by the designer.
Returns: Boolean. true if Samples 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 (decimation.ShouldSerializeSamples())
decimation.ResetSamples();