0
votes

I am using Telerik UI for ASP.NET Core

I have a kendo chart that shows date vs int graph. The model has 2 properties CreatedDateTime(datetime) and Count(int). The chart do the sum of count by month. Below is the model and chart

public class Document
{
    public DateTime CreatedDateTime { get; set; }

    public int Count { get; set; }
}



@model IEnumerable<Document>

@(Html.Kendo().Chart(Model)
                .Name("chart")
                .Title("Dashboard Metrics")
                .Legend(legend => legend
                .Position(ChartLegendPosition.Bottom)
            )
            .Series(series =>
            {
                series
                .Area(model => model.Count, model => model.CreatedDateTime)
                .Aggregate(ChartSeriesAggregate.Sum)
                .Name("Document Count").Color("#BA2727").Opacity(.7);
            })
            .CategoryAxis(axis => axis
                .Date()
                .BaseUnit(ChartAxisBaseUnit.Months)
                .Labels(labels => labels.DateFormats(formats => formats.Months("MMM")))
            )
            .Tooltip(tooltip => tooltip
                .Visible(true)               
                .Format("{0:N0}"))
        )

Currently chart shows only 'Count` as tooltip, in addition i also want to show month in the tooltip.

I would like to know what would be the syntax for tooltip to show month as well? There is tooltip.template() method but im not able to figure the syntax to show both count and month.

2

2 Answers

1
votes

You use template. "category" is the special keyword you want

"#= category # - #= value #"

You will probably want the date formated, so try something like this:

"#= kendo.toString( category , 'd/M/yyyy') # - #= value #"
0
votes

Here is a way to get the series name inside of a chart tooltip.

.Tooltip(tooltip => tooltip
    .Visible(true)                                    
    .Template("#= series.name #: #= value.current #%")
 )