@gitlab/ui 122.3.0 → 122.5.0
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.
- package/dist/components/charts/bar/bar.js +3 -58
- package/dist/components/charts/shared/tooltip/tooltip.js +26 -7
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/utils/charts/config.js +26 -7
- package/package.json +7 -7
- package/src/components/base/alert/alert.scss +2 -2
- package/src/components/base/avatar/avatar.scss +18 -18
- package/src/components/base/banner/banner.scss +1 -1
- package/src/components/base/drawer/drawer.scss +2 -2
- package/src/components/base/form/form_input/form_input.scss +1 -1
- package/src/components/base/form/form_select/form_select.scss +1 -1
- package/src/components/charts/bar/bar.vue +14 -55
- package/src/components/charts/shared/tooltip/tooltip.vue +29 -6
- package/src/components/utilities/truncate_text/truncate_text.scss +1 -1
- package/src/scss/mixins.scss +71 -0
- package/src/utils/charts/config.js +22 -11
- package/src/vendor/bootstrap/scss/mixins/_breakpoints.scss +0 -21
- package/src/components/regions/dashboard_skeleton/dashboard_skeleton.md +0 -4
|
@@ -468,24 +468,44 @@ const generateLineSeries = _ref5 => {
|
|
|
468
468
|
}
|
|
469
469
|
};
|
|
470
470
|
};
|
|
471
|
+
const getTooltipAxisConfig = dimensionAxis => {
|
|
472
|
+
if (!['xAxis', 'yAxis'].includes(dimensionAxis)) {
|
|
473
|
+
throw new Error(`\`dimensionAxis\` must be "xAxis" or "yAxis", received ${dimensionAxis}`);
|
|
474
|
+
}
|
|
475
|
+
if (dimensionAxis === 'xAxis') {
|
|
476
|
+
return {
|
|
477
|
+
dimensionIndex: 0,
|
|
478
|
+
metricIndex: 1,
|
|
479
|
+
valueAxis: 'yAxis'
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
dimensionIndex: 1,
|
|
484
|
+
metricIndex: 0,
|
|
485
|
+
valueAxis: 'xAxis'
|
|
486
|
+
};
|
|
487
|
+
};
|
|
471
488
|
const getTooltipTitle = function () {
|
|
472
489
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
473
490
|
let titleAxisName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
491
|
+
let dimensionIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
474
492
|
if (!params) return '';
|
|
475
493
|
const title = params.seriesData.reduce((acc, _ref6) => {
|
|
476
494
|
let {
|
|
477
495
|
value
|
|
478
496
|
} = _ref6;
|
|
479
|
-
|
|
497
|
+
const dimension = value[dimensionIndex];
|
|
498
|
+
if (acc.includes(dimension)) {
|
|
480
499
|
return acc;
|
|
481
500
|
}
|
|
482
|
-
return [...acc,
|
|
501
|
+
return [...acc, dimension];
|
|
483
502
|
}, []).join(', ');
|
|
484
503
|
return titleAxisName ? `${title} (${titleAxisName})` : title;
|
|
485
504
|
};
|
|
486
505
|
const getTooltipContent = function () {
|
|
487
506
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
488
507
|
let valueAxisName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
508
|
+
let metricIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
489
509
|
if (!params) {
|
|
490
510
|
return {};
|
|
491
511
|
}
|
|
@@ -494,12 +514,12 @@ const getTooltipContent = function () {
|
|
|
494
514
|
} = params;
|
|
495
515
|
if (seriesData.length === 1) {
|
|
496
516
|
const {
|
|
497
|
-
value
|
|
517
|
+
value,
|
|
498
518
|
seriesName
|
|
499
519
|
} = seriesData[0];
|
|
500
520
|
return {
|
|
501
521
|
[valueAxisName || seriesName]: {
|
|
502
|
-
value:
|
|
522
|
+
value: value[metricIndex],
|
|
503
523
|
color: '' // ignore color when showing a single series
|
|
504
524
|
}
|
|
505
525
|
};
|
|
@@ -510,9 +530,8 @@ const getTooltipContent = function () {
|
|
|
510
530
|
seriesName,
|
|
511
531
|
color
|
|
512
532
|
} = _ref7;
|
|
513
|
-
const yValue = value[1];
|
|
514
533
|
acc[seriesName] = {
|
|
515
|
-
value:
|
|
534
|
+
value: value[metricIndex],
|
|
516
535
|
color
|
|
517
536
|
};
|
|
518
537
|
return acc;
|
|
@@ -560,4 +579,4 @@ const getDefaultTooltipContent = function (params) {
|
|
|
560
579
|
};
|
|
561
580
|
};
|
|
562
581
|
|
|
563
|
-
export { annotationsYAxisCoords, axes, dataZoomAdjustments, defaultAreaOpacity, defaultChartOptions, defaultFontSize, defaultHeight, defaultWidth, generateAnnotationSeries, generateBarSeries, generateLineSeries, getAnnotationsConfig, getDataZoomConfig, getDefaultTooltipContent, getThresholdConfig, getTooltipContent, getTooltipTitle, grid, gridWithSecondaryYAxis, lineStyle, mergeAnnotationAxisToOptions, mergeSeriesToOptions, parseAnnotations, symbolSize, toolboxHeight, validRenderers, xAxis, yAxis };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "122.
|
|
3
|
+
"version": "122.5.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"rollup-plugin-vue/@vue/component-compiler/postcss-modules-sync/generic-names/loader-utils": "3.3.1"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@babel/core": "^7.28.
|
|
99
|
+
"@babel/core": "^7.28.4",
|
|
100
100
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
101
101
|
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
|
102
102
|
"@babel/preset-env": "^7.28.3",
|
|
@@ -122,9 +122,9 @@
|
|
|
122
122
|
"@storybook/vue3": "^7.6.20",
|
|
123
123
|
"@storybook/vue3-webpack5": "^7.6.20",
|
|
124
124
|
"@types/jest-image-snapshot": "^6.4.0",
|
|
125
|
-
"@vue/compat": "^3.5.
|
|
126
|
-
"@vue/compiler-sfc": "^3.5.
|
|
127
|
-
"@vue/server-renderer": "^3.5.
|
|
125
|
+
"@vue/compat": "^3.5.21",
|
|
126
|
+
"@vue/compiler-sfc": "^3.5.21",
|
|
127
|
+
"@vue/server-renderer": "^3.5.21",
|
|
128
128
|
"@vue/test-utils": "1.3.6",
|
|
129
129
|
"@vue/test-utils-vue3": "npm:@vue/test-utils@^2.4.6",
|
|
130
130
|
"@vue/vue2-jest": "29.2.6",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"axe-playwright": "^2.1.0",
|
|
137
137
|
"babel-loader": "^9.2.1",
|
|
138
138
|
"cypress": "14.5.4",
|
|
139
|
-
"cypress-real-events": "^1.
|
|
139
|
+
"cypress-real-events": "^1.15.0",
|
|
140
140
|
"dompurify": "^3.1.2",
|
|
141
141
|
"emoji-regex": "^10.5.0",
|
|
142
142
|
"esbuild": "^0.25.9",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"rollup-plugin-string": "^3.0.0",
|
|
166
166
|
"rollup-plugin-svg": "^2.0.0",
|
|
167
167
|
"rollup-plugin-vue": "^5.1.9",
|
|
168
|
-
"sass": "^1.92.
|
|
168
|
+
"sass": "^1.92.1",
|
|
169
169
|
"sass-loader": "^10.5.2",
|
|
170
170
|
"sass-true": "^9",
|
|
171
171
|
"start-server-and-test": "^2.1.0",
|
|
@@ -101,7 +101,7 @@ $gl-alert-top-border-size: 2px;
|
|
|
101
101
|
.gl-alert-actions {
|
|
102
102
|
@apply gl-flex gl-flex-col gl-flex-wrap gl-gap-y-3;
|
|
103
103
|
@apply gl-mt-3;
|
|
104
|
-
@include gl-
|
|
104
|
+
@include gl-container-width-up(sm) {
|
|
105
105
|
@apply gl-flex-row;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -110,7 +110,7 @@ $gl-alert-top-border-size: 2px;
|
|
|
110
110
|
@apply gl-mr-0 gl-w-full;
|
|
111
111
|
@apply gl-text-base;
|
|
112
112
|
@apply gl-leading-normal;
|
|
113
|
-
@include gl-
|
|
113
|
+
@include gl-container-width-up(sm) {
|
|
114
114
|
@apply gl-mr-3 gl-w-auto;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -103,109 +103,109 @@ $gl-avatar-identicon-texts: var(--gl-avatar-fallback-text-color-red),
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
.gl-sm-avatar-s16 {
|
|
106
|
-
@include gl-
|
|
106
|
+
@include gl-container-width-up(sm) {
|
|
107
107
|
@include gl-avatar-s16;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
.gl-md-avatar-s16 {
|
|
112
|
-
@include gl-
|
|
112
|
+
@include gl-container-width-up(md) {
|
|
113
113
|
@include gl-avatar-s16;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
.gl-lg-avatar-s16 {
|
|
118
|
-
@include gl-
|
|
118
|
+
@include gl-container-width-up(lg) {
|
|
119
119
|
@include gl-avatar-s16;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
.gl-sm-avatar-s24 {
|
|
124
|
-
@include gl-
|
|
124
|
+
@include gl-container-width-up(sm) {
|
|
125
125
|
@include gl-avatar-s24;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.gl-md-avatar-s24 {
|
|
130
|
-
@include gl-
|
|
130
|
+
@include gl-container-width-up(md) {
|
|
131
131
|
@include gl-avatar-s24;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
.gl-lg-avatar-s24 {
|
|
136
|
-
@include gl-
|
|
136
|
+
@include gl-container-width-up(lg) {
|
|
137
137
|
@include gl-avatar-s24;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
.gl-sm-avatar-s32 {
|
|
142
|
-
@include gl-
|
|
142
|
+
@include gl-container-width-up(sm) {
|
|
143
143
|
@include gl-avatar-s32;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
.gl-md-avatar-s32 {
|
|
148
|
-
@include gl-
|
|
148
|
+
@include gl-container-width-up(md) {
|
|
149
149
|
@include gl-avatar-s32;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
.gl-lg-avatar-s32 {
|
|
154
|
-
@include gl-
|
|
154
|
+
@include gl-container-width-up(lg) {
|
|
155
155
|
@include gl-avatar-s32;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
.gl-sm-avatar-s48 {
|
|
160
|
-
@include gl-
|
|
160
|
+
@include gl-container-width-up(sm) {
|
|
161
161
|
@include gl-avatar-s48;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
.gl-md-avatar-s48 {
|
|
166
|
-
@include gl-
|
|
166
|
+
@include gl-container-width-up(md) {
|
|
167
167
|
@include gl-avatar-s48;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
.gl-lg-avatar-s48 {
|
|
172
|
-
@include gl-
|
|
172
|
+
@include gl-container-width-up(lg) {
|
|
173
173
|
@include gl-avatar-s48;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
.gl-sm-avatar-s64 {
|
|
178
|
-
@include gl-
|
|
178
|
+
@include gl-container-width-up(sm) {
|
|
179
179
|
@include gl-avatar-s64;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
.gl-md-avatar-s64 {
|
|
184
|
-
@include gl-
|
|
184
|
+
@include gl-container-width-up(md) {
|
|
185
185
|
@include gl-avatar-s64;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
.gl-lg-avatar-s64 {
|
|
190
|
-
@include gl-
|
|
190
|
+
@include gl-container-width-up(lg) {
|
|
191
191
|
@include gl-avatar-s64;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
.gl-sm-avatar-s96 {
|
|
196
|
-
@include gl-
|
|
196
|
+
@include gl-container-width-up(sm) {
|
|
197
197
|
@include gl-avatar-s96;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
.gl-md-avatar-s96 {
|
|
202
|
-
@include gl-
|
|
202
|
+
@include gl-container-width-up(md) {
|
|
203
203
|
@include gl-avatar-s96;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
.gl-lg-avatar-s96 {
|
|
208
|
-
@include gl-
|
|
208
|
+
@include gl-container-width-up(lg) {
|
|
209
209
|
@include gl-avatar-s96;
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -28,7 +28,7 @@ $gl-drawer-scrim-gradient: linear-gradient(
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.gl-drawer-default {
|
|
31
|
-
@include
|
|
31
|
+
@include gl-container-width-up(md) {
|
|
32
32
|
width: $gl-drawer-width;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ $gl-drawer-scrim-gradient: linear-gradient(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
.gl-drawer-sidebar {
|
|
42
|
-
@include
|
|
42
|
+
@include gl-container-width-up(md) {
|
|
43
43
|
width: $gl-sidebar-width;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
@each $breakpointName, $breakpointSize in $gl-form-input-sizes {
|
|
65
65
|
@if $breakpointName != xs {
|
|
66
66
|
.gl-#{$breakpointName}-form-input-#{$name} {
|
|
67
|
-
@include gl-
|
|
67
|
+
@include gl-container-width-up($breakpointName) {
|
|
68
68
|
max-width: $size;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -106,7 +106,7 @@ See: https://gitlab.com/gitlab-org/gitlab/issues/30055
|
|
|
106
106
|
@each $breakpointName, $breakpointSize in $gl-form-input-sizes {
|
|
107
107
|
@if $breakpointName != xs {
|
|
108
108
|
.gl-#{$breakpointName}-form-select-#{$name} {
|
|
109
|
-
@include gl-
|
|
109
|
+
@include gl-container-width-up($breakpointName) {
|
|
110
110
|
max-width: $size;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -7,7 +7,6 @@ import { CHART_DEFAULT_SERIES_STACK, HEIGHT_AUTO_CLASSES } from '../../../utils/
|
|
|
7
7
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
8
8
|
import { engineeringNotation } from '../../../utils/number_utils';
|
|
9
9
|
import { hexToRgba } from '../../../utils/utils';
|
|
10
|
-
import TooltipDefaultFormat from '../shared/tooltip/tooltip_default_format/tooltip_default_format.vue';
|
|
11
10
|
import Chart from '../chart/chart.vue';
|
|
12
11
|
import ChartTooltip from '../shared/tooltip/tooltip.vue';
|
|
13
12
|
import { stackedPresentationOptions } from '../../../utils/constants';
|
|
@@ -64,7 +63,6 @@ export default {
|
|
|
64
63
|
components: {
|
|
65
64
|
Chart,
|
|
66
65
|
ChartTooltip,
|
|
67
|
-
TooltipDefaultFormat,
|
|
68
66
|
},
|
|
69
67
|
inheritAttrs: false,
|
|
70
68
|
props: {
|
|
@@ -113,8 +111,6 @@ export default {
|
|
|
113
111
|
data() {
|
|
114
112
|
return {
|
|
115
113
|
chart: null,
|
|
116
|
-
tooltipTitle: '',
|
|
117
|
-
tooltipContent: {},
|
|
118
114
|
};
|
|
119
115
|
},
|
|
120
116
|
computed: {
|
|
@@ -162,13 +158,6 @@ export default {
|
|
|
162
158
|
axisTick: {
|
|
163
159
|
show: true,
|
|
164
160
|
},
|
|
165
|
-
axisPointer: {
|
|
166
|
-
show: true,
|
|
167
|
-
type: 'none',
|
|
168
|
-
label: {
|
|
169
|
-
formatter: this.onLabelChange,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
161
|
},
|
|
173
162
|
},
|
|
174
163
|
this.option,
|
|
@@ -187,46 +176,6 @@ export default {
|
|
|
187
176
|
this.chart = chart;
|
|
188
177
|
this.$emit('created', chart);
|
|
189
178
|
},
|
|
190
|
-
onLabelChange(params) {
|
|
191
|
-
const { yLabels, tooltipContent } = this.getTooltipContent(params, this.xAxisTitle);
|
|
192
|
-
|
|
193
|
-
this.$set(this, 'tooltipContent', tooltipContent);
|
|
194
|
-
this.tooltipTitle = yLabels.join(', ');
|
|
195
|
-
},
|
|
196
|
-
/**
|
|
197
|
-
* For bar charts, the tooltip should be against x-axis values.
|
|
198
|
-
* This method will be removed after https://gitlab.com/gitlab-org/gitlab-ui/-/issues/674
|
|
199
|
-
*
|
|
200
|
-
* @param {Object} params series data
|
|
201
|
-
* @param {String} xAxisTitle x-axis title
|
|
202
|
-
* @returns {Object} tooltip title and content
|
|
203
|
-
*/
|
|
204
|
-
getTooltipContent(params, xAxisTitle = null) {
|
|
205
|
-
const seriesDataLength = params.seriesData.length;
|
|
206
|
-
const { yLabels, tooltipContent } = params.seriesData.reduce(
|
|
207
|
-
(acc, chartItem) => {
|
|
208
|
-
const [value, title] = chartItem.value || [];
|
|
209
|
-
// The x axis title is used instead of y axis
|
|
210
|
-
const seriesName =
|
|
211
|
-
seriesDataLength === 1 && xAxisTitle ? xAxisTitle : chartItem.seriesName;
|
|
212
|
-
const color = seriesDataLength === 1 ? '' : chartItem.color;
|
|
213
|
-
acc.tooltipContent[seriesName] = {
|
|
214
|
-
value,
|
|
215
|
-
color,
|
|
216
|
-
};
|
|
217
|
-
if (!acc.yLabels.includes(title)) {
|
|
218
|
-
acc.yLabels.push(title);
|
|
219
|
-
}
|
|
220
|
-
return acc;
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
yLabels: [],
|
|
224
|
-
tooltipContent: {},
|
|
225
|
-
},
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
return { yLabels, tooltipContent };
|
|
229
|
-
},
|
|
230
179
|
},
|
|
231
180
|
HEIGHT_AUTO_CLASSES,
|
|
232
181
|
};
|
|
@@ -242,11 +191,21 @@ export default {
|
|
|
242
191
|
v-on="$listeners"
|
|
243
192
|
@created="onCreated"
|
|
244
193
|
/>
|
|
245
|
-
<chart-tooltip
|
|
246
|
-
|
|
247
|
-
|
|
194
|
+
<chart-tooltip
|
|
195
|
+
v-if="chart"
|
|
196
|
+
:chart="chart"
|
|
197
|
+
:use-default-tooltip-formatter="true"
|
|
198
|
+
dimension-axis="yAxis"
|
|
199
|
+
>
|
|
200
|
+
<template v-if="$scopedSlots['tooltip-title']" #title="scope">
|
|
201
|
+
<slot name="tooltip-title" v-bind="scope"></slot>
|
|
202
|
+
</template>
|
|
203
|
+
<template v-if="$scopedSlots['tooltip-content']" #default="scope">
|
|
204
|
+
<slot name="tooltip-content" v-bind="scope"></slot>
|
|
205
|
+
</template>
|
|
206
|
+
<template v-if="$scopedSlots['tooltip-value']" #tooltip-value="scope">
|
|
207
|
+
<slot name="tooltip-value" v-bind="scope"></slot>
|
|
248
208
|
</template>
|
|
249
|
-
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
250
209
|
</chart-tooltip>
|
|
251
210
|
</div>
|
|
252
211
|
</template>
|
|
@@ -5,7 +5,11 @@ import { uid, debounceByAnimationFrame } from '../../../../utils/utils';
|
|
|
5
5
|
import GlPopover from '../../../base/popover/popover.vue';
|
|
6
6
|
import { popoverPlacements } from '../../../../utils/constants';
|
|
7
7
|
import { TOOLTIP_LEFT_OFFSET, TOOLTIP_TOP_OFFSET } from '../../../../utils/charts/constants';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
getTooltipTitle,
|
|
10
|
+
getTooltipContent,
|
|
11
|
+
getTooltipAxisConfig,
|
|
12
|
+
} from '../../../../utils/charts/config';
|
|
9
13
|
|
|
10
14
|
import TooltipDefaultFormat from './tooltip_default_format/tooltip_default_format.vue';
|
|
11
15
|
|
|
@@ -127,6 +131,20 @@ export default {
|
|
|
127
131
|
required: false,
|
|
128
132
|
default: false,
|
|
129
133
|
},
|
|
134
|
+
/**
|
|
135
|
+
* Specifies which axis contains the dimensional data used in the tooltip.
|
|
136
|
+
* When `xAxis`, x-axis value becomes the tooltip's title and
|
|
137
|
+
* y-axis values become the tooltip's values.
|
|
138
|
+
* When `yAxis`, roles are reversed.
|
|
139
|
+
*/
|
|
140
|
+
dimensionAxis: {
|
|
141
|
+
type: String,
|
|
142
|
+
required: false,
|
|
143
|
+
default: 'xAxis',
|
|
144
|
+
validator(value) {
|
|
145
|
+
return value === 'xAxis' || value === 'yAxis';
|
|
146
|
+
},
|
|
147
|
+
},
|
|
130
148
|
},
|
|
131
149
|
data() {
|
|
132
150
|
return {
|
|
@@ -208,17 +226,22 @@ export default {
|
|
|
208
226
|
|
|
209
227
|
if (this.useDefaultTooltipFormatter) {
|
|
210
228
|
this.chart.setOption({
|
|
211
|
-
|
|
229
|
+
[this.dimensionAxis]: {
|
|
212
230
|
axisPointer: {
|
|
213
231
|
show: true,
|
|
214
232
|
label: {
|
|
215
233
|
formatter: (params) => {
|
|
216
234
|
const options = this.chart.getOption();
|
|
217
|
-
const titleAxisName = options.xAxis?.[0]?.name;
|
|
218
|
-
const valueAxisName = options.yAxis?.[0]?.name;
|
|
219
235
|
|
|
220
|
-
|
|
221
|
-
|
|
236
|
+
const { dimensionIndex, metricIndex, valueAxis } = getTooltipAxisConfig(
|
|
237
|
+
this.dimensionAxis,
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
const titleAxisName = options[this.dimensionAxis]?.[0]?.name;
|
|
241
|
+
const valueAxisName = options[valueAxis]?.[0]?.name;
|
|
242
|
+
|
|
243
|
+
this.title = getTooltipTitle(params, titleAxisName, dimensionIndex);
|
|
244
|
+
this.content = getTooltipContent(params, valueAxisName, metricIndex);
|
|
222
245
|
this.params = params;
|
|
223
246
|
},
|
|
224
247
|
},
|
package/src/scss/mixins.scss
CHANGED
|
@@ -145,6 +145,77 @@
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
@mixin gl-container-width-up($name, $containerName: '', $includeMQFallback: true) {
|
|
149
|
+
$min: map.get($breakpoints, $name);
|
|
150
|
+
@if $min == null {
|
|
151
|
+
@error "#{$name} is not a valid breakpoint for this @container query.";
|
|
152
|
+
}
|
|
153
|
+
@if $min != 0 {
|
|
154
|
+
@container #{$containerName} (min-width: #{$min}) {
|
|
155
|
+
@if & {
|
|
156
|
+
:where(html.with-gl-container-queries) & {
|
|
157
|
+
@content
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
@else {
|
|
161
|
+
:where(html.with-gl-container-queries) {
|
|
162
|
+
@content
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
@if $includeMQFallback {
|
|
167
|
+
@media (min-width: $min) {
|
|
168
|
+
@if & {
|
|
169
|
+
:where(html:not(.with-gl-container-queries)) & {
|
|
170
|
+
@content;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
@else {
|
|
174
|
+
:where(html:not(.with-gl-container-queries)) {
|
|
175
|
+
@content
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} @else {
|
|
181
|
+
@content;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@mixin gl-container-width-down($name, $containerName: '', $includeMQFallback: true) {
|
|
186
|
+
$max: map.get($breakpoints, $name);
|
|
187
|
+
@if ($max == null or $max == 0) {
|
|
188
|
+
@error "#{$name} is not a valid breakpoint for this @container query.";
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@container #{$containerName} (width < #{$max}) {
|
|
192
|
+
@if & {
|
|
193
|
+
:where(html.with-gl-container-queries) & {
|
|
194
|
+
@content;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
@else {
|
|
198
|
+
:where(html.with-gl-container-queries) {
|
|
199
|
+
@content;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
@if $includeMQFallback {
|
|
204
|
+
@media (width < $max) {
|
|
205
|
+
@if & {
|
|
206
|
+
:where(html:not(.with-gl-container-queries)) & {
|
|
207
|
+
@content;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
@else {
|
|
211
|
+
:where(html:not(.with-gl-container-queries)) {
|
|
212
|
+
@content;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
148
219
|
/**
|
|
149
220
|
* Helper function to resolve font-size value from $gl-font-sizes and
|
|
150
221
|
* $gl-font-sizes-fixed maps.
|
|
@@ -432,22 +432,36 @@ export const generateLineSeries = ({ name, color, data = [], yAxisIndex = 0 }) =
|
|
|
432
432
|
itemStyle: { color },
|
|
433
433
|
});
|
|
434
434
|
|
|
435
|
-
export const
|
|
435
|
+
export const getTooltipAxisConfig = (dimensionAxis) => {
|
|
436
|
+
if (!['xAxis', 'yAxis'].includes(dimensionAxis)) {
|
|
437
|
+
throw new Error(`\`dimensionAxis\` must be "xAxis" or "yAxis", received ${dimensionAxis}`);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (dimensionAxis === 'xAxis') {
|
|
441
|
+
return { dimensionIndex: 0, metricIndex: 1, valueAxis: 'yAxis' };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return { dimensionIndex: 1, metricIndex: 0, valueAxis: 'xAxis' };
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
export const getTooltipTitle = (params = null, titleAxisName = null, dimensionIndex = 0) => {
|
|
436
448
|
if (!params) return '';
|
|
437
449
|
|
|
438
450
|
const title = params.seriesData
|
|
439
451
|
.reduce((acc, { value }) => {
|
|
440
|
-
|
|
452
|
+
const dimension = value[dimensionIndex];
|
|
453
|
+
|
|
454
|
+
if (acc.includes(dimension)) {
|
|
441
455
|
return acc;
|
|
442
456
|
}
|
|
443
|
-
return [...acc,
|
|
457
|
+
return [...acc, dimension];
|
|
444
458
|
}, [])
|
|
445
459
|
.join(', ');
|
|
446
460
|
|
|
447
461
|
return titleAxisName ? `${title} (${titleAxisName})` : title;
|
|
448
462
|
};
|
|
449
463
|
|
|
450
|
-
export const getTooltipContent = (params = null, valueAxisName = null) => {
|
|
464
|
+
export const getTooltipContent = (params = null, valueAxisName = null, metricIndex = 1) => {
|
|
451
465
|
if (!params) {
|
|
452
466
|
return {};
|
|
453
467
|
}
|
|
@@ -455,22 +469,19 @@ export const getTooltipContent = (params = null, valueAxisName = null) => {
|
|
|
455
469
|
const { seriesData } = params;
|
|
456
470
|
|
|
457
471
|
if (seriesData.length === 1) {
|
|
458
|
-
const {
|
|
459
|
-
value: [, yValue],
|
|
460
|
-
seriesName,
|
|
461
|
-
} = seriesData[0];
|
|
472
|
+
const { value, seriesName } = seriesData[0];
|
|
462
473
|
|
|
463
474
|
return {
|
|
464
475
|
[valueAxisName || seriesName]: {
|
|
465
|
-
value:
|
|
476
|
+
value: value[metricIndex],
|
|
466
477
|
color: '', // ignore color when showing a single series
|
|
467
478
|
},
|
|
468
479
|
};
|
|
469
480
|
}
|
|
470
481
|
|
|
471
482
|
return seriesData.reduce((acc, { value, seriesName, color }) => {
|
|
472
|
-
|
|
473
|
-
|
|
483
|
+
acc[seriesName] = { value: value[metricIndex], color };
|
|
484
|
+
|
|
474
485
|
return acc;
|
|
475
486
|
}, {});
|
|
476
487
|
};
|
|
@@ -81,27 +81,6 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// Media that spans multiple breakpoint widths.
|
|
85
|
-
// Makes the @content apply between the min and max breakpoints
|
|
86
|
-
@mixin media-breakpoint-between($lower, $upper, $breakpoints: $grid-breakpoints) {
|
|
87
|
-
$min: breakpoint-min($lower, $breakpoints);
|
|
88
|
-
$max: breakpoint-max($upper, $breakpoints);
|
|
89
|
-
|
|
90
|
-
@if $min != null and $max != null {
|
|
91
|
-
@media (min-width: $min) and (max-width: $max) {
|
|
92
|
-
@content;
|
|
93
|
-
}
|
|
94
|
-
} @else if $max == null {
|
|
95
|
-
@include media-breakpoint-up($lower, $breakpoints) {
|
|
96
|
-
@content;
|
|
97
|
-
}
|
|
98
|
-
} @else if $min == null {
|
|
99
|
-
@include media-breakpoint-down($upper, $breakpoints) {
|
|
100
|
-
@content;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
84
|
// Media between the breakpoint's minimum and maximum widths.
|
|
106
85
|
// No minimum for the smallest breakpoint, and no maximum for the largest one.
|
|
107
86
|
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower.
|