From: Jukka Kurkela Date: Sat, 19 Jun 2021 22:28:05 +0000 (+0300) Subject: Bar: ignore not-grouped bars from group bar count (#9291) X-Git-Tag: v3.4.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba5ebceca802c98dbdfea7ed4967cea24b294e04;p=thirdparty%2FChart.js.git Bar: ignore not-grouped bars from group bar count (#9291) --- diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index cf08851f3..9a568cdeb 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -324,6 +324,10 @@ export default class BarController extends DatasetController { for (i = 0; i < ilen; ++i) { item = metasets[i]; + if (!item.controller.options.grouped) { + continue; + } + if (typeof dataIndex !== 'undefined') { const val = item.controller.getParsed(dataIndex)[ item.controller._cachedMeta.vScale.axis diff --git a/test/fixtures/controller.bar/not-grouped/mixed.js b/test/fixtures/controller.bar/not-grouped/mixed.js new file mode 100644 index 000000000..750595312 --- /dev/null +++ b/test/fixtures/controller.bar/not-grouped/mixed.js @@ -0,0 +1,35 @@ +module.exports = { + description: 'https://github.com/chartjs/Chart.js/issues/9281', + config: { + type: 'bar', + data: { + labels: [0, 1, 2], + datasets: [ + { + label: 'data 1', + data: [1, 2, 2], + backgroundColor: 'rgb(255,0,0,0.7)', + grouped: true + }, + { + label: 'data 2', + data: [4, 4, 1], + backgroundColor: 'rgb(0,255,0,0.7)', + grouped: true + }, + { + label: 'data 3', + data: [2, 1, 3], + backgroundColor: 'rgb(0,0,255,0.7)', + grouped: false + } + ] + }, + options: { + scales: { + x: {display: false}, + y: {display: false} + } + } + }, +}; diff --git a/test/fixtures/controller.bar/not-grouped/mixed.png b/test/fixtures/controller.bar/not-grouped/mixed.png new file mode 100644 index 000000000..af2c9fda2 Binary files /dev/null and b/test/fixtures/controller.bar/not-grouped/mixed.png differ