0
我想將gif圖像添加到chart.js,就像它在這裏完成的方式a link!/但在chart.js的最新版本(2.0)中。將gif圖像添加到chart.js V2.0
這裏是代碼完全適用於.png圖片,但不是.gif圖片也不適用於chart.js的V2.0。 請幫忙提前
謝謝:)
var img = new Image();
var size = 48;
Chart.types.Line.extend({
name: "LineAlt",
draw: function() {
Chart.types.Line.prototype.draw.apply(this, arguments);
var scale = this.scale;
[
\t { x: 2, y: 50 },
{ x: 4, y: 10 }
].forEach(function(p) {
ctx.drawImage(img, scale.calculateX(p.x) - size/2, scale.calculateY(p.y) - size/2, size, size);
})
}
});
var data = {
labels: ["Dec", "Jan", "Feb", "March", "April", "May", "June"],
datasets: [{
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]
}]
};
var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).LineAlt(data, {
scaleBeginAtZero: true
});
,我發現經過一番艱苦的工作解決方案,並在這裏張貼如果有一個人需要它。 – Hellboy