New to Telerik UI for ASP.NET Core? Start a free 30-day trial

Defines the fluent API for configuring the Kendo UI Chart

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

T

Syntax:

C#
public class ChartBuilder<T> : WidgetBuilderBase<Chart<T>, ChartBuilder<T>>, IHtmlContent where T : class

Inheritance: objectHelperResultWidgetBuilderBase<Chart<T>, ChartBuilder<T>>ChartBuilder<T>

Implements: IHtmlContent

Inherited Members WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ToComponent()WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.Expression(string)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.Explorer(ModelExplorer)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.Name(string)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.Deferred(bool)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.HtmlAttributes(object)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ScriptAttributes(object, bool)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.Render()WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ToHtmlString()WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.WriteTo(TextWriter, HtmlEncoder)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ToClientTemplate()WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.AsModule(bool)WidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ComponentWidgetBuilderBase<Chart<T>, ChartBuilder<T>>.ContainerHelperResult.WriteTo(TextWriter, HtmlEncoder)HelperResult.WriteActionobject.GetType()object.MemberwiseClone()object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()...

Constructors

Initializes a new instance of the ChartBuilder<T> class.

C#
public ChartBuilder(Chart<T> component)
Parameters:componentChart<T>

The Chart<T> component

Methods

If set to false the widget will not bind to the data source during initialization. In this case data binding will occur when the change event of the data source is fired. By default the widget will bind to the data source specified in the configuration.

C#
public ChartBuilder<T> AutoBind(bool value)
Parameters:valuebool

The value for AutoBind

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

The default options for all chart axes. Accepts the options supported by categoryAxis, valueAxis, xAxis and yAxis.

C#
public ChartBuilder<T> AxisDefaults(Action<ChartAxisDefaultsSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartAxisDefaultsSettingsBuilder<T>>

The ChartAxisDefaultsSettingsBuilder<T> for the axisdefaults setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Configures the category axis of the Chart.

C#
public ChartBuilder<T> CategoryAxis(Action<ChartCategoryAxisBuilder<T>> configurator)
Parameters:configuratorAction<ChartCategoryAxisBuilder<T>>

The action that configures the category axis options.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.CategoryAxis(axis =&gt; axis
.Categories("2002", "2003", "2004")
.MajorGridLines(lines =&gt; lines.Visible(false))
)
)

The chart area configuration options. Represents the entire visible area of the chart.

C#
public ChartBuilder<T> ChartArea(Action<ChartChartAreaSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartChartAreaSettingsBuilder<T>>

The ChartChartAreaSettingsBuilder<T> for the chartarea setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Defines the DataSource configuration of the Chart.

C#
public ChartBuilder<T> DataSource(Action<ReadOnlyAjaxDataSourceBuilder<T>> configurator)
Parameters:configuratorAction<ReadOnlyAjaxDataSourceBuilder<T>>

The action that configures the DataSource settings.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart&lt;ChartViewModel&gt;()
.Name("chart")
.DataSource(ds =&gt;
{
ds.Ajax().Read(r =&gt; r.Action("SalesData", "Chart"));
})
)

Specifies an external DataSource that will be used by the Chart.

C#
public ChartBuilder<T> DataSource(string dataSourceId)
Parameters:dataSourceIdstring

The Name() option of the external DataSource.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().DataSource&lt;ProductViewModel&gt;()
.Name("dataSource1")
.Ajax(dataSource =&gt; dataSource
.Read(read =&gt; read.Action("Products_Read", "DataSource"))
)
)
@(Html.Kendo().Chart&lt;ProductViewModel&gt;()
.Name("chart")
.DataSource("dataSource1")
.Series(series =&gt;
{
series.Column(model =&gt; model.UnitPrice).Name("Price").CategoryField("ProductName");
})
)

Configures the client-side events.

C#
public ChartBuilder<T> Events(Action<ChartEventBuilder> configurator)
Parameters:configuratorAction<ChartEventBuilder>

The client events action.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("Chart")
.Events(events =&gt; events
.AxisLabelClick("onAxisLabelClick")
)
)

The chart legend configuration options.

C#
public ChartBuilder<T> Legend(Action<ChartLegendSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartLegendSettingsBuilder<T>>

The ChartLegendSettingsBuilder<T> for the legend setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Sets the visibility of the chart's legend.

C#
public ChartBuilder<T> Legend(bool visible)
Parameters:visiblebool

A value indicating whether to show the legend.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.Legend(false)
)

Allows localization of the strings that are used in the widget.

C#
public ChartBuilder<T> Messages(Action<ChartMessagesSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartMessagesSettingsBuilder<T>>

The ChartMessagesSettingsBuilder<T> for the messages setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

When no series data is available, the Chart will display an overlay element that contains a message with the text "No data available". The overlay will be automatically cleared if the series receive data.To disable the "No Data" overlay, set this option to false.

C#
public ChartBuilder<T> NoData(Action<ChartNoDataSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartNoDataSettingsBuilder<T>>

The ChartNoDataSettingsBuilder<T> for the nodata setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

When no series data is available, the Chart will display an overlay element that contains a message with the text "No data available". The overlay will be automatically cleared if the series receive data.To disable the "No Data" overlay, set this option to false.

C#
public ChartBuilder<T> NoData(bool enabled)
Parameters:enabledbool

Enables or disables the nodata option.

Returns:

ChartBuilder<T>

Returns the current instance of ChartNoDataSettingsBuilder<T> .

The default options for all panes.

C#
public ChartBuilder<T> PaneDefaults(Action<ChartPaneDefaultsSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartPaneDefaultsSettingsBuilder<T>>

The ChartPaneDefaultsSettingsBuilder<T> for the panedefaults setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

The chart panes configuration.Panes are used to split the chart in two or more parts. The panes are ordered from top to bottom.Each axis can be associated with a pane by setting its pane option to the name of the desired pane. Axis that don't have specified pane are placed in the top (default) pane.Series are moved to the desired pane by associating them with an axis.

C#
public ChartBuilder<T> Panes(Action<ChartPaneFactory<T>> configurator)
Parameters:configuratorAction<ChartPaneFactory<T>>

The ChartPaneFactory<T> for the panes setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Specifies if the chart can be panned.

C#
public ChartBuilder<T> Pannable()
Returns:

ChartBuilder<T>

Returns the current instance of ChartPannableSettingsBuilder<T> .

Specifies if the chart can be panned.

C#
public ChartBuilder<T> Pannable(Action<ChartPannableSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartPannableSettingsBuilder<T>>

The ChartPannableSettingsBuilder<T> for the pannable setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Specifies if the chart can be panned.

C#
public ChartBuilder<T> Pannable(bool enabled)
Parameters:enabledbool

Enables or disables the pannable option.

Returns:

ChartBuilder<T>

Returns the current instance of ChartPannableSettingsBuilder<T> .

Configures the export settings for the saveAsPDF method.

C#
public ChartBuilder<T> Pdf(Action<ChartPdfSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartPdfSettingsBuilder<T>>

The ChartPdfSettingsBuilder<T> for the pdf setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Specifies if the series visible option should be persisted when changing the dataSource data.

C#
public ChartBuilder<T> PersistSeriesVisibility()
Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Specifies if the series visible option should be persisted when changing the dataSource data.

C#
public ChartBuilder<T> PersistSeriesVisibility(bool value)
Parameters:valuebool

The value for PersistSeriesVisibility

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

The plot area configuration options. The plot area is the area which displays the series.

C#
public ChartBuilder<T> PlotArea(Action<ChartPlotAreaSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartPlotAreaSettingsBuilder<T>>

The ChartPlotAreaSettingsBuilder<T> for the plotarea setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Specifies the preferred widget rendering mode.

C#
public ChartBuilder<T> RenderAs(RenderingMode value)
Parameters:valueRenderingMode

The value for RenderAs

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

The configuration of the chart series.The series type is determined by the value of the type field. If a type value is missing, the type is assumed to be the one specified in seriesDefaults.

C#
public ChartBuilder<T> Series(Action<ChartSeriesFactory<T>> configurator)
Parameters:configuratorAction<ChartSeriesFactory<T>>

The ChartSeriesFactory<T> for the series setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

The default colors for the chart's series. When all colors are used, new colors are pulled from the start again.

C#
public ChartBuilder<T> SeriesColors(params string[] value)
Parameters:valuestring[]

The value for SeriesColors

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Defines the default options for all Chart series of the specified type.

C#
public ChartBuilder<T> SeriesDefaults(Action<ChartSeriesDefaultsSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartSeriesDefaultsSettingsBuilder<T>>

The action that configures the default series options.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.SeriesDefaults(seriesDefaults =&gt;
seriesDefaults.Area().Line(line =&gt; line.Style(ChartSeriesLineStyle.Smooth))
)
.Series(series =&gt;
{
series.Area(new double[] { 3.907, 7.943, 5.848 }).Name("Result 1");
series.Area(new double[] { 4.223, 6.743, 8.922 }).Name("Result 2");
})
)

The chart subtitle configuration options or text.

C#
public ChartBuilder<T> Subtitle(Action<ChartSubtitleSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartSubtitleSettingsBuilder<T>>

The ChartSubtitleSettingsBuilder<T> for the subtitle setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Sets the subtitle of the Chart.

C#
public ChartBuilder<T> Subtitle(string subtitle)
Parameters:subtitlestring

The text of the subtitle.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("Chart")
.Title("Yearly sales")
.Subtitle("/ thousands /")
)

Specifies the chart theme to be used. The recomended value is sass.Note: Since Q2 2024 release, the default value for the theme property is sass instead of default.With versions prior to R1 2023 this can be either the respective LESS theme from the list below or "sass". When set to "sass" the chart will read the variables from the Sass-based themes.The supported values prior to and including 2023.1.117 version are: "sass"; "black"; "blueopal"; "bootstrap"; "default"; "fiori"; "flat"; "highcontrast"; "material"; "materialblack"; "metro"; "metroblack"; "moonlight"; "nova"; "office365"; "silver" or "uniform".

C#
public ChartBuilder<T> Theme(string value)
Parameters:valuestring

The value for Theme

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

The chart title configuration options or text.

C#
public ChartBuilder<T> Title(Action<ChartTitleSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartTitleSettingsBuilder<T>>

The ChartTitleSettingsBuilder<T> for the title setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Sets the title of the Chart.

C#
public ChartBuilder<T> Title(string title)
Parameters:titlestring

The text of the title.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("Chart")
.Title("Yearly sales")
)

The chart series tooltip configuration options.

C#
public ChartBuilder<T> Tooltip(Action<ChartTooltipSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartTooltipSettingsBuilder<T>>

The ChartTooltipSettingsBuilder<T> for the tooltip setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

If set to true the chart will play animations when displaying the series. By default animations are enabled.

C#
public ChartBuilder<T> Transitions(bool value)
Parameters:valuebool

The value for Transitions

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Defines the value axis options.

C#
public ChartBuilder<T> ValueAxis(Action<ChartValueAxisBuilder<T>> configurator)
Parameters:configuratorAction<ChartValueAxisBuilder<T>>

The action that configures the value axis options.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.ValueAxis(axis =&gt; axis
.Numeric()
.Max(140000)
.Line(line =&gt; line.Visible(false))
)
)

Defines the X-axis configuration options of the Scatter Chart X-axis. The X-axis supports all ValueAxis options.

C#
public ChartBuilder<T> XAxis(Action<ChartXAxisBuilder<T>> configurator)
Parameters:configuratorAction<ChartXAxisBuilder<T>>

The action that configures the X-axis options.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.Series(series =&gt;
{
series.Scatter(new double[][] {
new[] { 6.4, 5.4 },
new[] { 11.7, 2 },
new[] { 25.4, 3 },
new[] { 19.0, 2.0 }
});
})
.XAxis(x =&gt; x
.Numeric()
.Max(30)
)
)

Defines the Y-axis configuration options of the Scatter Chart. The Y-axis supports all ValueAxis options.

C#
public ChartBuilder<T> YAxis(Action<ChartYAxisBuilder<T>> configurator)
Parameters:configuratorAction<ChartYAxisBuilder<T>>

The action that configures the Y-axis options.

Returns:

ChartBuilder<T>

Returns the current ChartBuilder<T> instance.

Example:
C#
@(Html.Kendo().Chart()
.Name("chart")
.Series(series =&gt;
{
series.Scatter(new double[][] {
new[] { 6.4, 5.4 },
new[] { 11.7, 2 },
new[] { 25.4, 3 },
new[] { 19.0, 2.0 }
});
})
.YAxis(x =&gt; x
.Numeric()
.Max(15)
)
)

Specifies if the chart can be zoomed.

C#
public ChartBuilder<T> Zoomable()
Returns:

ChartBuilder<T>

Returns the current instance of ChartZoomableSettingsBuilder<T> .

Specifies if the chart can be zoomed.

C#
public ChartBuilder<T> Zoomable(Action<ChartZoomableSettingsBuilder<T>> configurator)
Parameters:configuratorAction<ChartZoomableSettingsBuilder<T>>

The ChartZoomableSettingsBuilder<T> for the zoomable setting.

Returns:

ChartBuilder<T>

Returns the current instance of ChartBuilder<T> .

Specifies if the chart can be zoomed.

C#
public ChartBuilder<T> Zoomable(bool enabled)
Parameters:enabledbool

Enables or disables the zoomable option.

Returns:

ChartBuilder<T>

Returns the current instance of ChartZoomableSettingsBuilder<T> .