如何制作交互式折线图

时间:2015-01-13 05:30:28

标签: interactive chart.js helper-functions

我查看了Charts.js主页上的迷你条形图。我无法理解如何将其转换为交互式折线图。辅助函数在哪里记录?如何将它们应用于折线图?

1 个答案:

答案 0 :(得分:2)

实施例

var myLineChart = new Chart(ctx).Line(data, options);

数据结构

var data = {
    labels: ["January", "February", "March", "April", "May", "June", "July"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "rgba(220,220,220,0.2)",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(220,220,220,1)",
            data: [65, 59, 80, 81, 56, 55, 40]
        },
        {
            label: "My Second dataset",
            fillColor: "rgba(151,187,205,0.2)",
            strokeColor: "rgba(151,187,205,1)",
            pointColor: "rgba(151,187,205,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(151,187,205,1)",
            data: [28, 48, 40, 19, 86, 27, 90]
        }
    ]
};

您可以在此链接ChartJs-LineChart

中查看相关文档