* Returns the grouped metasets of the given type on the index scale, in sorted order. * A hidden metaset is kept when its stack still has visible bars, so that it holds the * position of that stack: hiding a dataset must not reorder the stacks. * @private
(chart: Chart, iScale: BarScale, type: string, hasBar: (meta: BarMeta) => boolean)
| 101 | * @private |
| 102 | */ |
| 103 | function getGroupedMetas(chart: Chart, iScale: BarScale, type: string, hasBar: (meta: BarMeta) => boolean): BarMeta[] { |
| 104 | const axisID = iScale.axis + 'AxisID'; |
| 105 | // @ts-expect-error `_getSortedDatasetMetas` is `@private` in core.controller.js, which tsc reads as `private` |
| 106 | const metasets: BarMeta[] = chart._getSortedDatasetMetas() |
| 107 | .filter(meta => meta[axisID] === iScale.id && meta.type === type && meta.controller.options.grouped); |
| 108 | |
| 109 | if (iScale.options.stacked === false) { |
| 110 | return metasets.filter(meta => meta.visible); |
| 111 | } |
| 112 | if (metasets.every(meta => meta.visible)) { |
| 113 | return metasets; |
| 114 | } |
| 115 | |
| 116 | const visibleStacks = new Set(metasets.filter(meta => meta.visible && hasBar(meta)).map(meta => meta.stack)); |
| 117 | return metasets.filter(meta => meta.visible || (meta.stack !== undefined && visibleStacks.has(meta.stack))); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Returns the first parsed item of the meta whose index-axis value is `value`. |
no test coverage detected