简体   繁体   English

Kendo-UI中的工具提示模板格式

[英]Tooltip Template Formating in Kendo-UI

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. 我有以下代码,最初我的数据仅包含xy值,但是,一旦我添加了另一个值k但它停止工作。 I am planning to display k value as an additional information into tooltip. 我打算在工具提示中显示k值作为附加信息。 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/ http://jsfiddle.net/3yhbyy2g/49/

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 . 这里的关键点是通过dataItem访问数据,而不是通过value-->(value.x, value.y)来访问数据,该访问限制了只能访问xy之外的数据对象中的其他元素。

It seems that value inherits from dataItem . 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/ http://jsfiddle.net/3yhbyy2g/50/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM