javascript - Can not update bar chart values in Chart.js 2.0.0 alpha3 -
i trying draw live bar chart using latest chart.js alpha. want dynamically update both values , labels. however, when try address specific bar, say, number 3:
$.each(my_chart.datasets, function(i, dataset){ dataset.data[3].fillcolor = fc; dataset.data[3].value = v; }); i jquery error, stating cannot length of 1 of parameters.
when try access chart's dataset this:
my_chart.datasets[0].data = new_values_array; i typeerror: undefined not object
what right way address problem in newest alpha? examples suggest updating whole array, can't see difference between updating whole array or addressing specific element. maybe i'm missing something. thank you!
you can update point point, so
$.each(my_chart.data.datasets, function (i, dataset) { dataset.metadata[3].custom = { backgroundcolor: "green" }; dataset.data[3] = 2.5; }); my_chart.update(); replace green fc , 2.5 v
fiddle - https://jsfiddle.net/6qt14tpj/
Comments
Post a Comment