diff --git a/docs/charts/bar.md b/docs/charts/bar.md
index b14afddee00..e71c38e24ba 100644
--- a/docs/charts/bar.md
+++ b/docs/charts/bar.md
@@ -61,31 +61,69 @@ var myBarChart = new Chart(ctx, {
```
## Dataset Properties
-The bar chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of the bars is generally set this way.
-Some properties can be specified as an array. If these are set to an array value, the first value applies to the first bar, the second value to the second bar, and so on.
+The bar chart allows a number of properties to be specified for each dataset.
+These are used to set display properties for a specific dataset. For example,
+the color of the bars is generally set this way.
-| Name | Type | Description
-| ---- | ---- | -----------
-| `label` | `String` | The label for the dataset which appears in the legend and tooltips.
-| `xAxisID` | `String` | The ID of the x axis to plot this dataset on. If not specified, this defaults to the ID of the first found x axis.
-| `yAxisID` | `String` | The ID of the y axis to plot this dataset on. If not specified, this defaults to the ID of the first found y axis.
-| `backgroundColor` | `Color/Color[]` | The fill color of the bar. See [Colors](../general/colors.md#colors).
-| `borderColor` | `Color/Color[]` | The color of the bar border. See [Colors](../general/colors.md#colors).
-| `borderWidth` | `Number/Number[]` | The stroke width of the bar in pixels.
-| `borderSkipped` | `String` | Which edge to skip drawing the border for. [more...](#borderskipped)
-| `hoverBackgroundColor` | `Color/Color[]` | The fill colour of the bars when hovered.
-| `hoverBorderColor` | `Color/Color[]` | The stroke colour of the bars when hovered.
-| `hoverBorderWidth` | `Number/Number[]` | The stroke width of the bars when hovered.
-
-### borderSkipped
-This setting is used to avoid drawing the bar stroke at the base of the fill. In general, this does not need to be changed except when creating chart types that derive from a bar chart.
+| Name | Type | [Scriptable](../general/options.md#scriptable-options) | [Indexable](../general/options.md#indexable-options) | Default
+| ---- | ---- | :----: | :----: | ----
+| [`backgroundColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
+| [`borderColor`](#styling) | [`Color`](../general/colors.md) | Yes | Yes | `'rgba(0,0,0,0.1)'`
+| [`borderSkipped`](#borderskipped) | `String` | Yes | Yes | `'bottom'`
+| [`borderWidth`](#styling) | `Number` | Yes | Yes | `0`
+| [`data`](#data-structure) | `Object[]` | - | - | **required**
+| [`hoverBackgroundColor`](#interactions) | [`Color`](../general/colors.md) | - | - | `undefined`
+| [`hoverBorderColor`](#interactions) | [`Color`](../general/colors.md) | - | - | `undefined`
+| [`hoverBorderWidth`](#interactions) | `Number` | - | - | `1`
+| [`label`](#general) | `String` | - | - | `''`
+| [`xAxisID`](#general) | `String` | - | - | first x axis
+| [`yAxisID`](#general) | `String` | - | - | first y axis
+
+### General
+
+| Name | Description
+| ---- | ----
+| `label` | The label for the dataset which appears in the legend and tooltips.
+| `xAxisID` | The ID of the x axis to plot this dataset on.
+| `yAxisID` | The ID of the y axis to plot this dataset on.
+
+### Styling
+
+The style of each bar can be controlled with the following properties:
+
+| Name | Description
+| ---- | ----
+| `backgroundColor` | The bar background color.
+| `borderColor` | The bar border color.
+| [`borderSkipped`](#borderskipped) | The edge to skip when drawing bar.
+| `borderWidth` | The bar border width (in pixels).
+
+All these values, if `undefined`, fallback to the associated [`elements.rectangle.*`](../configuration/elements.md#rectangle-configuration) options.
+
+#### borderSkipped
+
+This setting is used to avoid drawing the bar stroke at the base of the fill.
+In general, this does not need to be changed except when creating chart types
+that derive from a bar chart.
Options are:
-* 'bottom'
-* 'left'
-* 'top'
-* 'right'
+* `'bottom'`
+* `'left'`
+* `'top'`
+* `'right'`
+
+### Interactions
+
+The interaction with each bar can be controlled with the following properties:
+
+| Name | Description
+| ---- | -----------
+| `hoverBackgroundColor` | The bar background color when hovered.
+| `hoverBorderColor` | The bar border color hovered.
+| `hoverBorderWidth` | The bar border width when hovered (in pixels).
+
+All these values, if `undefined`, fallback to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options.
## Configuration Options
diff --git a/gulpfile.js b/gulpfile.js
index 49fd66ade16..d8872df0e31 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -186,16 +186,16 @@ function lintHtmlTask() {
}
function docsTask(done) {
- const script = require.resolve('gitbook-cli/bin/gitbook.js');
- const cmd = process.execPath;
+ var script = require.resolve('gitbook-cli/bin/gitbook.js');
+ var cmd = '"' + process.execPath + '"';
exec([cmd, script, 'install', './'].join(' ')).then(() => {
return exec([cmd, script, argv.watch ? 'serve' : 'build', './', './dist/docs'].join(' '));
- }).catch((err) => {
- console.error(err.stdout);
}).then(() => {
done();
- });
+ }).catch((err) => {
+ done(new Error(err.stdout || err));
+ })
}
function unittestTask(done) {
diff --git a/samples/samples.js b/samples/samples.js
index b818827c6d2..6edc6282423 100644
--- a/samples/samples.js
+++ b/samples/samples.js
@@ -176,6 +176,9 @@
}, {
title: 'Scriptable',
items: [{
+ title: 'Bar Chart',
+ path: 'scriptable/bar.html'
+ }, {
title: 'Bubble Chart',
path: 'scriptable/bubble.html'
}]
diff --git a/samples/scriptable/bar.html b/samples/scriptable/bar.html
new file mode 100644
index 00000000000..ec7ac35c842
--- /dev/null
+++ b/samples/scriptable/bar.html
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+ Scriptable > Bar | Chart.js sample
+
+
+
+
+
+
+
+
+ Randomize
+ Add Dataset
+ Remove Dataset
+
+
+
+
+
+
diff --git a/samples/utils.js b/samples/utils.js
index 50bb81c0c1b..71ac5e4e122 100644
--- a/samples/utils.js
+++ b/samples/utils.js
@@ -11,7 +11,7 @@ window.chartColors = {
};
(function(global) {
- var Months = [
+ var MONTHS = [
'January',
'February',
'March',
@@ -106,7 +106,7 @@ window.chartColors = {
var i, value;
for (i = 0; i < count; ++i) {
- value = Months[Math.ceil(i) % 12];
+ value = MONTHS[Math.ceil(i) % 12];
values.push(value.substring(0, section));
}
diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js
index 74e6d2289f0..36f7c7e6e37 100644
--- a/src/controllers/controller.bar.js
+++ b/src/controllers/controller.bar.js
@@ -213,27 +213,24 @@ module.exports = function(Chart) {
updateElement: function(rectangle, index, reset) {
var me = this;
- var chart = me.chart;
var meta = me.getMeta();
var dataset = me.getDataset();
- var custom = rectangle.custom || {};
- var rectangleOptions = chart.options.elements.rectangle;
+ var options = me._resolveElementOptions(rectangle, index);
rectangle._xScale = me.getScaleForId(meta.xAxisID);
rectangle._yScale = me.getScaleForId(meta.yAxisID);
rectangle._datasetIndex = me.index;
rectangle._index = index;
-
rectangle._model = {
+ backgroundColor: options.backgroundColor,
+ borderColor: options.borderColor,
+ borderSkipped: options.borderSkipped,
+ borderWidth: options.borderWidth,
datasetLabel: dataset.label,
- label: chart.data.labels[index],
- borderSkipped: custom.borderSkipped ? custom.borderSkipped : rectangleOptions.borderSkipped,
- backgroundColor: custom.backgroundColor ? custom.backgroundColor : helpers.valueAtIndexOrDefault(dataset.backgroundColor, index, rectangleOptions.backgroundColor),
- borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.borderColor, index, rectangleOptions.borderColor),
- borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.borderWidth, index, rectangleOptions.borderWidth)
+ label: me.chart.data.labels[index]
};
- me.updateElementGeometry(rectangle, index, reset);
+ me._updateElementGeometry(rectangle, index, reset);
rectangle.pivot();
},
@@ -241,7 +238,7 @@ module.exports = function(Chart) {
/**
* @private
*/
- updateElementGeometry: function(rectangle, index, reset) {
+ _updateElementGeometry: function(rectangle, index, reset) {
var me = this;
var model = rectangle._model;
var vscale = me.getValueScale();
@@ -472,6 +469,47 @@ module.exports = function(Chart) {
helpers.canvas.unclipArea(chart.ctx);
},
+
+ /**
+ * @private
+ */
+ _resolveElementOptions: function(rectangle, index) {
+ var me = this;
+ var chart = me.chart;
+ var datasets = chart.data.datasets;
+ var dataset = datasets[me.index];
+ var custom = rectangle.custom || {};
+ var options = chart.options.elements.rectangle;
+ var resolve = helpers.options.resolve;
+ var values = {};
+ var i, ilen, key;
+
+ // Scriptable options
+ var context = {
+ chart: chart,
+ dataIndex: index,
+ dataset: dataset,
+ datasetIndex: me.index
+ };
+
+ var keys = [
+ 'backgroundColor',
+ 'borderColor',
+ 'borderSkipped',
+ 'borderWidth'
+ ];
+
+ for (i = 0, ilen = keys.length; i < ilen; ++i) {
+ key = keys[i];
+ values[key] = resolve([
+ custom[key],
+ dataset[key],
+ options[key]
+ ], context, index);
+ }
+
+ return values;
+ }
});
Chart.controllers.horizontalBar = Chart.controllers.bar.extend({
diff --git a/src/controllers/controller.bubble.js b/src/controllers/controller.bubble.js
index f14e512300f..ed1e2045c71 100644
--- a/src/controllers/controller.bubble.js
+++ b/src/controllers/controller.bubble.js
@@ -103,12 +103,14 @@ module.exports = function(Chart) {
setHoverStyle: function(point) {
var model = point._model;
var options = point._options;
+
point.$previousStyle = {
backgroundColor: model.backgroundColor,
borderColor: model.borderColor,
borderWidth: model.borderWidth,
radius: model.radius
};
+
model.backgroundColor = helpers.valueOrDefault(options.hoverBackgroundColor, helpers.getHoverColor(options.backgroundColor));
model.borderColor = helpers.valueOrDefault(options.hoverBorderColor, helpers.getHoverColor(options.borderColor));
model.borderWidth = helpers.valueOrDefault(options.hoverBorderWidth, options.borderWidth);
@@ -167,6 +169,7 @@ module.exports = function(Chart) {
dataset.radius,
options.radius
], context, index);
+
return values;
}
});
diff --git a/test/fixtures/controller.bar/backgroundColor/indexable.js b/test/fixtures/controller.bar/backgroundColor/indexable.js
new file mode 100644
index 00000000000..781f81b878f
--- /dev/null
+++ b/test/fixtures/controller.bar/backgroundColor/indexable.js
@@ -0,0 +1,52 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ backgroundColor: [
+ '#ff0000',
+ '#00ff00',
+ '#0000ff',
+ '#ffff00',
+ '#ff00ff',
+ '#000000'
+ ]
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: [
+ '#ff88ff',
+ '#888888',
+ '#ff8800',
+ '#00ff88',
+ '#8800ff',
+ '#ffff88'
+ ]
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/backgroundColor/indexable.png b/test/fixtures/controller.bar/backgroundColor/indexable.png
new file mode 100644
index 00000000000..eecc4ac6df2
Binary files /dev/null and b/test/fixtures/controller.bar/backgroundColor/indexable.png differ
diff --git a/test/fixtures/controller.bar/backgroundColor/scriptable.js b/test/fixtures/controller.bar/backgroundColor/scriptable.js
new file mode 100644
index 00000000000..b17349b1da8
--- /dev/null
+++ b/test/fixtures/controller.bar/backgroundColor/scriptable.js
@@ -0,0 +1,57 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ backgroundColor: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return value > 8 ? '#ff0000'
+ : value > 0 ? '#00ff00'
+ : value > -8 ? '#0000ff'
+ : '#ff00ff';
+ }
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5]
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return value > 8 ? '#ff00ff'
+ : value > 0 ? '#0000ff'
+ : value > -8 ? '#ff0000'
+ : '#00ff00';
+ }
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [
+ {
+ display: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }
+ ]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/backgroundColor/scriptable.png b/test/fixtures/controller.bar/backgroundColor/scriptable.png
new file mode 100644
index 00000000000..e78839af1d8
Binary files /dev/null and b/test/fixtures/controller.bar/backgroundColor/scriptable.png differ
diff --git a/test/fixtures/controller.bar/backgroundColor/value.js b/test/fixtures/controller.bar/backgroundColor/value.js
new file mode 100644
index 00000000000..d82d60d5dfc
--- /dev/null
+++ b/test/fixtures/controller.bar/backgroundColor/value.js
@@ -0,0 +1,38 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ backgroundColor: '#ff0000'
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: '#00ff00'
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/backgroundColor/value.png b/test/fixtures/controller.bar/backgroundColor/value.png
new file mode 100644
index 00000000000..4885e108607
Binary files /dev/null and b/test/fixtures/controller.bar/backgroundColor/value.png differ
diff --git a/test/fixtures/controller.bar/borderColor/indexable.js b/test/fixtures/controller.bar/borderColor/indexable.js
new file mode 100644
index 00000000000..de39b134ae8
--- /dev/null
+++ b/test/fixtures/controller.bar/borderColor/indexable.js
@@ -0,0 +1,54 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderColor: [
+ '#ff0000',
+ '#00ff00',
+ '#0000ff',
+ '#ffff00',
+ '#ff00ff',
+ '#000000'
+ ]
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: [
+ '#ff88ff',
+ '#888888',
+ '#ff8800',
+ '#00ff88',
+ '#8800ff',
+ '#ffff88'
+ ],
+ borderWidth: 8
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderColor/indexable.png b/test/fixtures/controller.bar/borderColor/indexable.png
new file mode 100644
index 00000000000..1a3a45cdd21
Binary files /dev/null and b/test/fixtures/controller.bar/borderColor/indexable.png differ
diff --git a/test/fixtures/controller.bar/borderColor/scriptable.js b/test/fixtures/controller.bar/borderColor/scriptable.js
new file mode 100644
index 00000000000..d4fefc788f3
--- /dev/null
+++ b/test/fixtures/controller.bar/borderColor/scriptable.js
@@ -0,0 +1,59 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderColor: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return value > 8 ? '#ff0000'
+ : value > 0 ? '#00ff00'
+ : value > -8 ? '#0000ff'
+ : '#ff00ff';
+ }
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5]
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return value > 8 ? '#ff00ff'
+ : value > 0 ? '#0000ff'
+ : value > -8 ? '#ff0000'
+ : '#00ff00';
+ },
+ borderWidth: 8
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [
+ {
+ display: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }
+ ]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderColor/scriptable.png b/test/fixtures/controller.bar/borderColor/scriptable.png
new file mode 100644
index 00000000000..c24a2beab8e
Binary files /dev/null and b/test/fixtures/controller.bar/borderColor/scriptable.png differ
diff --git a/test/fixtures/controller.bar/borderColor/value.js b/test/fixtures/controller.bar/borderColor/value.js
new file mode 100644
index 00000000000..4f328b59168
--- /dev/null
+++ b/test/fixtures/controller.bar/borderColor/value.js
@@ -0,0 +1,40 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderColor: '#ff0000'
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#00ff00',
+ borderWidth: 8
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderColor/value.png b/test/fixtures/controller.bar/borderColor/value.png
new file mode 100644
index 00000000000..6e170412c30
Binary files /dev/null and b/test/fixtures/controller.bar/borderColor/value.png differ
diff --git a/test/fixtures/controller.bar/borderSkipped/indexable.js b/test/fixtures/controller.bar/borderSkipped/indexable.js
new file mode 100644
index 00000000000..405e6da62f1
--- /dev/null
+++ b/test/fixtures/controller.bar/borderSkipped/indexable.js
@@ -0,0 +1,55 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderSkipped: [
+ 'top',
+ 'top',
+ 'right',
+ 'right',
+ 'bottom',
+ 'left'
+ ]
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderWidth: 8,
+ borderSkipped: [
+ 'bottom',
+ 'bottom',
+ 'left',
+ 'left',
+ 'top',
+ 'right'
+ ]
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderSkipped/indexable.png b/test/fixtures/controller.bar/borderSkipped/indexable.png
new file mode 100644
index 00000000000..64bd848cf62
Binary files /dev/null and b/test/fixtures/controller.bar/borderSkipped/indexable.png differ
diff --git a/test/fixtures/controller.bar/borderSkipped/scriptable.js b/test/fixtures/controller.bar/borderSkipped/scriptable.js
new file mode 100644
index 00000000000..6801d95fab8
--- /dev/null
+++ b/test/fixtures/controller.bar/borderSkipped/scriptable.js
@@ -0,0 +1,60 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderSkipped: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return value > 8 ? 'left'
+ : value > 0 ? 'right'
+ : value > -8 ? 'top'
+ : 'bottom';
+ }
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5]
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderSkipped: function(ctx) {
+ var index = ctx.dataIndex;
+ return index > 4 ? 'left'
+ : index > 3 ? 'right'
+ : index > 1 ? 'top'
+ : 'bottom';
+ },
+ borderWidth: 8
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [
+ {
+ display: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }
+ ]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderSkipped/scriptable.png b/test/fixtures/controller.bar/borderSkipped/scriptable.png
new file mode 100644
index 00000000000..54708387e1e
Binary files /dev/null and b/test/fixtures/controller.bar/borderSkipped/scriptable.png differ
diff --git a/test/fixtures/controller.bar/borderSkipped/value.js b/test/fixtures/controller.bar/borderSkipped/value.js
new file mode 100644
index 00000000000..139a2c68905
--- /dev/null
+++ b/test/fixtures/controller.bar/borderSkipped/value.js
@@ -0,0 +1,51 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, -10, null],
+ borderSkipped: 'top'
+ },
+ {
+ // option in dataset
+ data: [0, 5, -10, null],
+ borderSkipped: 'right'
+ },
+ {
+ // option in dataset
+ data: [0, 5, -10, null],
+ borderSkipped: 'bottom'
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, -10, null],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderSkipped: 'left',
+ borderWidth: 8
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderSkipped/value.png b/test/fixtures/controller.bar/borderSkipped/value.png
new file mode 100644
index 00000000000..56ef05a41fe
Binary files /dev/null and b/test/fixtures/controller.bar/borderSkipped/value.png differ
diff --git a/test/fixtures/controller.bar/borderWidth/indexable.js b/test/fixtures/controller.bar/borderWidth/indexable.js
new file mode 100644
index 00000000000..ddd544ff201
--- /dev/null
+++ b/test/fixtures/controller.bar/borderWidth/indexable.js
@@ -0,0 +1,54 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderWidth: [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5
+ ]
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderWidth: [
+ 5,
+ 4,
+ 3,
+ 2,
+ 1,
+ 0
+ ]
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderWidth/indexable.png b/test/fixtures/controller.bar/borderWidth/indexable.png
new file mode 100644
index 00000000000..30011d3b722
Binary files /dev/null and b/test/fixtures/controller.bar/borderWidth/indexable.png differ
diff --git a/test/fixtures/controller.bar/borderWidth/scriptable.js b/test/fixtures/controller.bar/borderWidth/scriptable.js
new file mode 100644
index 00000000000..40128657749
--- /dev/null
+++ b/test/fixtures/controller.bar/borderWidth/scriptable.js
@@ -0,0 +1,52 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderWidth: function(ctx) {
+ var value = ctx.dataset.data[ctx.dataIndex] || 0;
+ return Math.abs(value);
+ }
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5]
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderWidth: function(ctx) {
+ return ctx.dataIndex * 2;
+ }
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [
+ {
+ display: false,
+ ticks: {
+ beginAtZero: true
+ }
+ }
+ ]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderWidth/scriptable.png b/test/fixtures/controller.bar/borderWidth/scriptable.png
new file mode 100644
index 00000000000..fd8b193460f
Binary files /dev/null and b/test/fixtures/controller.bar/borderWidth/scriptable.png differ
diff --git a/test/fixtures/controller.bar/borderWidth/value.js b/test/fixtures/controller.bar/borderWidth/value.js
new file mode 100644
index 00000000000..33cd40f780e
--- /dev/null
+++ b/test/fixtures/controller.bar/borderWidth/value.js
@@ -0,0 +1,40 @@
+module.exports = {
+ config: {
+ type: 'bar',
+ data: {
+ labels: [0, 1, 2, 3, 4, 5],
+ datasets: [
+ {
+ // option in dataset
+ data: [0, 5, 10, null, -10, -5],
+ borderWidth: 2
+ },
+ {
+ // option in element (fallback)
+ data: [0, 5, 10, null, -10, -5],
+ }
+ ]
+ },
+ options: {
+ legend: false,
+ title: false,
+ elements: {
+ rectangle: {
+ backgroundColor: 'transparent',
+ borderColor: '#888',
+ borderWidth: 4
+ }
+ },
+ scales: {
+ xAxes: [{display: false}],
+ yAxes: [{display: false}]
+ }
+ }
+ },
+ options: {
+ canvas: {
+ height: 256,
+ width: 512
+ }
+ }
+};
diff --git a/test/fixtures/controller.bar/borderWidth/value.png b/test/fixtures/controller.bar/borderWidth/value.png
new file mode 100644
index 00000000000..3c81aff7f2d
Binary files /dev/null and b/test/fixtures/controller.bar/borderWidth/value.png differ