工具提示中的多个对象处理

Multiple objects handling in ToolTip

如果我的数组中有 3 个对象,Kendo UI 不会显示任何工具提示。但是,如果数组中只有两个对象,它就可以正常工作。

代码如下:

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

Here是三个对象的fiddle。

Here是有两个对象的fiddle。

Here 是答案:

首先,我应该将对象数组更改为常规 javascript 对象,然后它就可以工作了。

var stats = [
    [0 , 200,400], [100, 300,900],[220, 400,1000],[300, 500,1500],[400, 800,1700],[600, 1200,1800],[800, 1600,3000]
];

stats = stats.map(function(x) {
    return { x: x[0], y: x[1], k: x[2] };
});

function createChart() {
    $("#chart")
        .kendoChart({
            xAxis: {},
            yAxis: {},
            seriesDefaults: {type: "scatterLine" },
            series: [{data: stats}],
            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)))# "}
        });
}


$(document)
    .ready(createChart);