@gitlab/ui 126.3.3 → 126.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -538,6 +538,41 @@ const getTooltipContent = function () {
538
538
  }, {});
539
539
  };
540
540
 
541
+ /**
542
+ * Enriches tooltip parameters with stack information for proper series ordering.
543
+ *
544
+ * In stacked column charts, series are grouped by their `stack` property to determine
545
+ * visual stacking and tooltip display order. ECharts doesn't provide stack data
546
+ * in tooltip params by default, so this function manually adds it by mapping
547
+ * series names to their configured stack values.
548
+ *
549
+ * @param {Object} params - Tooltip parameters from ECharts
550
+ * @param {Object} options - Chart configuration with series definitions
551
+ * @returns {Object} Enhanced tooltip parameters with stack data
552
+ */
553
+ const getTooltipParams = function () {
554
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
555
+ let options = arguments.length > 1 ? arguments[1] : undefined;
556
+ if (!params) return null;
557
+ const {
558
+ series: optionsSeries = []
559
+ } = options !== null && options !== void 0 ? options : {};
560
+ const seriesStacks = Object.fromEntries(optionsSeries.map(_ref8 => {
561
+ let {
562
+ name,
563
+ stack
564
+ } = _ref8;
565
+ return [name, stack];
566
+ }));
567
+ return {
568
+ ...params,
569
+ seriesData: params.seriesData.map(series => ({
570
+ ...series,
571
+ stack: seriesStacks[series.seriesName]
572
+ }))
573
+ };
574
+ };
575
+
541
576
  /**
542
577
  * The method works well if tooltip content should be against y-axis values.
543
578
  * However, for bar charts, the tooltip should be against x-axis values.
@@ -579,4 +614,4 @@ const getDefaultTooltipContent = function (params) {
579
614
  };
580
615
  };
581
616
 
582
- export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultChartOptions, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, getTooltipAxisConfig, getTooltipContent, getTooltipTitle, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, toolboxHeight, validRenderers, xAxis, yAxis };
617
+ export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultChartOptions, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, getTooltipAxisConfig, getTooltipContent, getTooltipParams, getTooltipTitle, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, toolboxHeight, validRenderers, xAxis, yAxis };
@@ -112,6 +112,23 @@ const mockDefaultStackedBarData = [{
112
112
  name: 'Fun 4',
113
113
  data: [8, 9, 5, 40, 13, 19, 58, 21, 47, 59, 23, 46]
114
114
  }];
115
+ const mockMultiStackBarData = [{
116
+ name: 'Fun 1',
117
+ data: [58, 49, 38, 23, 27, 68, 38, 35, 7, 64, 65, 31],
118
+ stack: 'stack-1'
119
+ }, {
120
+ name: 'Fun 2',
121
+ data: [8, 6, 34, 19, 9, 7, 17, 25, 14, 7, 10, 32],
122
+ stack: 'stack-1'
123
+ }, {
124
+ name: 'Fun 3',
125
+ data: [67, 60, 66, 32, 61, 54, 13, 50, 16, 11, 47, 28],
126
+ stack: 'stack-2'
127
+ }, {
128
+ name: 'Fun 4',
129
+ data: [8, 9, 5, 40, 13, 19, 58, 21, 47, 59, 23, 46],
130
+ stack: 'stack-2'
131
+ }];
115
132
  const mockDefaultStackedLineData = [{
116
133
  name: 'Stacked median line',
117
134
  data: [67, 60, 66, 32, 61, 54, 13, 50, 16, 11, 47, 28]
@@ -171,4 +188,4 @@ const mockSecondaryTrendlineData = [{
171
188
  data: [['Joe', 220], ['Sarah', 392], ['Tom', 291], ['Mary', 594], ['Mike', 320], ['Ben', 230], ['Jane', 120], ['Anne', 290]]
172
189
  }];
173
190
 
174
- export { mockAnnotationsConfigs, mockAnnotationsSeries, mockDefaultBarChartConfig, mockDefaultBarData, mockDefaultDataZoomConfig, mockDefaultLineChartConfig, mockDefaultLineData, mockDefaultStackedBarData, mockDefaultStackedLineData, mockRawBarData, mockSecondaryBarData, mockSecondaryData, mockSecondaryTrendlineData };
191
+ export { mockAnnotationsConfigs, mockAnnotationsSeries, mockDefaultBarChartConfig, mockDefaultBarData, mockDefaultDataZoomConfig, mockDefaultLineChartConfig, mockDefaultLineData, mockDefaultStackedBarData, mockDefaultStackedLineData, mockMultiStackBarData, mockRawBarData, mockSecondaryBarData, mockSecondaryData, mockSecondaryTrendlineData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "126.3.3",
3
+ "version": "126.3.4",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -159,7 +159,7 @@
159
159
  "rollup-plugin-string": "^3.0.0",
160
160
  "rollup-plugin-svg": "^2.0.0",
161
161
  "rollup-plugin-vue": "^5.1.9",
162
- "sass": "^1.94.2",
162
+ "sass": "^1.95.0",
163
163
  "sass-loader": "^10.5.2",
164
164
  "sass-true": "^9",
165
165
  "start-server-and-test": "^2.1.3",
@@ -146,7 +146,7 @@
146
146
  }
147
147
 
148
148
  &:hover {
149
- .gl-new-dropdown-item-content {
149
+ .gl-new-dropdown-item-content:not(:disabled):not(.disabled) {
150
150
  color: var(--gl-action-danger-foreground-color-hover);
151
151
  background-color: var(--gl-action-danger-background-color-hover);
152
152
  }
@@ -9,6 +9,7 @@ import {
9
9
  getTooltipTitle,
10
10
  getTooltipContent,
11
11
  getTooltipAxisConfig,
12
+ getTooltipParams,
12
13
  } from '../../../../utils/charts/config';
13
14
 
14
15
  import TooltipDefaultFormat from './tooltip_default_format/tooltip_default_format.vue';
@@ -242,7 +243,7 @@ export default {
242
243
 
243
244
  this.title = getTooltipTitle(params, titleAxisName, dimensionIndex);
244
245
  this.content = getTooltipContent(params, valueAxisName, metricIndex);
245
- this.params = params;
246
+ this.params = getTooltipParams(params, options);
246
247
  },
247
248
  },
248
249
  },
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import merge from 'lodash/merge';
3
+ import groupBy from 'lodash/groupBy';
3
4
  import {
4
5
  defaultChartOptions,
5
6
  grid,
@@ -310,12 +311,22 @@ export default {
310
311
  getTooltipContent({ params }) {
311
312
  if (!params) return {};
312
313
 
313
- const tooltipContentEntries = params.seriesData
314
- .toSorted((a, b) => b.seriesIndex - a.seriesIndex) // Invert stacking order so it matches chart (see https://github.com/apache/echarts/issues/14700)
315
- .map(({ seriesName = '', value, borderColor }) => [
314
+ // Group by stack and invert order within so it matches `stacked` presentation (see https://github.com/apache/echarts/issues/14700).
315
+ const seriesDataGroupedByStack = groupBy(
316
+ params.seriesData,
317
+ ({ stack, seriesIndex }) => stack ?? seriesIndex,
318
+ );
319
+
320
+ const sortedSeriesData = Object.values(seriesDataGroupedByStack).flatMap((seriesDataStack) =>
321
+ seriesDataStack.toSorted((a, b) => b.seriesIndex - a.seriesIndex),
322
+ );
323
+
324
+ const tooltipContentEntries = sortedSeriesData.map(
325
+ ({ seriesName = '', value, borderColor, color }) => [
316
326
  seriesName,
317
- { value, color: borderColor },
318
- ]);
327
+ { value, color: borderColor ?? color },
328
+ ],
329
+ );
319
330
 
320
331
  return Object.fromEntries(tooltipContentEntries);
321
332
  },
@@ -486,6 +486,34 @@ export const getTooltipContent = (params = null, valueAxisName = null, metricInd
486
486
  }, {});
487
487
  };
488
488
 
489
+ /**
490
+ * Enriches tooltip parameters with stack information for proper series ordering.
491
+ *
492
+ * In stacked column charts, series are grouped by their `stack` property to determine
493
+ * visual stacking and tooltip display order. ECharts doesn't provide stack data
494
+ * in tooltip params by default, so this function manually adds it by mapping
495
+ * series names to their configured stack values.
496
+ *
497
+ * @param {Object} params - Tooltip parameters from ECharts
498
+ * @param {Object} options - Chart configuration with series definitions
499
+ * @returns {Object} Enhanced tooltip parameters with stack data
500
+ */
501
+ export const getTooltipParams = (params = null, options) => {
502
+ if (!params) return null;
503
+
504
+ const { series: optionsSeries = [] } = options ?? {};
505
+
506
+ const seriesStacks = Object.fromEntries(optionsSeries.map(({ name, stack }) => [name, stack]));
507
+
508
+ return {
509
+ ...params,
510
+ seriesData: params.seriesData.map((series) => ({
511
+ ...series,
512
+ stack: seriesStacks[series.seriesName],
513
+ })),
514
+ };
515
+ };
516
+
489
517
  /**
490
518
  * The method works well if tooltip content should be against y-axis values.
491
519
  * However, for bar charts, the tooltip should be against x-axis values.
@@ -106,6 +106,13 @@ export const mockDefaultStackedBarData = [
106
106
  { name: 'Fun 4', data: [8, 9, 5, 40, 13, 19, 58, 21, 47, 59, 23, 46] },
107
107
  ];
108
108
 
109
+ export const mockMultiStackBarData = [
110
+ { name: 'Fun 1', data: [58, 49, 38, 23, 27, 68, 38, 35, 7, 64, 65, 31], stack: 'stack-1' },
111
+ { name: 'Fun 2', data: [8, 6, 34, 19, 9, 7, 17, 25, 14, 7, 10, 32], stack: 'stack-1' },
112
+ { name: 'Fun 3', data: [67, 60, 66, 32, 61, 54, 13, 50, 16, 11, 47, 28], stack: 'stack-2' },
113
+ { name: 'Fun 4', data: [8, 9, 5, 40, 13, 19, 58, 21, 47, 59, 23, 46], stack: 'stack-2' },
114
+ ];
115
+
109
116
  export const mockDefaultStackedLineData = [
110
117
  { name: 'Stacked median line', data: [67, 60, 66, 32, 61, 54, 13, 50, 16, 11, 47, 28] },
111
118
  ];