I using Chart.js and I want to pull the data from the properties inside the DIV element.
I can get data in data-gpget and data-gpret. It writes to the console but does not see it as "data" data.
data: getATT('#graph3','data-gpval') and data: getATT('#graph3','data-gpret')
What could be the reason for this? What am I missing?
Thank you.
<div id="graph3" data-gpget="[28,12,14,27,11]" data-gpret="[21,64,32,73,76]">
<canvas id="js-chartjs-earnings"></canvas>
</div>
JS:
function getATT(id,value) {
return $(id).attr(value);
}
return e = a, t = [{
key: "initCharts", value: function () {
Chart.defaults.scale.gridLines.color = "transparent", Chart.defaults.scale.gridLines.zeroLineColor = "transparent", Chart.defaults.scale.ticks.beginAtZero = !0, Chart.defaults.global.elements.line.borderWidth = 0, Chart.defaults.global.elements.point.radius = 0, Chart.defaults.global.elements.point.hoverRadius = 0, Chart.defaults.global.tooltips.cornerRadius = 3, Chart.defaults.global.legend.labels.boxWidth = 12;
var r, a = jQuery(".js-chartjs-earnings");
r = {
labels: ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"],
datasets: [{
label: "GETTING",
fill: !0,
data: getATT('#graph3','data-gpget')
}, {
label: "RETURNS",
fill: !0,
data: getATT('#graph3','data-gpret')
}]
}, a.length && new Chart(a, {
type: "bar",
data: r,
options: {
tooltips: {
intersect: !1, callbacks: {
label: function (r, a) {
return a.datasets[r.datasetIndex].label + ": $" + r.yLabel
}
}
}
}
})
}
}, {
key: "init", value: function () {
this.initCharts()
}
}], null && r(e.prototype, null), t && r(e, t), a