From a92dd7b97fb6adef4ae9b5b8f86e37dc9be854df Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 27 Oct 2019 15:11:33 -0400 Subject: [PATCH] Release v2.9.1 (#6618) Release v2.9.1 --- docs/general/README.md | 1 + package.json | 2 +- src/controllers/controller.horizontalBar.js | 12 +++++-- src/controllers/controller.line.js | 3 +- src/core/core.scale.js | 2 +- .../bar-thickness-absolute.json | 6 ++-- .../bar-thickness-flex-offset.json | 6 ++-- .../bar-thickness-flex-single-reverse.json | 6 ++-- .../bar-thickness-flex-single.json | 6 ++-- .../controller.bar/bar-thickness-flex.json | 6 ++-- .../controller.bar/bar-thickness-max.json | 6 ++-- .../bar-thickness-min-interval.json | 4 +-- .../bar-thickness-multiple.json | 8 +++-- .../bar-thickness-no-overlap.json | 8 +++-- .../controller.bar/bar-thickness-offset.json | 8 +++-- .../controller.bar/bar-thickness-reverse.json | 8 +++-- .../bar-thickness-single-xy.json | 4 +-- .../controller.bar/bar-thickness-single.json | 4 +-- .../controller.bar/bar-thickness-stacked.json | 8 +++-- .../controller.line/non-numeric-y.json | 34 ++++++++++++++++++ .../controller.line/non-numeric-y.png | Bin 0 -> 3702 bytes test/specs/controller.bar.tests.js | 23 +++++++++--- 22 files changed, 120 insertions(+), 45 deletions(-) create mode 100644 test/fixtures/controller.line/non-numeric-y.json create mode 100644 test/fixtures/controller.line/non-numeric-y.png diff --git a/docs/general/README.md b/docs/general/README.md index 950188ff1d5..fc4821d31f1 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 1550d567a37..782dc972f2d 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 ebfc6d84ae1..7b11bcc6627 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 dc1fc689b24..47adc08010c 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 f292bd2c2e5..914bdefaae1 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 58b6e113244..4c5ed53391d 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 6b0829dd561..6672516e472 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 6f63ca93468..e6d12373666 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 f523f4f5fc6..a59b2aff802 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 c800a0af067..b9048faed0a 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 3430b8c9390..2ca185516bc 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 41fd8676a45..954e15cfdf6 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 3dcddaff0e7..f26a395fb4d 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 9b06e512718..2bfee4436c6 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 78ff4e2dd9c..8785569570b 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 5e868370f75..215858dd8b7 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 20446e80887..68a99a90853 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 59e5fcb9a90..1b6565ed0a2 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 effb2f4fb71..3c9f01c2867 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 00000000000..db5f3c38180 --- /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 0000000000000000000000000000000000000000..5ebecd597b5c127faf76dae0837ed9a3a4eae94d GIT binary patch literal 3702 zcmeH~`Ck)f8o&ocMW|s}4-^TkZW*y6poByS;?@I7WdO@o5jjLCM+t{PNRSA)m1Qdm z)#-XnIJKHu0tA#mfI>7PomC0Q5kf)$nG%#75L8gEodErL|AC!f=KVaM=Y5}Z-tRNt z`}=yWHL)}S0AQ{67l*zA07HCf02r^rUoAhhMFRj~pZB59|IRE>_osIyzAIQg&NyB^ zy2ldTwXI72lHTm#Y`f>XGpN&(lHjLv)lP!4%_Muz$DclRx*~i0$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.bar.tests.js b/test/specs/controller.bar.tests.js index 3874c3325df..49b586fd81e 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',