I'm relatively new in kendo chart. I have a chart as following;
@(Html.Kendo().Chart<PlodWareWeb.Models.TotalDrilledBySize>()
.Name("totalDrilledBySizeChart")
.Title("Total Drilled By Size")
.ChartArea(chartArea => chartArea.Background("transparent").Height(350))
.DataSource(dataSource => dataSource.Read(read => read.Action("GetTotalDrilledBySizeChartData", "Home")))
.Legend(legend => legend.Visible(false))
.Series(series =>
{
series.Column(model => model.TotalDrilled, model => model.GroupName);
})
.CategoryAxis(axis => axis.Categories(model => model.HoleSize).Line(line => line.Visible(true)).Labels(labels => labels.Rotation(0)))
.CategoryAxis(axis => axis.Categories(model => model.DisplayName)
.Line(line => line.Visible(false))
.Labels(labels => labels.Rotation(-90).Format("{0}")))
.ValueAxis(axis => axis.Numeric().Labels(labels => labels.Format("{0}")))
.Tooltip(tooltip => tooltip.Visible(true).Format("{0}%").Template("#= series.name #: #= value #")
)
)
How can I show "model.DisplayName" and "model.HoleSize" as a Tooltip in Template? I've tried the following but it gives me "undefined". Can anyone help? Thank you.
.Template("#= model.DisplayName #: #= series.name #: #= value #")
or
.Template("#= CategoryAxis.model.DisplayName #: #= series.name #: #= value #")
To access the data of the chart you need to use "dataItem" as follows;
.Tooltip(tooltip => tooltip.Visible(true).Format("{0}%").Template("#= dataItem.DisplayName # #= dataItem.HoleSize #: #= series.name #: #= value #")
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With