在剑道图上显示工具提示

时间:2016-10-17 18:32:14

标签: kendo-ui kendo-asp.net-mvc kendo-chart

我正在使用Telerik UI for ASP.NET Core

我有一张显示date vs int图表的剑道图表。该模型有2个属性CreatedDateTime(datetime)Count(int)。该图表按月计算总和。 以下是模型和图表

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}"))
        )

目前图表仅显示&#39; Count`作为工具提示,此外我还想在工具提示中显示月份。

我想知道工具提示显示月份的语法是什么?有tooltip.template()方法,但我无法确定显示计数和月份的语法。

2 个答案:

答案 0 :(得分:1)

您使用模板。 &#34;类别&#34;是您想要的特殊关键字

"#= category # - #= value #"

你可能希望格式化日期,所以尝试这样的事情:

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

答案 1 :(得分:0)

这是一种在图表工具提示中获取系列名称的方法。

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