1
Chart.js有一个很好的新版本,看起来更直观一些。但我试图用V1设计一些代码,它不工作,但深入了解它,有点超越我 - 我试图使用的代码是这里的最后一篇文章 - http://yuluer.com/page/dbajceij-chart-js-draw-horizontal-line.shtml如何使用ChartJS v2绘制动态直线
我的代码线图如下:
$.ajax({
url : "getData.asp",
type: "POST",
data : {
database: dataBase,
sn: Options,
opts: opt,
dateRange: dateRange
},
dataType:"json",
success: function(result){
var Result = (result)
Array.prototype.mapProperty = function(property) {
return this.map(function (obj) {
return obj[property];
});
};
var ctx = document.getElementById("chart");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: result.mapProperty('sn'),
datasets: [{
label: opt,
data: result.mapProperty('data')
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: false
}
}]
}
}
});
})
有没有人设法在V2上获得自定义的动态直线?
谢谢你,我会检查了这一点! – Hyperjase