Skip to main content
Version: 4.2

Sparkline

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

Displays a compact line, area, or bar chart without axes.

public class Sparkline : Control

Samples use absolute units. The newest MaxPoints samples are retained. Click is inherited from Control.

Example:

var chart = new Sparkline { ChartType = SparklineChartType.Area, MaxPoints = 60, ShowLastPoint = true };
chart.Values = new double[] { 12, 18, 14, 25, 20 };
this.Controls.Add(chart);
chart.Push(28);

Constructors​

Instance member Sparkline()​

Initializes an empty, nonfocusable sparkline with a 30-sample rolling window.

Properties​

Instance member ChartType​

SparklineChartType: Gets or sets the chart mode. The default is Line. (Default: Line)

Protected member DefaultSize​

Size: Gets the default chart size of 140 by 48 pixels.

Instance member Focusable​

Boolean: Gets or sets whether the chart can receive focus. The default is false. (Default: False)

Instance member LineColor​

Color: Gets or sets a custom chart color. Color.Empty uses the theme's Tone color. (Default: Color [Empty])

Instance member LineWidth​

Int32: Gets or sets line thickness in pixels. The default is 2. (Default: 2)

Throws:

Instance member Maximum​

Nullable<Double>: Gets or sets the upper scale bound, or null for automatic scaling. (Default: null)

Throws:

Instance member MaxPoints​

Int32: Gets or sets the positive rolling-window capacity. The default is 30. (Default: 30)

Reducing capacity immediately discards the oldest excess samples.

Throws:

Instance member Minimum​

Nullable<Double>: Gets or sets the lower scale bound, or null for automatic scaling. (Default: null)

Throws:

Example:

chart.Minimum = 0;
chart.Maximum = 100;
chart.Values = new double[] { -10, 40, 120 }; // Drawing is clipped; sample values are retained.
chart.Minimum = null; // Restores an automatic lower bound.

Instance member NoSamplesText​

String: Gets or sets the localized override for the "No samples." text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member SamplesSummaryText​

String: Gets or sets the localized override for the "{0} samples. Latest value: {1}." text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the sample count and {1} is the latest value. Used for the CLDR other category of the current UI culture. Literal braces can be written as {{ and }}.

Instance member SampleSummaryText​

String: Gets or sets the localized override for the "{0} sample. Latest value: {1}." text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the sample count and {1} is the latest value. Used for the CLDR one category of the current UI culture. Literal braces can be written as {{ and }}.

Instance member ShowLastPoint​

Boolean: Gets or sets whether the last line or area sample has a marker. The default is false. (Default: False)

A single sample always has a marker. Bar charts always accent the last bar.

Instance member Smooth​

Boolean: Gets or sets whether line and area paths use smooth curves. The default is false. (Default: False)

Curves remain between neighboring sample values. Bars ignore this property.

Instance member TabStop​

Boolean: Gets or sets tab navigation participation. The default is false. (Default: False)

Instance member Threshold​

Nullable<Double>: Gets or sets the absolute level above which a threshold band is drawn, or null to hide it. (Default: null)

Throws:

Example:

chart.Minimum = 0;
chart.Maximum = 100;
chart.Threshold = 75; // Shades values above 75 without changing the scale.
chart.Threshold = null; // Hides the band.

Instance member Tone​

SparklineTone: Gets or sets the semantic color. The default is Primary. (Default: Primary)

LineColor, when nonempty, overrides this color.

Instance member Values​

Double[]: Gets a copy of the samples or replaces them, retaining the newest MaxPoints values.

Null clears the chart. Mutating the source array or returned copy does not affect the control.

Throws:

Example:

chart.Values = new double[] { 10, 20, 15 };
var samples = chart.Values;
samples[0] = 12;
chart.Values = samples; // Assign the edited copy to update the chart.

Methods​

Instance member Clear()​

Removes all samples while preserving scale, style, and rolling-window settings.

Protected member OnPointHover(e)​

Raises PointHover with a snapshot of the hovered sample.

ParameterTypeDescription
eSparklinePointEventArgsSample index and value.

Protected member OnWebEvent(e)​

Dispatches client events to their processing methods.

ParameterTypeDescription
eWisejEventArgsClient event and payload.

Protected member OnWebRender(config)​

Serializes chart state and wires PointHover, including for derived controls without attached handlers.

ParameterTypeDescription
configObjectClient configuration.

Instance member Push(value)​

Appends a sample, discarding the oldest sample when the window is full.

ParameterTypeDescription
valueDoubleFinite absolute sample value.

Throws:

Example:

chart.MaxPoints = 3;
chart.Values = new double[] { 10, 20, 30 };
chart.Push(40); // Values now contains 20, 30, 40.

Instance member ResetValues()​

Clears the samples, restoring the default Values property.

Events​

Instance member PointHover​

EventHandler<SparklinePointEventArgs> Occurs when the pointer enters a different sample's horizontal region.

Stale notifications received after the sample window changes are ignored. Notifications also reach overrides of OnPointHover when no event handler is attached.

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IBindableComponentBindable components implement this interface.
IDropTargetControls that support drag & drop operations implement this interface.
IWisejComponentAll wisej components implement this interface.
IWisejControlAll wisej controls derived from the Control class must implement this interface.
IWisejSerializableAllows an object to serialize itself.