如何在canvajs中为X轴标签添加工具提示功能?

时间:2017-01-20 10:57:38

标签: javascript canvas tooltip canvasjs

如何向x轴标签添加工具提示功能?这是我的代码

window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
    title: {
        //text: "Line Chart"
    },
    axisY2: {
        includeZero: false,
        title: "Accuracy"
    },
    axisY: {
        title: "Speed"
    },
    data: [{
        type: "line",
        name: "Average Speed(in sec)",
        showInLegend: true,
        dataPoints: [
        {
            label: 'Test1 simple test simple test ',
            y: 3
        },
        {
            label: 'Test2',
            y: 5
        },
        {
            label: 'Test3',
            y: 6
        },
        {
            label: 'Test4',
            y: 4.5
        },
        {
            label: 'Test5',
            y: 6.8
        },
        {
            label: 'Test6',
            y: 7.9
        },
        {
            label: 'Test7',
            y: 8
        },
        {
            label: 'Test8',
            y: 4.5
        }, ]
    },
    {
        type: "line",
        name: "Accuracy(in %)",
        showInLegend: true,
        axisYType: "secondary",
        dataPoints: [
        {
            label: 'Test1',
            y: 50
        },
        {
            label: 'Test2',
            y: 60
        },
        {
            label: 'Test3',
            y: 99
        },
        {
            label: 'Test4',
            y: 78
        },
        {
            label: 'Test5',
            y: 56
        },
        {
            label: 'Test6',
            y: 44
        },
        {
            label: 'Test7',
            y: 67
        },
        {
            label: 'Test8',
            y: 70
        }, ]
    }, ]
});
chart.render();
}

当标签太长时根据我的测试看起来并不合适。所以我想在标签上添加指定内容,当用户将鼠标悬停在标签上时,我想在工具提示中显示完整标签。

0 个答案:

没有答案
相关问题