}
```
+When using the pie/doughnut chart type, the `parsing` object should have a `key` item that points to the value to look at. In this example, the doughnut chart will show two items with values 1500 and 500.
+
+```javascript
+type: 'doughnut',
+data: {
+ datasets: [{
+ data: [{id: 'Sales', nested: {value: 1500}}, {id: 'Purchases', nested: {value: 500}}]
+ }]
+},
+options: {
+ parsing: {
+ key: 'nested.value'
+ }
+}
+```
+
## Object
```javascript
import DatasetController from '../core/core.datasetController';
-import {isArray, toPercentage, toDimension, valueOrDefault} from '../helpers/helpers.core';
+import {isArray, isObject, resolveObjectKey, toPercentage, toDimension, valueOrDefault} from '../helpers/helpers.core';
import {formatNumber} from '../helpers/helpers.intl';
import {toRadians, PI, TAU, HALF_PI, _angleBetween} from '../helpers/helpers.math';
parse(start, count) {
const data = this.getDataset().data;
const meta = this._cachedMeta;
- let i, ilen;
- for (i = start, ilen = start + count; i < ilen; ++i) {
- meta._parsed[i] = +data[i];
+
+ if (this._parsing === false) {
+ meta._parsed = data;
+ } else {
+ let getter = (i) => +data[i];
+
+ if (isObject(data[start])) {
+ const {key = 'value'} = this._parsing;
+ getter = (i) => +resolveObjectKey(data[i], key);
+ }
+
+ let i, ilen;
+ for (i = start, ilen = start + count; i < ilen; ++i) {
+ meta._parsed[i] = getter(i);
+ }
}
}
--- /dev/null
+module.exports = {
+ config: {
+ type: 'doughnut',
+ data: {
+ labels: ['Red', 'Blue', 'Yellow'],
+ datasets: [{
+ data: [
+ {foo: 12},
+ {foo: 4},
+ {foo: 6},
+ ],
+ backgroundColor: ['red', 'blue', 'yellow']
+ }]
+ },
+ options: {
+ parsing: {
+ key: 'foo'
+ }
+ }
+ }
+};