Skip to main content

FontOptions

Namespace: Wisej.Web.Ext.ChartJS4.Models

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

Represents the font options used to render text elements of the chart (Chart.js font object with family, size, style, weight and lineHeight).

public class FontOptions : OptionsBase

Used by several option classes, such as Font, Font, Font and Font. Properties left at null are not serialized, letting Chart.js apply its global font defaults.

Example:

var chart = new ChartJS4();
var font = chart.ChartOptions.Scales.X.Ticks.Font;
font.Family = "Segoe UI";
font.Size = 14;
font.Weight = "bold";

Constructors​

Instance member FontOptions()​

Initializes a new instance of FontOptions.

Properties​

Instance member Family​

String: Returns or sets the font family (Chart.js font.family).

Value: A CSS font-family string, e.g. "Arial" or "'Helvetica Neue', Helvetica, sans-serif", or null (default) to use the Chart.js default font family.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Ticks.Font.Family = "Verdana, sans-serif";

Instance member LineHeight​

Object: Returns or sets the height of an individual line of text (Chart.js font.lineHeight).

Value: A number used as a multiplier of the font size (e.g. 1.2), a CSS length string (e.g. "20px" or "150%"), or null (default) to use the Chart.js default (1.2).

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Title.Font.LineHeight = 1.5;

Instance member Size​

Int32: Returns or sets the font size, in pixels (Chart.js font.size). (Default: 12)

Value: The font size in pixels. The default is 12.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Title.Font.Size = 16;

Instance member Style​

String: Returns or sets the font style (Chart.js font.style).

Value: One of "normal", "italic", "oblique", "initial" or "inherit", or null (default) to use the Chart.js default ("normal").

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Title.Font.Style = "italic";

Instance member Weight​

Object: Returns or sets the font weight (Chart.js font.weight).

Value: A string such as "normal", "bold", "lighter" or "bolder", a numeric weight (e.g. 600), or null (default) to use the Chart.js default.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Ticks.Font.Weight = "bold";
chart.ChartOptions.Scales.Y.Ticks.Font.Weight = 600;

Methods​

Instance member ResetFamily()​

Resets the Family property to its default value (null).

Example:

var font = new FontOptions { Family = "Arial" };
font.ResetFamily();

Instance member ResetLineHeight()​

Resets the LineHeight property to its default value (null).

Example:

var font = new FontOptions { LineHeight = 1.5 };
font.ResetLineHeight();

Instance member ResetSize()​

Resets the Size property to its default value (12).

Example:

var font = new FontOptions { Size = 20 };
font.ResetSize();

Instance member ResetStyle()​

Resets the Style property to its default value (null).

Example:

var font = new FontOptions { Style = "italic" };
font.ResetStyle();

Instance member ResetWeight()​

Resets the Weight property to its default value (null).

Example:

var font = new FontOptions { Weight = "bold" };
font.ResetWeight();

Instance member ShouldSerializeFamily()​

Determines whether the Family property should be serialized by the designer.

Returns: Boolean. true if Family is not null; otherwise, false.

Used by the Visual Studio designer together with ResetFamily.

Example:

var font = new FontOptions();
if (font.ShouldSerializeFamily())
font.ResetFamily();

Instance member ShouldSerializeLineHeight()​

Determines whether the LineHeight property should be serialized by the designer.

Returns: Boolean. true if LineHeight is not null; otherwise, false.

Used by the Visual Studio designer together with ResetLineHeight.

Example:

var font = new FontOptions();
if (font.ShouldSerializeLineHeight())
font.ResetLineHeight();

Instance member ShouldSerializeSize()​

Determines whether the Size property should be serialized by the designer.

Returns: Boolean. true if Size is not 12; otherwise, false.

Used by the Visual Studio designer together with ResetSize.

Example:

var font = new FontOptions();
if (font.ShouldSerializeSize())
font.ResetSize();

Instance member ShouldSerializeStyle()​

Determines whether the Style property should be serialized by the designer.

Returns: Boolean. true if Style is not null; otherwise, false.

Used by the Visual Studio designer together with ResetStyle.

Example:

var font = new FontOptions();
if (font.ShouldSerializeStyle())
font.ResetStyle();

Instance member ShouldSerializeWeight()​

Determines whether the Weight property should be serialized by the designer.

Returns: Boolean. true if Weight is not null; otherwise, false.

Used by the Visual Studio designer together with ResetWeight.

Example:

var font = new FontOptions();
if (font.ShouldSerializeWeight())
font.ResetWeight();