当用户将鼠标悬停在折线图中的节点上时,我想显示自定义工具提示。
在这个工具提示中,我需要数据绑定到包含在系列中绑定的对象中的字符串
在下面的示例中,MyObject类有三个属性 Date,Point和Point_Info
@(Html.Kendo().Chart<MyObject>()
.Name("chart")
.Title("")
.DataSource(ds =>
ds.Read(read => read.Action("_X", "Y"))
)
.Series(series =>
{
series.ScatterLine(model => model.Date, model => model.Point);
})
.XAxis(x=>x
.Date()
.Title("Date")
)
.Tooltip(tooltip => tooltip
.Visible(true)
. Format("{1} on {0} -- #=Point_Info#") <-- this doesnt work for me
)
)
答案 0 :(得分:1)
而不是使用格式使用.Template(“#= customTip#”),其中customTip是包含自定义工具提示文本的模型中的属性之一。格式更加有限,仅用于数字。
答案 1 :(得分:0)
谢谢Mike!
@(Html.Kendo().Chart<MyObject>()
.Name("chart")
.Title("")
.DataSource(ds =>
ds.Read(read => read.Action("_X", "Y"))
)
.Series(series =>
{
series.ScatterLine(model => model.Date, model => model.Point).Tooltip(x=>x.Template("#=dataItem.Point_Info#"));
})
.XAxis(x=>x
.Date()
.Title("Date")
)
.Tooltip(tooltip => tooltip
.Visible(true)
)
)