@gitlab/ui 70.0.0 → 71.0.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/CHANGELOG.md +20 -0
- package/dist/components/base/datepicker/datepicker.js +1 -18
- package/dist/components/base/form/form_input/form_input.js +11 -31
- package/dist/components/base/form/form_select/form_select.js +11 -31
- package/dist/components/charts/bar/bar.js +3 -27
- package/dist/components/charts/column/column.js +2 -22
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -10
- package/dist/components/charts/heatmap/heatmap.js +1 -13
- package/dist/components/charts/line/line.js +1 -24
- package/dist/components/charts/sparkline/sparkline.js +1 -6
- package/dist/components/charts/stacked_column/stacked_column.js +2 -25
- package/dist/tokens/css/tokens.css +1 -1
- package/dist/tokens/css/tokens.dark.css +1 -1
- package/dist/tokens/js/tokens.dark.js +1 -1
- package/dist/tokens/js/tokens.js +1 -1
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/utils/constants.js +2 -6
- package/package.json +2 -2
- package/src/components/base/datepicker/datepicker.spec.js +0 -15
- package/src/components/base/datepicker/datepicker.stories.js +3 -7
- package/src/components/base/datepicker/datepicker.vue +1 -22
- package/src/components/base/form/form_input/form_input.spec.js +2 -54
- package/src/components/base/form/form_input/form_input.stories.js +12 -21
- package/src/components/base/form/form_input/form_input.vue +9 -30
- package/src/components/base/form/form_select/form_select.spec.js +3 -28
- package/src/components/base/form/form_select/form_select.stories.js +23 -9
- package/src/components/base/form/form_select/form_select.vue +9 -30
- package/src/components/charts/area/area.spec.js +1 -1
- package/src/components/charts/bar/bar.vue +2 -29
- package/src/components/charts/column/column.vue +1 -27
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +0 -10
- package/src/components/charts/heatmap/heatmap.vue +1 -19
- package/src/components/charts/line/line.spec.js +3 -80
- package/src/components/charts/line/line.vue +1 -35
- package/src/components/charts/sparkline/sparkline.spec.js +0 -38
- package/src/components/charts/sparkline/sparkline.vue +0 -8
- package/src/components/charts/stacked_column/stacked_column.spec.js +4 -97
- package/src/components/charts/stacked_column/stacked_column.vue +1 -27
- package/src/utils/constants.js +1 -6
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
import { CHART_TYPE_LINE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
16
16
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
17
17
|
import { columnOptions } from '../../../utils/constants';
|
|
18
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
19
18
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
20
19
|
import Chart from '../chart/chart.vue';
|
|
21
20
|
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
@@ -87,14 +86,8 @@ export default {
|
|
|
87
86
|
data() {
|
|
88
87
|
return {
|
|
89
88
|
chart: null,
|
|
90
|
-
showTooltip: false,
|
|
91
89
|
tooltipTitle: '',
|
|
92
90
|
tooltipContent: {},
|
|
93
|
-
tooltipPosition: {
|
|
94
|
-
left: '0',
|
|
95
|
-
top: '0',
|
|
96
|
-
},
|
|
97
|
-
debouncedMoveShowTooltip: debounceByAnimationFrame(this.moveShowTooltip),
|
|
98
91
|
};
|
|
99
92
|
},
|
|
100
93
|
computed: {
|
|
@@ -181,21 +174,8 @@ export default {
|
|
|
181
174
|
return this.height === 'auto';
|
|
182
175
|
},
|
|
183
176
|
},
|
|
184
|
-
beforeDestroy() {
|
|
185
|
-
this.chart.getDom().removeEventListener('mousemove', this.debouncedMoveShowTooltip);
|
|
186
|
-
this.chart.getDom().removeEventListener('mouseout', this.debouncedMoveShowTooltip);
|
|
187
|
-
},
|
|
188
177
|
methods: {
|
|
189
|
-
moveShowTooltip(mouseEvent) {
|
|
190
|
-
this.tooltipPosition = {
|
|
191
|
-
left: `${mouseEvent.zrX}px`,
|
|
192
|
-
top: `${mouseEvent.zrY}px`,
|
|
193
|
-
};
|
|
194
|
-
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
195
|
-
},
|
|
196
178
|
onCreated(chart) {
|
|
197
|
-
chart.getDom().addEventListener('mousemove', this.debouncedMoveShowTooltip);
|
|
198
|
-
chart.getDom().addEventListener('mouseout', this.debouncedMoveShowTooltip);
|
|
199
179
|
this.chart = chart;
|
|
200
180
|
this.$emit('created', chart);
|
|
201
181
|
},
|
|
@@ -219,13 +199,7 @@ export default {
|
|
|
219
199
|
v-on="$listeners"
|
|
220
200
|
@created="onCreated"
|
|
221
201
|
/>
|
|
222
|
-
<chart-tooltip
|
|
223
|
-
v-if="chart"
|
|
224
|
-
:show="showTooltip"
|
|
225
|
-
:chart="chart"
|
|
226
|
-
:top="tooltipPosition.top"
|
|
227
|
-
:left="tooltipPosition.left"
|
|
228
|
-
>
|
|
202
|
+
<chart-tooltip v-if="chart" :chart="chart">
|
|
229
203
|
<template #title>
|
|
230
204
|
<div>{{ tooltipTitle }} ({{ xAxisTitle }})</div>
|
|
231
205
|
</template>
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
mergeSeriesToOptions,
|
|
8
8
|
} from '../../../utils/charts/config';
|
|
9
9
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
10
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
11
10
|
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
12
11
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
13
12
|
import Chart from '../chart/chart.vue';
|
|
@@ -66,14 +65,12 @@ export default {
|
|
|
66
65
|
data() {
|
|
67
66
|
return {
|
|
68
67
|
chart: null,
|
|
69
|
-
showTooltip: false,
|
|
70
68
|
tooltipTitle: '',
|
|
71
69
|
tooltipContent: {},
|
|
72
70
|
tooltipPosition: {
|
|
73
71
|
left: '0',
|
|
74
72
|
top: '0',
|
|
75
73
|
},
|
|
76
|
-
debouncedShowHideTooltip: debounceByAnimationFrame(this.showHideTooltip),
|
|
77
74
|
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText,
|
|
78
75
|
};
|
|
79
76
|
},
|
|
@@ -156,12 +153,7 @@ export default {
|
|
|
156
153
|
};
|
|
157
154
|
this.$set(this, 'tooltipContent', tooltipContent);
|
|
158
155
|
},
|
|
159
|
-
showHideTooltip(mouseEvent) {
|
|
160
|
-
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
161
|
-
},
|
|
162
156
|
onCreated(chart) {
|
|
163
|
-
chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
|
|
164
|
-
chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
|
|
165
157
|
this.chart = chart;
|
|
166
158
|
this.$emit('created', chart);
|
|
167
159
|
},
|
|
@@ -173,7 +165,6 @@ export default {
|
|
|
173
165
|
if (data.length) {
|
|
174
166
|
const [left, top] = this.chart.convertToPixel('grid', data);
|
|
175
167
|
|
|
176
|
-
this.showTooltip = true;
|
|
177
168
|
this.tooltipPosition = {
|
|
178
169
|
left: `${left}px`,
|
|
179
170
|
top: `${top}px`,
|
|
@@ -200,7 +191,6 @@ export default {
|
|
|
200
191
|
/>
|
|
201
192
|
<chart-tooltip
|
|
202
193
|
v-if="!disableTooltip && chart"
|
|
203
|
-
:show="showTooltip"
|
|
204
194
|
:chart="chart"
|
|
205
195
|
:top="tooltipPosition.top"
|
|
206
196
|
:left="tooltipPosition.left"
|
|
@@ -6,7 +6,6 @@ import { getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
|
6
6
|
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
7
7
|
import { heatmapHues } from '../../../utils/charts/theme';
|
|
8
8
|
import { engineeringNotation } from '../../../utils/number_utils';
|
|
9
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
10
9
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
11
10
|
import Chart from '../chart/chart.vue';
|
|
12
11
|
import ChartLegend from '../legend/legend.vue';
|
|
@@ -112,13 +111,11 @@ export default {
|
|
|
112
111
|
return {
|
|
113
112
|
chart: null,
|
|
114
113
|
tooltip: {
|
|
115
|
-
show: false,
|
|
116
114
|
title: '',
|
|
117
115
|
content: {},
|
|
118
116
|
left: '0',
|
|
119
117
|
top: '0',
|
|
120
118
|
},
|
|
121
|
-
debouncedShowHideTooltip: debounceByAnimationFrame(this.showHideTooltip),
|
|
122
119
|
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText,
|
|
123
120
|
};
|
|
124
121
|
},
|
|
@@ -223,10 +220,6 @@ export default {
|
|
|
223
220
|
return this.height === 'auto';
|
|
224
221
|
},
|
|
225
222
|
},
|
|
226
|
-
beforeDestroy() {
|
|
227
|
-
this.chart.getDom().removeEventListener('mousemove', this.debouncedShowHideTooltip);
|
|
228
|
-
this.chart.getDom().removeEventListener('mouseout', this.debouncedShowHideTooltip);
|
|
229
|
-
},
|
|
230
223
|
methods: {
|
|
231
224
|
defaultFormatTooltipText(params) {
|
|
232
225
|
const { xLabels, tooltipContent } = getDefaultTooltipContent(
|
|
@@ -238,14 +231,9 @@ export default {
|
|
|
238
231
|
this.tooltip.title = xLabels.join(', ');
|
|
239
232
|
},
|
|
240
233
|
onCreated(chart) {
|
|
241
|
-
chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
|
|
242
|
-
chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
|
|
243
234
|
this.chart = chart;
|
|
244
235
|
this.$emit('created', chart);
|
|
245
236
|
},
|
|
246
|
-
showHideTooltip(mouseEvent) {
|
|
247
|
-
this.tooltip.show = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
248
|
-
},
|
|
249
237
|
onLabelChange(params) {
|
|
250
238
|
this.selectedFormatTooltipText(params);
|
|
251
239
|
const { seriesData = [] } = params;
|
|
@@ -275,13 +263,7 @@ export default {
|
|
|
275
263
|
@created="onCreated"
|
|
276
264
|
v-on="$listeners"
|
|
277
265
|
/>
|
|
278
|
-
<chart-tooltip
|
|
279
|
-
v-if="chart"
|
|
280
|
-
:show="tooltip.show"
|
|
281
|
-
:chart="chart"
|
|
282
|
-
:top="tooltip.top"
|
|
283
|
-
:left="tooltip.left"
|
|
284
|
-
>
|
|
266
|
+
<chart-tooltip v-if="chart" :chart="chart" :top="tooltip.top" :left="tooltip.left">
|
|
285
267
|
<template #title>
|
|
286
268
|
<slot v-if="formatTooltipText" name="tooltip-title"></slot>
|
|
287
269
|
<div v-else>
|
|
@@ -7,7 +7,6 @@ import { expectHeightAutoClasses } from '~helpers/chart_height';
|
|
|
7
7
|
|
|
8
8
|
import Chart from '../chart/chart.vue';
|
|
9
9
|
import ChartLegend from '../legend/legend.vue';
|
|
10
|
-
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
11
10
|
|
|
12
11
|
import LineChart from './line.vue';
|
|
13
12
|
|
|
@@ -138,89 +137,13 @@ describe('line component', () => {
|
|
|
138
137
|
});
|
|
139
138
|
});
|
|
140
139
|
|
|
141
|
-
describe('tooltip', () => {
|
|
142
|
-
const tooltipParams = {
|
|
143
|
-
seriesData: [
|
|
144
|
-
{
|
|
145
|
-
seriesName: 'Series 1',
|
|
146
|
-
value: ['x', 1000],
|
|
147
|
-
color: '#fff',
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
seriesName: 'Series 2',
|
|
151
|
-
value: ['x', 1001],
|
|
152
|
-
color: '#fff',
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
it('renders tooltip', async () => {
|
|
158
|
-
createShallowWrapper(
|
|
159
|
-
{},
|
|
160
|
-
{
|
|
161
|
-
stubs: { TooltipDefaultFormat },
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
wrapper.vm.defaultFormatTooltipText(tooltipParams); // force render of a tooltip
|
|
166
|
-
await nextTick();
|
|
167
|
-
|
|
168
|
-
const tooltipText = findDataTooltip().text();
|
|
169
|
-
expect(tooltipText).toContain('1000');
|
|
170
|
-
expect(tooltipText).toContain('1001');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('renders formatted tooltip values', async () => {
|
|
174
|
-
createShallowWrapper(
|
|
175
|
-
{},
|
|
176
|
-
{
|
|
177
|
-
stubs: { TooltipDefaultFormat },
|
|
178
|
-
scopedSlots: {
|
|
179
|
-
'tooltip-value': ({ value }) => `$ ${value.toLocaleString()}`,
|
|
180
|
-
},
|
|
181
|
-
}
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
wrapper.vm.defaultFormatTooltipText(tooltipParams); // force render of a tooltip
|
|
185
|
-
await nextTick();
|
|
186
|
-
|
|
187
|
-
const tooltipText = findDataTooltip().text();
|
|
188
|
-
expect(tooltipText).toContain('$ 1,000');
|
|
189
|
-
expect(tooltipText).toContain('$ 1,001');
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
describe('tooltip position', () => {
|
|
194
|
-
const dataTooltipTitle = 'FooBar';
|
|
195
|
-
|
|
140
|
+
describe('data tooltip is set', () => {
|
|
196
141
|
beforeEach(() => {
|
|
197
|
-
createShallowWrapper(
|
|
198
|
-
{},
|
|
199
|
-
{
|
|
200
|
-
stubs: {
|
|
201
|
-
'chart-tooltip': ChartTooltipStub,
|
|
202
|
-
},
|
|
203
|
-
}
|
|
204
|
-
);
|
|
142
|
+
createShallowWrapper();
|
|
205
143
|
});
|
|
206
144
|
|
|
207
145
|
it('is initialized', () => {
|
|
208
|
-
expect(findDataTooltip().props('
|
|
209
|
-
expect(findDataTooltip().props('top')).toBe('0');
|
|
210
|
-
expect(findDataTooltip().text()).not.toContain(dataTooltipTitle);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('is reset when mouse moves', async () => {
|
|
214
|
-
const left = '10px';
|
|
215
|
-
const top = '30px';
|
|
216
|
-
|
|
217
|
-
wrapper.setData({ dataTooltipPosition: { left, top }, dataTooltipTitle });
|
|
218
|
-
|
|
219
|
-
await nextTick();
|
|
220
|
-
|
|
221
|
-
expect(findDataTooltip().props('left')).toBe(`${left}`);
|
|
222
|
-
expect(findDataTooltip().props('top')).toBe(`${top}`);
|
|
223
|
-
expect(findDataTooltip().text()).toContain(dataTooltipTitle);
|
|
146
|
+
expect(findDataTooltip().props('chart')).toBe(mockChartInstance);
|
|
224
147
|
});
|
|
225
148
|
});
|
|
226
149
|
|
|
@@ -43,7 +43,6 @@ import {
|
|
|
43
43
|
} from '../../../utils/charts/constants';
|
|
44
44
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
45
45
|
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
46
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
47
46
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
48
47
|
import Chart from '../chart/chart.vue';
|
|
49
48
|
import ChartLegend from '../legend/legend.vue';
|
|
@@ -137,13 +136,8 @@ export default {
|
|
|
137
136
|
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
|
|
138
137
|
return {
|
|
139
138
|
chart: null,
|
|
140
|
-
showDataTooltip: false,
|
|
141
139
|
dataTooltipTitle: '',
|
|
142
140
|
dataTooltipContent: {},
|
|
143
|
-
dataTooltipPosition: {
|
|
144
|
-
left: '0',
|
|
145
|
-
top: '0',
|
|
146
|
-
},
|
|
147
141
|
showAnnotationsTooltip: false,
|
|
148
142
|
annotationsTooltipTitle: '',
|
|
149
143
|
annotationsTooltipContent: '',
|
|
@@ -151,7 +145,6 @@ export default {
|
|
|
151
145
|
left: '0',
|
|
152
146
|
top: '0',
|
|
153
147
|
},
|
|
154
|
-
debouncedShowHideTooltip: debounceByAnimationFrame(this.showHideTooltip),
|
|
155
148
|
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText,
|
|
156
149
|
};
|
|
157
150
|
},
|
|
@@ -262,9 +255,6 @@ export default {
|
|
|
262
255
|
},
|
|
263
256
|
},
|
|
264
257
|
beforeDestroy() {
|
|
265
|
-
this.chart.getDom().removeEventListener('mousemove', this.debouncedShowHideTooltip);
|
|
266
|
-
this.chart.getDom().removeEventListener('mouseout', this.debouncedShowHideTooltip);
|
|
267
|
-
|
|
268
258
|
this.chart.off('mouseout', this.onChartDataPointMouseOut);
|
|
269
259
|
this.chart.off('mouseover', this.onChartDataPointMouseOver);
|
|
270
260
|
},
|
|
@@ -282,13 +272,6 @@ export default {
|
|
|
282
272
|
};
|
|
283
273
|
},
|
|
284
274
|
onCreated(chart) {
|
|
285
|
-
// These listeners are used to show/hide data tooltips
|
|
286
|
-
// when the mouse is hovered over the parent container
|
|
287
|
-
// of echarts' svg element. This works only for data points
|
|
288
|
-
// and not markPoints.
|
|
289
|
-
chart.getDom().addEventListener('mousemove', this.debouncedShowHideTooltip);
|
|
290
|
-
chart.getDom().addEventListener('mouseout', this.debouncedShowHideTooltip);
|
|
291
|
-
|
|
292
275
|
// eCharts inbuild mouse events
|
|
293
276
|
// https://echarts.apache.org/en/api.html#events.Mouse%20events
|
|
294
277
|
// is used to attach listeners to markPoints. These listeners
|
|
@@ -307,14 +290,6 @@ export default {
|
|
|
307
290
|
this.chart = chart;
|
|
308
291
|
this.$emit('created', chart);
|
|
309
292
|
},
|
|
310
|
-
showHideTooltip(mouseEvent) {
|
|
311
|
-
this.showDataTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
312
|
-
|
|
313
|
-
this.dataTooltipPosition = {
|
|
314
|
-
left: `${mouseEvent.zrX}px`,
|
|
315
|
-
top: `${mouseEvent.zrY}px`,
|
|
316
|
-
};
|
|
317
|
-
},
|
|
318
293
|
onChartDataPointMouseOut() {
|
|
319
294
|
this.showAnnotationsTooltip = false;
|
|
320
295
|
},
|
|
@@ -370,16 +345,7 @@ export default {
|
|
|
370
345
|
</template>
|
|
371
346
|
<div>{{ annotationsTooltipContent }}</div>
|
|
372
347
|
</chart-tooltip>
|
|
373
|
-
<chart-tooltip
|
|
374
|
-
v-if="chart"
|
|
375
|
-
id="dataTooltip"
|
|
376
|
-
ref="dataTooltip"
|
|
377
|
-
class="gl-pointer-events-none"
|
|
378
|
-
:show="showDataTooltip"
|
|
379
|
-
:chart="chart"
|
|
380
|
-
:top="dataTooltipPosition.top"
|
|
381
|
-
:left="dataTooltipPosition.left"
|
|
382
|
-
>
|
|
348
|
+
<chart-tooltip v-if="chart" ref="dataTooltip" :chart="chart">
|
|
383
349
|
<template #title>
|
|
384
350
|
<slot v-if="formatTooltipText" name="tooltip-title"></slot>
|
|
385
351
|
<div v-else>
|
|
@@ -127,44 +127,6 @@ describe('sparkline chart component', () => {
|
|
|
127
127
|
expect(getTooltipContent().text()).toContain(tooltipLabel);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
it('shows the tooltip when mousing over an axis point in the component', async () => {
|
|
131
|
-
expect(getTooltip().props('show')).toBe(false);
|
|
132
|
-
|
|
133
|
-
const mockData = { seriesData: [{ data: [5, 8] }] };
|
|
134
|
-
getXAxisLabelFormatter()(mockData);
|
|
135
|
-
|
|
136
|
-
await wrapper.vm.$nextTick();
|
|
137
|
-
expect(getTooltip().props('show')).toBe(true);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('hides the tooltip when the mouse leaves the component', async () => {
|
|
141
|
-
wrapper.setData({ tooltip: { show: true } });
|
|
142
|
-
await wrapper.vm.$nextTick();
|
|
143
|
-
|
|
144
|
-
expect(getTooltip().props('show')).toBe(true);
|
|
145
|
-
|
|
146
|
-
wrapper.trigger('mouseleave');
|
|
147
|
-
await wrapper.vm.$nextTick();
|
|
148
|
-
|
|
149
|
-
expect(getTooltip().props('show')).toBe(false);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it.each`
|
|
153
|
-
label | content
|
|
154
|
-
${null} | ${5}
|
|
155
|
-
${5} | ${null}
|
|
156
|
-
${undefined} | ${0}
|
|
157
|
-
${-10} | ${undefined}
|
|
158
|
-
`(`hides the tooltip when seriesData = ($label, $content)`, async ({ label, content }) => {
|
|
159
|
-
expect(getTooltip().props('show')).toBe(false);
|
|
160
|
-
|
|
161
|
-
const mockData = { seriesData: [{ data: [label, content] }] };
|
|
162
|
-
getXAxisLabelFormatter()(mockData);
|
|
163
|
-
|
|
164
|
-
await wrapper.vm.$nextTick();
|
|
165
|
-
expect(getTooltip().props('show')).toBe(false);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
130
|
it('adds the right content to the tooltip', async () => {
|
|
169
131
|
const xValue = 'foo';
|
|
170
132
|
const yValue = 'bar';
|
|
@@ -89,7 +89,6 @@ export default {
|
|
|
89
89
|
return {
|
|
90
90
|
chartInstance: null,
|
|
91
91
|
tooltip: {
|
|
92
|
-
show: false,
|
|
93
92
|
title: '',
|
|
94
93
|
content: '',
|
|
95
94
|
position: {
|
|
@@ -190,9 +189,6 @@ export default {
|
|
|
190
189
|
handleResize() {
|
|
191
190
|
this.chartInstance.resize();
|
|
192
191
|
},
|
|
193
|
-
hideTooltip() {
|
|
194
|
-
this.tooltip.show = false;
|
|
195
|
-
},
|
|
196
192
|
setTooltipPosition(data) {
|
|
197
193
|
const [left, top] = this.chartInstance.convertToPixel('grid', data);
|
|
198
194
|
this.tooltip.position = {
|
|
@@ -214,7 +210,6 @@ export default {
|
|
|
214
210
|
const [title, content] = data;
|
|
215
211
|
if (isNil(title) || isNil(content)) return;
|
|
216
212
|
|
|
217
|
-
this.tooltip.show = true;
|
|
218
213
|
this.tooltip.title = title;
|
|
219
214
|
this.tooltip.content = content;
|
|
220
215
|
this.setTooltipPosition(data);
|
|
@@ -229,7 +224,6 @@ export default {
|
|
|
229
224
|
v-resize-observer="handleResize"
|
|
230
225
|
class="gl-display-flex gl-align-items-center"
|
|
231
226
|
:class="{ 'gl-h-full': autoHeight }"
|
|
232
|
-
@mouseleave="hideTooltip"
|
|
233
227
|
>
|
|
234
228
|
<slot name="default"></slot>
|
|
235
229
|
<div
|
|
@@ -247,11 +241,9 @@ export default {
|
|
|
247
241
|
/>
|
|
248
242
|
<chart-tooltip
|
|
249
243
|
v-if="chartInstance"
|
|
250
|
-
:show="tooltip.show"
|
|
251
244
|
:chart="chartInstance"
|
|
252
245
|
:top="tooltip.position.top"
|
|
253
246
|
:left="tooltip.position.left"
|
|
254
|
-
:style="{ pointerEvents: 'none' }"
|
|
255
247
|
placement="top"
|
|
256
248
|
>
|
|
257
249
|
<template #title>
|
|
@@ -34,7 +34,6 @@ describe('stacked column chart component', () => {
|
|
|
34
34
|
|
|
35
35
|
const findChart = () => wrapper.findComponent(Chart);
|
|
36
36
|
const findLegend = () => wrapper.findComponent(ChartLegend);
|
|
37
|
-
const getOptions = () => findChart().props('options');
|
|
38
37
|
const findDataTooltip = () => wrapper.findComponent(ChartTooltipStub);
|
|
39
38
|
|
|
40
39
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
@@ -142,104 +141,12 @@ describe('stacked column chart component', () => {
|
|
|
142
141
|
});
|
|
143
142
|
|
|
144
143
|
describe('tooltip', () => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
beforeEach(() => {
|
|
149
|
-
createShallowWrapper();
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('is initialized', () => {
|
|
153
|
-
expect(findDataTooltip().props('left')).toBe('0');
|
|
154
|
-
expect(findDataTooltip().props('top')).toBe('0');
|
|
155
|
-
expect(findDataTooltip().text()).not.toContain(tooltipTitle);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('is reset when mouse moves', async () => {
|
|
159
|
-
const left = '10px';
|
|
160
|
-
const top = '30px';
|
|
161
|
-
|
|
162
|
-
wrapper.setData({ tooltipPosition: { left, top }, tooltipTitle });
|
|
163
|
-
|
|
164
|
-
await wrapper.vm.$nextTick();
|
|
165
|
-
|
|
166
|
-
expect(findDataTooltip().props('left')).toBe(`${left}`);
|
|
167
|
-
expect(findDataTooltip().props('top')).toBe(`${top}`);
|
|
168
|
-
expect(findDataTooltip().text()).toContain(tooltipTitle);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
const params = {
|
|
173
|
-
seriesData: [{ seriesIndex: '0', seriesName: 'Blah', value: 'Jan' }],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
describe('default', () => {
|
|
177
|
-
beforeEach(() => {
|
|
178
|
-
createShallowWrapper();
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('calls the default tooltip text function', async () => {
|
|
182
|
-
wrapper.vm.defaultFormatTooltipText = jest.fn();
|
|
183
|
-
|
|
184
|
-
expect(wrapper.vm.defaultFormatTooltipText).not.toHaveBeenCalled();
|
|
185
|
-
|
|
186
|
-
getOptions().xAxis.axisPointer.label.formatter(params);
|
|
187
|
-
|
|
188
|
-
await wrapper.vm.$nextTick();
|
|
189
|
-
|
|
190
|
-
expect(wrapper.vm.defaultFormatTooltipText).toHaveBeenCalled();
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('displays the generic tooltip content', async () => {
|
|
194
|
-
getOptions().xAxis.axisPointer.label.formatter(params);
|
|
195
|
-
|
|
196
|
-
await wrapper.vm.$nextTick();
|
|
197
|
-
|
|
198
|
-
const tooltipText = findDataTooltip().element.textContent;
|
|
199
|
-
|
|
200
|
-
expect(tooltipText).toContain(defaultChartProps.xAxisTitle);
|
|
201
|
-
expect(tooltipText).toContain(params.seriesData[0].seriesName);
|
|
202
|
-
expect(tooltipText).toContain(params.seriesData[0].value);
|
|
203
|
-
});
|
|
144
|
+
beforeEach(() => {
|
|
145
|
+
createShallowWrapper();
|
|
204
146
|
});
|
|
205
147
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const customTitle = 'Custom title';
|
|
209
|
-
const customContent = 'Custom content';
|
|
210
|
-
|
|
211
|
-
beforeEach(() => {
|
|
212
|
-
createShallowWrapper({
|
|
213
|
-
props: {
|
|
214
|
-
formatTooltipText,
|
|
215
|
-
},
|
|
216
|
-
slots: {
|
|
217
|
-
'tooltip-title': customTitle,
|
|
218
|
-
'tooltip-content': customContent,
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('calls the formatTooltipText tooltip text function', async () => {
|
|
224
|
-
expect(formatTooltipText).not.toHaveBeenCalled();
|
|
225
|
-
|
|
226
|
-
getOptions().xAxis.axisPointer.label.formatter(params);
|
|
227
|
-
|
|
228
|
-
await wrapper.vm.$nextTick();
|
|
229
|
-
|
|
230
|
-
expect(formatTooltipText).toHaveBeenCalled();
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('displays the custom tooltip content', async () => {
|
|
234
|
-
getOptions().xAxis.axisPointer.label.formatter(params);
|
|
235
|
-
|
|
236
|
-
await wrapper.vm.$nextTick();
|
|
237
|
-
|
|
238
|
-
const tooltipText = findDataTooltip().element.textContent;
|
|
239
|
-
|
|
240
|
-
expect(tooltipText).toContain(customTitle);
|
|
241
|
-
expect(tooltipText).toContain(customContent);
|
|
242
|
-
});
|
|
148
|
+
it('is initialized', () => {
|
|
149
|
+
expect(findDataTooltip().props('chart')).toBe(mockChartInstance);
|
|
243
150
|
});
|
|
244
151
|
});
|
|
245
152
|
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
} from '../../../utils/charts/constants';
|
|
23
23
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
24
24
|
import { columnOptions } from '../../../utils/constants';
|
|
25
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
26
25
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
27
26
|
import Chart from '../chart/chart.vue';
|
|
28
27
|
import ChartLegend from '../legend/legend.vue';
|
|
@@ -149,14 +148,8 @@ export default {
|
|
|
149
148
|
data() {
|
|
150
149
|
return {
|
|
151
150
|
chart: null,
|
|
152
|
-
showTooltip: false,
|
|
153
151
|
tooltipTitle: '',
|
|
154
152
|
tooltipContent: {},
|
|
155
|
-
tooltipPosition: {
|
|
156
|
-
left: '0',
|
|
157
|
-
top: '0',
|
|
158
|
-
},
|
|
159
|
-
debouncedMoveShowTooltip: debounceByAnimationFrame(this.moveShowTooltip),
|
|
160
153
|
};
|
|
161
154
|
},
|
|
162
155
|
computed: {
|
|
@@ -259,24 +252,11 @@ export default {
|
|
|
259
252
|
return this.height === 'auto';
|
|
260
253
|
},
|
|
261
254
|
},
|
|
262
|
-
beforeDestroy() {
|
|
263
|
-
this.chart.getZr().off('mousemove', this.debouncedMoveShowTooltip);
|
|
264
|
-
this.chart.getZr().off('mouseout', this.debouncedMoveShowTooltip);
|
|
265
|
-
},
|
|
266
255
|
methods: {
|
|
267
256
|
getColor(index) {
|
|
268
257
|
return this.customPalette ? this.customPalette?.[index] : colorFromDefaultPalette(index);
|
|
269
258
|
},
|
|
270
|
-
moveShowTooltip({ event: mouseEvent }) {
|
|
271
|
-
this.tooltipPosition = {
|
|
272
|
-
left: `${mouseEvent.zrX}px`,
|
|
273
|
-
top: `${mouseEvent.zrY}px`,
|
|
274
|
-
};
|
|
275
|
-
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
276
|
-
},
|
|
277
259
|
onCreated(chart) {
|
|
278
|
-
chart.getZr().on('mousemove', this.debouncedMoveShowTooltip);
|
|
279
|
-
chart.getZr().on('mouseout', this.debouncedMoveShowTooltip);
|
|
280
260
|
this.chart = chart;
|
|
281
261
|
this.$emit('created', chart);
|
|
282
262
|
},
|
|
@@ -320,13 +300,7 @@ export default {
|
|
|
320
300
|
v-on="$listeners"
|
|
321
301
|
@created="onCreated"
|
|
322
302
|
/>
|
|
323
|
-
<chart-tooltip
|
|
324
|
-
v-if="chart"
|
|
325
|
-
:show="showTooltip"
|
|
326
|
-
:chart="chart"
|
|
327
|
-
:top="tooltipPosition.top"
|
|
328
|
-
:left="tooltipPosition.left"
|
|
329
|
-
>
|
|
303
|
+
<chart-tooltip v-if="chart" :chart="chart">
|
|
330
304
|
<template #title>
|
|
331
305
|
<slot name="tooltip-title">{{ tooltipTitle }} ({{ xAxisTitle }})</slot>
|
|
332
306
|
</template>
|
package/src/utils/constants.js
CHANGED
|
@@ -144,11 +144,6 @@ export const buttonSizeOptions = {
|
|
|
144
144
|
medium: 'md',
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
export const datepickerSizeOptionsMap = {
|
|
148
|
-
small: 'sm',
|
|
149
|
-
medium: 'md',
|
|
150
|
-
};
|
|
151
|
-
|
|
152
147
|
export const datepickerWidthOptionsMap = {
|
|
153
148
|
sm: 'sm',
|
|
154
149
|
md: 'md',
|
|
@@ -290,7 +285,7 @@ export const keyboard = {
|
|
|
290
285
|
|
|
291
286
|
export const truncateOptions = POSITION;
|
|
292
287
|
|
|
293
|
-
export const
|
|
288
|
+
export const formInputWidths = {
|
|
294
289
|
xs: 'xs',
|
|
295
290
|
sm: 'sm',
|
|
296
291
|
md: 'md',
|