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

Defines the fluent API for configuring the Kendo UI Sparkline

Definition

Namespace:Kendo.Mvc.UI.Fluent

Assembly:Kendo.Mvc.dll

Type Parameters:

T

Syntax:

C#
public class SparklineBuilder<T> : WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>, IHtmlContent where T : class

Inheritance: objectHelperResultWidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>SparklineBuilder<T>

Implements: IHtmlContent

Inherited Members WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ToComponent()WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.Expression(string)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.Explorer(ModelExplorer)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.Name(string)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.Deferred(bool)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.HtmlAttributes(object)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.HtmlAttributes(IDictionary<string, object>)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ScriptAttributes(object, bool)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ScriptAttributes(IDictionary<string, object>, bool)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.Render()WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ToHtmlString()WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.WriteTo(TextWriter, HtmlEncoder)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ToClientTemplate()WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.AsModule(bool)WidgetBuilderBase<Sparkline<T>, SparklineBuilder<T>>.ComponentWidgetBuilderBase<Sparkline<T>, SparklineBuilder<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 SparklineBuilder<T> class.

C#
public SparklineBuilder(Sparkline<T> component)
Parameters:componentSparkline<T>

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 SparklineBuilder<T> AutoBind(bool value)
Parameters:valuebool

The value for AutoBind

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.DataSource(ds =&gt;
{
ds.Ajax().Read(r =&gt; r.Action("SalesData", "Sparkline"));
})
.AutoBind(false)
)

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

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

The configurator for the axisdefaults setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.AxisDefaults(axisDefaults =&gt; axisDefaults.MinorTickSize(5))
)

Configures the category axis

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

The configurator

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.CategoryAxis(axis =&gt; axis
.Categories(s =&gt; s.DateString)
)
)

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

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

The configurator for the chartarea setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.ChartArea(chartArea =&gt; chartArea.margin(20))
)

Sets the Sparkline data.

C#
public virtual SparklineBuilder<T> Data(double data)
Parameters:datadouble

The data for the default Sparkline series.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Data(new int[] { 1, 2 })
)

Sets the Sparkline data.

C#
public virtual SparklineBuilder<T> Data(IEnumerable data)
Parameters:dataIEnumerable

The data for the default Sparkline series.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@(Html.Kendo().Sparkline()
.Name("Sparkline")
.Data(new int[] { 1, 2 })
);

Data Source configuration

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

Use the configurator to set different data binding options.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

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

Configures the client-side events.

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

The client events action.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

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

Configures the client-side events.

C#
public SparklineBuilder<T> Events(Action<SparklineEventBuilder> configurator)
Parameters:configuratorAction<SparklineEventBuilder>

The client events action.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

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

The chart legend configuration options.

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

The configurator for the legend setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Legend(l =&gt; l.Width(200))
)

Sets the legend visibility.

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

A value indicating whether to show the legend.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@(Html.Kendo().Sparkline()
.Name("Sparkline")
.Legend(false)
);

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 SparklineBuilder<T> Panes(Action<ChartPaneFactory<T>> configurator)
Parameters:configuratorAction<ChartPaneFactory<T>>

The configurator for the panes setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Panes(p =&gt; p.Add().Title("content"))
)

Configures the export settings for the saveAsPDF method.

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

The configurator for the pdf setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Pdf(pdf =&gt; pdf.KeepPNG(true))
)

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

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

The configurator for the plotarea setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.PlotArea(plotArea =&gt; plotArea.margin(20))
)

The width to allocate for each data point.

C#
public SparklineBuilder<T> PointWidth(double value)
Parameters:valuedouble

The value for PointWidth

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Specifies the preferred widget rendering mode.

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

The value for RenderAs

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.RenderAs(RenderingMode.Canvas)
)

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 SparklineBuilder<T> Series(Action<ChartSeriesFactory<T>> configurator)
Parameters:configuratorAction<ChartSeriesFactory<T>>

The configurator for the series setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.Series(series =&gt;
{
series.Bar(s =&gt; s.SalesAmount);
})
)

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

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

The value for SeriesColors

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.SeriesColors(new string[] { "#f00", "#0f0", "#00f" })
)

Defines the options for all chart series of the specified type.

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

The configurator.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.SeriesDefaults(series =&gt; series.Bar().Stack(true))
)

The chart theme.The supported values are:

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

The value for Theme

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Theme("Telerik")
)

The chart title configuration options or text.

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

The configurator for the title setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Title(t =&gt; t.Text("content"))
)

The chart title.

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

The value of the Chart title

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Title("value")
)

The chart series tooltip configuration options.

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

The configurator for the tooltip setting.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Tooltip(tooltip =&gt;
{
tooltip.Visible(true).Format("{0:C}");
})
)

Sets the data point tooltip visibility.

C#
public SparklineBuilder<T> Tooltip(bool visible)
Parameters:visiblebool

A value indicating if the data point tooltip should be displayed. The tooltip is not visible by default.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@(Html.Kendo().Sparkline()
.Name("Sparkline")
.Tooltip(true)
);

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

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

The value for Transitions

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline()
.Name("Sparkline")
.Transitions(false)
)

Sets the type of the sparkline.

C#
public SparklineBuilder<T> Type(SparklineType type)
Parameters:typeSparklineType

The Sparkline type.

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@(Html.Kendo().Sparkline()
.Name("Sparkline")
.Type(SparklineType.Area)
);

Configures the default value axis or adds a new one

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

The configurator for the axis

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.ValueAxis(a =&gt; a.Numeric().Title("content"))
)

Configures the default X axis or adds a new one

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

The configurator for the axis

Returns:

SparklineBuilder<T>

Returns the current SparklineBuilder<T> instance.

Example:
C#
@( Html.Kendo().Sparkline(Model)
.Name("Sparkline")
.XAxis(a =&gt; a.Numeric().Title("content"))
)