Description
Feature Proposal
We should be able to specify the data in a dataset as an object that has the values keyed against the labels of the chart.
Feature Use Case
The current implementation works like this:
chart.data.labels = ["A","B","C"];
chart.data.datasets = [{data: [10,0,3]}];
This means you have to make sure that your dataset data array must be zero filled and populated in the same order as the label array. This adds unnecessary complexity to the code that builds the chart data object.
I have run into an issue creating a multiple series from an odata source. In odata, there is no guaranty that you get a data point if the value is zero, which results in this:
chart.data.labels = ["A","B","C"];
chart.data.datasets = [{data: [10,3]}];
This obviously results in an invalid chart, as A is supposed to be 10, B is supposed to be 0 and C is supposed to be 3.
Imagine if the dataset could be specified as an object instead of an array. This would make dataset building MUCH easier and less error prone.
chart.data.labels = ["A","B","C"];
chart.data.datasets = [{data: "A":10,"C":5}]
Possible Implementation
The chart.js library could maintain backward compatibility by detecting whether the dataset data property is an object or an array.