如何显示图表javascript?
How does display chart javascript?
我正在开发 Web 应用程序,我需要使用库 "Chart.js"。我正在 "jsfiddle" 上测试代码,我不知道为什么这不起作用!
感谢帮助。
<body>
<canvas id="myChart" width="600" height="600"></canvas>
</body>
var 数据 = {
labels: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto"],
datasets: [
{
label: "Temperature 2013",
fillColor: "rgba(99,240,220,0.2)",
strokeColor: "rgba(99,240,220,1)",
pointColor: "rgba(99,240,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [8, 11, 18, 22, 24, 26, 34, 39]
},
{
label: "Temperature 2014",
fillColor: "rgba(205,99,151,0.2)",
strokeColor: "rgba(205,99,151,1)",
pointColor: "rgba(205,99,151,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [16, 18, 22, 24, 26, 28, 32, 36]
}
]
};
var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Line(data);`JSFIDDLE
我将两个链接都更改为 https 并更改了这个
var myLineChart = new Chart(ctx).Line(data);
// to this
var myLineChart = new Chart(ctx, {
type: 'line',
data: data
});
Example 呈现两行。
我正在开发 Web 应用程序,我需要使用库 "Chart.js"。我正在 "jsfiddle" 上测试代码,我不知道为什么这不起作用!
感谢帮助。
<body>
<canvas id="myChart" width="600" height="600"></canvas>
</body>
var 数据 = {
labels: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto"],
datasets: [
{
label: "Temperature 2013",
fillColor: "rgba(99,240,220,0.2)",
strokeColor: "rgba(99,240,220,1)",
pointColor: "rgba(99,240,220,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: [8, 11, 18, 22, 24, 26, 34, 39]
},
{
label: "Temperature 2014",
fillColor: "rgba(205,99,151,0.2)",
strokeColor: "rgba(205,99,151,1)",
pointColor: "rgba(205,99,151,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [16, 18, 22, 24, 26, 28, 32, 36]
}
]
};
var ctx = document.getElementById("myChart").getContext("2d"); var myLineChart = new Chart(ctx).Line(data);`JSFIDDLE
我将两个链接都更改为 https 并更改了这个
var myLineChart = new Chart(ctx).Line(data);
// to this
var myLineChart = new Chart(ctx, {
type: 'line',
data: data
});
Example 呈现两行。