Kendo-UI 中的工具提示模板格式 [英] Tooltip Template Formating in Kendo-UI

查看:21
本文介绍了Kendo-UI 中的工具提示模板格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,最初我的数据仅包含 xy 值,但是,一旦我添加了另一个值 k 但它停止工作了.我打算在工具提示中显示 k 值作为附加信息.有人知道吗?

I have the following code, and initially my data consists only x and y values, however, once I added another value which is k but it stopped working. I am planning to display k value as an additional information into tooltip. Does anybody has any idea?

function createChart() {
    $("#chart")
        .kendoChart({
            xAxis: {},
            yAxis: {},
            seriesDefaults: {type: "scatterLine" },
            series: [{data: stats}],
            tooltip:{visible:true,template: "#= myTooltip(value) # "}
        });
}

function myTooltip(value) {
    return Math.abs(value.x) + ", "+Math.abs(value.y)+","+Math.abs(value.k);
}

http://jsfiddle.net/3yhbyy2g/49/

推荐答案

最后,这是我目前提出的解决方案.这里的关键点是通过 dataItem 访问数据,而不是通过 value-->(value.x, value.y) 访问数据对象中的其他元素除了 xy.

Finally, here is the solution that I have come up so far. The key-point here is to access data via dataItem not via value-->(value.x, value.y) that restricts to access other elements in data objects other than only x and y.

似乎value 继承自dataItem.

 tooltip:
     {
     visible:true,
     template: 
       "x : #=kendo.format('{0:n0}', (Math.abs(dataItem.x)))#, 
        y : #=kendo.format('{0:n0}', (Math.abs(dataItem.y)))#, 
        k : #=kendo.format('{0:n0}', (Math.abs(dataItem.k)))# "
     }

http://jsfiddle.net/3yhbyy2g/50/

这篇关于Kendo-UI 中的工具提示模板格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆