2013-10-23 56 views
0

我想显示一个自定义工具提示,当我的用户悬停在折线图上的一个节点。在剑道,如何使自定义数据绑定工具提示?

在该工具提示,我需要数据绑定到被包含在所述系列

在下面的示例绑定的对象内的字符串,所述的MyObject类有三个属性日期,点数和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 
     ) 
    ) 

回答

1

而不是使用format .Template(“#= customTip#”)其中customTip是包含自定义工具提示文本的模型中的属性之一。格式更受限制,仅用于数字。

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