From: Evert Timberg Date: Sun, 27 Oct 2019 19:11:33 +0000 (-0400) Subject: Release v2.9.1 (#6618) X-Git-Tag: v2.9.1~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a92dd7b97fb6adef4ae9b5b8f86e37dc9be854df;p=thirdparty%2FChart.js.git Release v2.9.1 (#6618) Release v2.9.1 --- diff --git a/docs/general/README.md b/docs/general/README.md index 950188ff1..fc4821d31 100644 --- a/docs/general/README.md +++ b/docs/general/README.md @@ -8,3 +8,4 @@ These sections describe general configuration options that can apply elsewhere i * [Options](./options.md) scriptable and indexable options syntax. * [Colors](./colors.md) defines acceptable color values. * [Font](./fonts.md) defines various font options. +* [Performance](./performance.md) gives tips for performance-sensitive applications. diff --git a/package.json b/package.json index 1550d567a..782dc972f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "chart.js", "homepage": "https://www.chartjs.org", "description": "Simple HTML5 charts using the canvas element.", - "version": "2.9.0", + "version": "2.9.1", "license": "MIT", "jsdelivr": "dist/Chart.min.js", "unpkg": "dist/Chart.min.js", diff --git a/src/controllers/controller.horizontalBar.js b/src/controllers/controller.horizontalBar.js index ebfc6d84a..7b11bcc66 100644 --- a/src/controllers/controller.horizontalBar.js +++ b/src/controllers/controller.horizontalBar.js @@ -18,8 +18,6 @@ defaults._set('horizontalBar', { yAxes: [{ type: 'category', position: 'left', - categoryPercentage: 0.8, - barPercentage: 0.9, offset: true, gridLines: { offsetGridLines: true @@ -39,6 +37,15 @@ defaults._set('horizontalBar', { } }); +defaults._set('global', { + datasets: { + horizontalBar: { + categoryPercentage: 0.8, + barPercentage: 0.9 + } + } +}); + module.exports = BarController.extend({ /** * @private @@ -54,4 +61,3 @@ module.exports = BarController.extend({ return this.getMeta().yAxisID; } }); - diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index dc1fc689b..47adc0801 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -209,8 +209,9 @@ module.exports = DatasetController.extend({ if (rightValue < 0) { return yScale.getPixelForValue(sumNeg + rightValue); } + return yScale.getPixelForValue(sumPos + rightValue); } - return yScale.getPixelForValue(sumPos + rightValue); + return yScale.getPixelForValue(value); }, updateBezierControlPoints: function() { diff --git a/src/core/core.scale.js b/src/core/core.scale.js index f292bd2c2..914bdefaa 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -929,7 +929,7 @@ var Scale = Element.extend({ getDecimalForPixel: function(pixel) { var decimal = (pixel - this._startPixel) / this._length; - return Math.min(1, Math.max(0, this._reversePixels ? 1 - decimal : decimal)); + return this._reversePixels ? 1 - decimal : decimal; }, /** diff --git a/test/fixtures/controller.bar/bar-thickness-absolute.json b/test/fixtures/controller.bar/bar-thickness-absolute.json index 58b6e1132..4c5ed5339 100644 --- a/test/fixtures/controller.bar/bar-thickness-absolute.json +++ b/test/fixtures/controller.bar/bar-thickness-absolute.json @@ -5,6 +5,9 @@ "labels": ["2017", "2018", "2019", "2024", "2025"], "datasets": [{ "backgroundColor": "rgba(255, 99, 132, 0.5)", + "barPercentage": 1, + "categoryPercentage": 1, + "barThickness": 128, "data": [1, null, 3, 4, 5] }] }, @@ -17,9 +20,6 @@ "type": "time", "offset": true, "display": false, - "barPercentage": 1, - "categoryPercentage": 1, - "barThickness": 128, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-flex-offset.json b/test/fixtures/controller.bar/bar-thickness-flex-offset.json index 6b0829dd5..6672516e4 100644 --- a/test/fixtures/controller.bar/bar-thickness-flex-offset.json +++ b/test/fixtures/controller.bar/bar-thickness-flex-offset.json @@ -5,6 +5,9 @@ "labels": ["2017", "2018", "2020", "2024", "2038"], "datasets": [{ "backgroundColor": "#FF6384", + "barPercentage": 1, + "categoryPercentage": 1, + "barThickness": "flex", "data": [1, null, 3, 4, 5] }] }, @@ -17,9 +20,6 @@ "type": "time", "offset": true, "display": false, - "barPercentage": 1, - "categoryPercentage": 1, - "barThickness": "flex", "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-flex-single-reverse.json b/test/fixtures/controller.bar/bar-thickness-flex-single-reverse.json index 6f63ca934..e6d123736 100644 --- a/test/fixtures/controller.bar/bar-thickness-flex-single-reverse.json +++ b/test/fixtures/controller.bar/bar-thickness-flex-single-reverse.json @@ -5,6 +5,9 @@ "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ "backgroundColor": "#FF6384", + "barThickness": "flex", + "barPercentage": 1, + "categoryPercentage": 1, "data": [1] }] }, @@ -16,9 +19,6 @@ "xAxes": [{ "type": "time", "display": false, - "barThickness": "flex", - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-flex-single.json b/test/fixtures/controller.bar/bar-thickness-flex-single.json index f523f4f5f..a59b2aff8 100644 --- a/test/fixtures/controller.bar/bar-thickness-flex-single.json +++ b/test/fixtures/controller.bar/bar-thickness-flex-single.json @@ -5,6 +5,9 @@ "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ "backgroundColor": "#FF6384", + "barThickness": "flex", + "barPercentage": 1, + "categoryPercentage": 1, "data": [1] }] }, @@ -16,9 +19,6 @@ "xAxes": [{ "type": "time", "display": false, - "barThickness": "flex", - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-flex.json b/test/fixtures/controller.bar/bar-thickness-flex.json index c800a0af0..b9048faed 100644 --- a/test/fixtures/controller.bar/bar-thickness-flex.json +++ b/test/fixtures/controller.bar/bar-thickness-flex.json @@ -5,6 +5,9 @@ "labels": ["2017", "2018", "2020", "2024", "2038"], "datasets": [{ "backgroundColor": "#FF6384", + "barPercentage": 1, + "categoryPercentage": 1, + "barThickness": "flex", "data": [1, null, 3, 4, 5] }] }, @@ -16,9 +19,6 @@ "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, - "barThickness": "flex", "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-max.json b/test/fixtures/controller.bar/bar-thickness-max.json index 3430b8c93..2ca185516 100644 --- a/test/fixtures/controller.bar/bar-thickness-max.json +++ b/test/fixtures/controller.bar/bar-thickness-max.json @@ -5,6 +5,9 @@ "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ "backgroundColor": "#FF6384", + "barPercentage": 1, + "categoryPercentage": 1, + "maxBarThickness": 8, "data": [1, null, 3, 4, 5] }] }, @@ -16,9 +19,6 @@ "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, - "maxBarThickness": 8, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-min-interval.json b/test/fixtures/controller.bar/bar-thickness-min-interval.json index 41fd8676a..954e15cfd 100644 --- a/test/fixtures/controller.bar/bar-thickness-min-interval.json +++ b/test/fixtures/controller.bar/bar-thickness-min-interval.json @@ -5,6 +5,8 @@ "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ "backgroundColor": "#FF6384", + "barPercentage": 1, + "categoryPercentage": 1, "data": [1, null, 3, 4, 5] }] }, @@ -16,8 +18,6 @@ "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-multiple.json b/test/fixtures/controller.bar/bar-thickness-multiple.json index 3dcddaff0..f26a395fb 100644 --- a/test/fixtures/controller.bar/bar-thickness-multiple.json +++ b/test/fixtures/controller.bar/bar-thickness-multiple.json @@ -18,12 +18,16 @@ "responsive": false, "legend": false, "title": false, + "datasets": { + "bar": { + "barPercentage": 1, + "categoryPercentage": 1 + } + }, "scales": { "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-no-overlap.json b/test/fixtures/controller.bar/bar-thickness-no-overlap.json index 9b06e5127..2bfee4436 100644 --- a/test/fixtures/controller.bar/bar-thickness-no-overlap.json +++ b/test/fixtures/controller.bar/bar-thickness-no-overlap.json @@ -18,12 +18,16 @@ "responsive": false, "legend": false, "title": false, + "datasets": { + "bar": { + "barPercentage": 1, + "categoryPercentage": 1 + } + }, "scales": { "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY-MM" }, diff --git a/test/fixtures/controller.bar/bar-thickness-offset.json b/test/fixtures/controller.bar/bar-thickness-offset.json index 78ff4e2dd..878556957 100644 --- a/test/fixtures/controller.bar/bar-thickness-offset.json +++ b/test/fixtures/controller.bar/bar-thickness-offset.json @@ -18,13 +18,17 @@ "responsive": false, "legend": false, "title": false, + "datasets": { + "bar": { + "barPercentage": 1, + "categoryPercentage": 1 + } + }, "scales": { "xAxes": [{ "type": "time", "offset": true, "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-reverse.json b/test/fixtures/controller.bar/bar-thickness-reverse.json index 5e868370f..215858dd8 100644 --- a/test/fixtures/controller.bar/bar-thickness-reverse.json +++ b/test/fixtures/controller.bar/bar-thickness-reverse.json @@ -18,12 +18,16 @@ "responsive": false, "legend": false, "title": false, + "datasets": { + "bar": { + "barPercentage": 1, + "categoryPercentage": 1 + } + }, "scales": { "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-single-xy.json b/test/fixtures/controller.bar/bar-thickness-single-xy.json index 20446e808..68a99a908 100644 --- a/test/fixtures/controller.bar/bar-thickness-single-xy.json +++ b/test/fixtures/controller.bar/bar-thickness-single-xy.json @@ -4,6 +4,8 @@ "data": { "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ + "barPercentage": 1, + "categoryPercentage": 1, "backgroundColor": "#FF6384", "data": [{"x": "2022", "y": 42}] }] @@ -16,8 +18,6 @@ "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-single.json b/test/fixtures/controller.bar/bar-thickness-single.json index 59e5fcb9a..1b6565ed0 100644 --- a/test/fixtures/controller.bar/bar-thickness-single.json +++ b/test/fixtures/controller.bar/bar-thickness-single.json @@ -4,6 +4,8 @@ "data": { "labels": ["2016", "2018", "2020", "2024", "2030"], "datasets": [{ + "barPercentage": 1, + "categoryPercentage": 1, "backgroundColor": "#FF6384", "data": [1] }] @@ -16,8 +18,6 @@ "xAxes": [{ "type": "time", "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.bar/bar-thickness-stacked.json b/test/fixtures/controller.bar/bar-thickness-stacked.json index effb2f4fb..3c9f01c28 100644 --- a/test/fixtures/controller.bar/bar-thickness-stacked.json +++ b/test/fixtures/controller.bar/bar-thickness-stacked.json @@ -18,13 +18,17 @@ "responsive": false, "legend": false, "title": false, + "datasets": { + "bar": { + "barPercentage": 1, + "categoryPercentage": 1 + } + }, "scales": { "xAxes": [{ "type": "time", "stacked": true, "display": false, - "barPercentage": 1, - "categoryPercentage": 1, "time": { "parser": "YYYY" }, diff --git a/test/fixtures/controller.line/non-numeric-y.json b/test/fixtures/controller.line/non-numeric-y.json new file mode 100644 index 000000000..db5f3c381 --- /dev/null +++ b/test/fixtures/controller.line/non-numeric-y.json @@ -0,0 +1,34 @@ +{ + "config": { + "type": "line", + "data": { + "xLabels": ["January", "February", "March", "April", "May", "June", "July"], + "yLabels": ["", "Request Added", "Request Viewed", "Request Accepted", "Request Solved", "Solving Confirmed"], + "datasets": [{ + "label": "My First dataset", + "data": ["", "Request Added", "Request Added", "Request Added", "Request Viewed", "Request Viewed", "Request Viewed"], + "fill": false, + "borderColor": "red", + "backgroundColor": "red" + }] + }, + "options": { + "responsive": false, + "legend": false, + "title": false, + "scales": { + "xAxes": [{"display": false}], + "yAxes": [{ + "type": "category", + "display": false + }] + } + } + }, + "options": { + "canvas": { + "height": 256, + "width": 512 + } + } +} diff --git a/test/fixtures/controller.line/non-numeric-y.png b/test/fixtures/controller.line/non-numeric-y.png new file mode 100644 index 000000000..5ebecd597 Binary files /dev/null and b/test/fixtures/controller.line/non-numeric-y.png differ diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 3874c3325..49b586fd8 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1214,12 +1214,16 @@ describe('Chart.controllers.bar', function() { options: { legend: false, title: false, + datasets: { + bar: { + barPercentage: 1, + } + }, scales: { xAxes: [{ type: 'category', display: false, stacked: true, - barPercentage: 1, }], yAxes: [{ type: 'logarithmic', @@ -1275,12 +1279,16 @@ describe('Chart.controllers.bar', function() { options: { legend: false, title: false, + datasets: { + bar: { + barPercentage: 1, + } + }, scales: { xAxes: [{ type: 'category', display: false, stacked: true, - barPercentage: 1, }], yAxes: [{ type: 'logarithmic', @@ -1593,8 +1601,9 @@ describe('Chart.controllers.bar', function() { var meta = chart.getDatasetMeta(0); var yScale = chart.scales[meta.yAxisID]; - var categoryPercentage = yScale.options.categoryPercentage; - var barPercentage = yScale.options.barPercentage; + var config = meta.controller._config; + var categoryPercentage = config.categoryPercentage; + var barPercentage = config.barPercentage; var stacked = yScale.options.stacked; var totalBarHeight = 0; @@ -1669,11 +1678,15 @@ describe('Chart.controllers.bar', function() { options: { legend: false, title: false, + datasets: { + bar: { + barThickness: barThickness + } + }, scales: { xAxes: [{ id: 'x', type: 'category', - barThickness: barThickness }], yAxes: [{ type: 'linear',