A number of changes were made to the configuration options passed to the `Chart` constructor. Those changes are documented below.
+#### Generic changes
+
+* Indexable options are now looping. `backgroundColor: ['red', 'green']` will result in alternating `'red'` / `'green'` if there are more than 2 data points.
+
+#### Specific changes
+
* `hover.animationDuration` is now configured in `animation.active.duration`
* `responsiveAnimationDuration` is now configured in `animation.resize.duration`
* Polar area `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`.
--- /dev/null
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 2, 3, 4, 5, 6],
+ backgroundColor: [
+ '#ff0000',
+ '#00ff00',
+ '#0000ff'
+ ]
+ },
+ {
+ // option in element (fallback)
+ data: [6, 5, 4, 3, 2, 1],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: [
+ '#000000',
+ '#888888'
+ ]
+ }
+ },
+ scales: {
+ x: {display: false},
+ y: {display: false}
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
});
it ('should fallback if an indexable option value is undefined', function() {
var input = [42, undefined, 'bar'];
- expect(resolve([input], undefined, 5)).toBe(undefined);
+ expect(resolve([input], undefined, 1)).toBe(undefined);
expect(resolve([input, 'foo'], undefined, 1)).toBe('foo');
- expect(resolve([input, 'foo'], undefined, 5)).toBe('foo');
+ });
+ it ('should loop if an indexable option index is out of bounds', function() {
+ var input = [42, undefined, 'bar'];
+ expect(resolve([input], undefined, 3)).toBe(42);
+ expect(resolve([input, 'foo'], undefined, 4)).toBe('foo');
+ expect(resolve([input, 'foo'], undefined, 5)).toBe('bar');
});
it ('should not handle indexable options if index is undefined', function() {
var array = [42, 'foo', 'bar'];
};
expect(resolve([input, 'foo'], {v: 42}, 0)).toBe(42);
expect(resolve([input, 'foo'], {v: 42}, 1)).toBe('foo');
- expect(resolve([input, 'foo'], {v: 42}, 5)).toBe('foo');
+ expect(resolve([input, 'foo'], {v: 42}, 5)).toBe('bar');
expect(resolve([input, ['foo', 'bar']], {v: 42}, 1)).toBe('bar');
});
});