@gitlab/ui 71.9.0 → 71.10.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 +14 -0
- package/dist/components/charts/area/area.js +11 -22
- package/dist/components/charts/bar/bar.js +3 -4
- package/dist/components/charts/column/column.js +5 -22
- package/dist/components/charts/heatmap/heatmap.js +4 -9
- package/dist/components/charts/line/line.js +11 -22
- 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/json/tokens.dark.json +198 -330
- package/dist/tokens/json/tokens.json +132 -132
- package/dist/tokens/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +67 -67
- package/package.json +1 -1
- package/src/components/charts/area/area.spec.js +82 -7
- package/src/components/charts/area/area.stories.js +24 -6
- package/src/components/charts/area/area.vue +21 -27
- package/src/components/charts/bar/bar.spec.js +7 -43
- package/src/components/charts/bar/bar.vue +3 -4
- package/src/components/charts/column/__snapshots__/column_chart.spec.js.snap +0 -12
- package/src/components/charts/column/column.vue +1 -23
- package/src/components/charts/column/column_chart.spec.js +13 -27
- package/src/components/charts/heatmap/heatmap.vue +4 -14
- package/src/components/charts/line/line.spec.js +120 -38
- package/src/components/charts/line/line.stories.js +21 -4
- package/src/components/charts/line/line.vue +21 -32
- package/src/tokens/color.theme.tokens.json +66 -66
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
// Do not edit directly
|
|
3
|
-
// Generated on
|
|
3
|
+
// Generated on Wed, 13 Dec 2023 16:29:09 GMT
|
|
4
4
|
|
|
5
5
|
$gl-line-height-52: 3.25rem;
|
|
6
6
|
$gl-line-height-44: 2.75rem;
|
|
@@ -92,72 +92,72 @@ $blue-100: #cbe2f9 !default;
|
|
|
92
92
|
$blue-50: #e9f3fc !default;
|
|
93
93
|
$white: #fff !default;
|
|
94
94
|
$black: #000 !default;
|
|
95
|
-
$theme-light-red-950: #5c1105;
|
|
96
|
-
$theme-light-red-900: #751709;
|
|
97
|
-
$theme-light-red-800: #8b2212;
|
|
98
|
-
$theme-light-red-700: #a02e1c;
|
|
99
|
-
$theme-light-red-600: #b53a26;
|
|
100
|
-
$theme-light-red-500: #c24b38;
|
|
101
|
-
$theme-light-red-400: #d36250;
|
|
102
|
-
$theme-light-red-300: #e07f6f;
|
|
103
|
-
$theme-light-red-200: #ebada2;
|
|
104
|
-
$theme-light-red-100: #f6d9d5;
|
|
105
|
-
$theme-light-red-50: #faf2f1;
|
|
106
|
-
$theme-red-950: #380700;
|
|
107
|
-
$theme-red-900: #580d02;
|
|
108
|
-
$theme-red-800: #761405;
|
|
109
|
-
$theme-red-700: #8f2110;
|
|
110
|
-
$theme-red-600: #a13322;
|
|
111
|
-
$theme-red-500: #ad4a3b;
|
|
112
|
-
$theme-red-400: #c66e60;
|
|
113
|
-
$theme-red-300: #d59086;
|
|
114
|
-
$theme-red-200: #e3bab5;
|
|
115
|
-
$theme-red-100: #ecd3d0;
|
|
116
|
-
$theme-red-50: #f4e9e7;
|
|
117
|
-
$theme-green-950: #052e19;
|
|
118
|
-
$theme-green-900: #0e4328;
|
|
119
|
-
$theme-green-800: #155635;
|
|
120
|
-
$theme-green-700: #1b653f;
|
|
121
|
-
$theme-green-600: #25744c;
|
|
122
|
-
$theme-green-500: #308258;
|
|
123
|
-
$theme-green-400: #499767;
|
|
124
|
-
$theme-green-300: #69af7d;
|
|
125
|
-
$theme-green-200: #8cc497;
|
|
126
|
-
$theme-green-100: #b1d6b5;
|
|
127
|
-
$theme-green-50: #dde9de;
|
|
128
|
-
$theme-light-blue-950: #0a3764;
|
|
129
|
-
$theme-light-blue-900: #0c4277;
|
|
130
|
-
$theme-light-blue-800: #0e4d8d;
|
|
131
|
-
$theme-light-blue-700: #145aa1;
|
|
132
|
-
$theme-light-blue-600: #2268ae;
|
|
133
|
-
$theme-light-blue-500: #3476b9;
|
|
134
|
-
$theme-light-blue-400: #4f8bc7;
|
|
135
|
-
$theme-light-blue-300: #74a3d3;
|
|
136
|
-
$theme-light-blue-200: #a0bedc;
|
|
137
|
-
$theme-light-blue-100: #c1d4e6;
|
|
138
|
-
$theme-light-blue-50: #dde6ee;
|
|
139
|
-
$theme-blue-950: #04101c;
|
|
140
|
-
$theme-blue-900: #0b2640;
|
|
141
|
-
$theme-blue-800: #153c63;
|
|
142
|
-
$theme-blue-700: #235180;
|
|
143
|
-
$theme-blue-600: #346596;
|
|
144
|
-
$theme-blue-500: #4977a5;
|
|
145
|
-
$theme-blue-400: #628eb9;
|
|
146
|
-
$theme-blue-300: #81a5c9;
|
|
147
|
-
$theme-blue-200: #a6bdd5;
|
|
148
|
-
$theme-blue-100: #b9cadc;
|
|
149
|
-
$theme-blue-50: #cdd8e3;
|
|
150
|
-
$theme-indigo-950: #14143d;
|
|
151
|
-
$theme-indigo-900: #222261;
|
|
152
|
-
$theme-indigo-800: #303083;
|
|
153
|
-
$theme-indigo-700: #41419f;
|
|
154
|
-
$theme-indigo-600: #5252b5;
|
|
155
|
-
$theme-indigo-500: #6666c4;
|
|
156
|
-
$theme-indigo-400: #8181d7;
|
|
157
|
-
$theme-indigo-300: #a2a2e6;
|
|
158
|
-
$theme-indigo-200: #c7c7f2;
|
|
159
|
-
$theme-indigo-100: #dbdbf8;
|
|
160
|
-
$theme-indigo-50: #f1f1ff;
|
|
95
|
+
$theme-light-red-950: #5c1105 !default;
|
|
96
|
+
$theme-light-red-900: #751709 !default;
|
|
97
|
+
$theme-light-red-800: #8b2212 !default;
|
|
98
|
+
$theme-light-red-700: #a02e1c !default;
|
|
99
|
+
$theme-light-red-600: #b53a26 !default;
|
|
100
|
+
$theme-light-red-500: #c24b38 !default;
|
|
101
|
+
$theme-light-red-400: #d36250 !default;
|
|
102
|
+
$theme-light-red-300: #e07f6f !default;
|
|
103
|
+
$theme-light-red-200: #ebada2 !default;
|
|
104
|
+
$theme-light-red-100: #f6d9d5 !default;
|
|
105
|
+
$theme-light-red-50: #faf2f1 !default;
|
|
106
|
+
$theme-red-950: #380700 !default;
|
|
107
|
+
$theme-red-900: #580d02 !default;
|
|
108
|
+
$theme-red-800: #761405 !default;
|
|
109
|
+
$theme-red-700: #8f2110 !default;
|
|
110
|
+
$theme-red-600: #a13322 !default;
|
|
111
|
+
$theme-red-500: #ad4a3b !default;
|
|
112
|
+
$theme-red-400: #c66e60 !default;
|
|
113
|
+
$theme-red-300: #d59086 !default;
|
|
114
|
+
$theme-red-200: #e3bab5 !default;
|
|
115
|
+
$theme-red-100: #ecd3d0 !default;
|
|
116
|
+
$theme-red-50: #f4e9e7 !default;
|
|
117
|
+
$theme-green-950: #052e19 !default;
|
|
118
|
+
$theme-green-900: #0e4328 !default;
|
|
119
|
+
$theme-green-800: #155635 !default;
|
|
120
|
+
$theme-green-700: #1b653f !default;
|
|
121
|
+
$theme-green-600: #25744c !default;
|
|
122
|
+
$theme-green-500: #308258 !default;
|
|
123
|
+
$theme-green-400: #499767 !default;
|
|
124
|
+
$theme-green-300: #69af7d !default;
|
|
125
|
+
$theme-green-200: #8cc497 !default;
|
|
126
|
+
$theme-green-100: #b1d6b5 !default;
|
|
127
|
+
$theme-green-50: #dde9de !default;
|
|
128
|
+
$theme-light-blue-950: #0a3764 !default;
|
|
129
|
+
$theme-light-blue-900: #0c4277 !default;
|
|
130
|
+
$theme-light-blue-800: #0e4d8d !default;
|
|
131
|
+
$theme-light-blue-700: #145aa1 !default;
|
|
132
|
+
$theme-light-blue-600: #2268ae !default;
|
|
133
|
+
$theme-light-blue-500: #3476b9 !default;
|
|
134
|
+
$theme-light-blue-400: #4f8bc7 !default;
|
|
135
|
+
$theme-light-blue-300: #74a3d3 !default;
|
|
136
|
+
$theme-light-blue-200: #a0bedc !default;
|
|
137
|
+
$theme-light-blue-100: #c1d4e6 !default;
|
|
138
|
+
$theme-light-blue-50: #dde6ee !default;
|
|
139
|
+
$theme-blue-950: #04101c !default;
|
|
140
|
+
$theme-blue-900: #0b2640 !default;
|
|
141
|
+
$theme-blue-800: #153c63 !default;
|
|
142
|
+
$theme-blue-700: #235180 !default;
|
|
143
|
+
$theme-blue-600: #346596 !default;
|
|
144
|
+
$theme-blue-500: #4977a5 !default;
|
|
145
|
+
$theme-blue-400: #628eb9 !default;
|
|
146
|
+
$theme-blue-300: #81a5c9 !default;
|
|
147
|
+
$theme-blue-200: #a6bdd5 !default;
|
|
148
|
+
$theme-blue-100: #b9cadc !default;
|
|
149
|
+
$theme-blue-50: #cdd8e3 !default;
|
|
150
|
+
$theme-indigo-950: #14143d !default;
|
|
151
|
+
$theme-indigo-900: #222261 !default;
|
|
152
|
+
$theme-indigo-800: #303083 !default;
|
|
153
|
+
$theme-indigo-700: #41419f !default;
|
|
154
|
+
$theme-indigo-600: #5252b5 !default;
|
|
155
|
+
$theme-indigo-500: #6666c4 !default;
|
|
156
|
+
$theme-indigo-400: #8181d7 !default;
|
|
157
|
+
$theme-indigo-300: #a2a2e6 !default;
|
|
158
|
+
$theme-indigo-200: #c7c7f2 !default;
|
|
159
|
+
$theme-indigo-100: #dbdbf8 !default;
|
|
160
|
+
$theme-indigo-50: #f1f1ff !default;
|
|
161
161
|
$data-viz-orange-950: #4b2707 !default;
|
|
162
162
|
$data-viz-orange-900: #5e2f05 !default;
|
|
163
163
|
$data-viz-orange-800: #6f3500 !default;
|
package/package.json
CHANGED
|
@@ -2,7 +2,11 @@ import { nextTick } from 'vue';
|
|
|
2
2
|
import { shallowMount } from '@vue/test-utils';
|
|
3
3
|
|
|
4
4
|
import { LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '~/utils/charts/constants';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createMockChartInstance,
|
|
7
|
+
ChartTooltipStub,
|
|
8
|
+
chartTooltipStubData,
|
|
9
|
+
} from '~helpers/chart_stubs';
|
|
6
10
|
import { expectHeightAutoClasses } from '~helpers/chart_height';
|
|
7
11
|
import Chart from '../chart/chart.vue';
|
|
8
12
|
import ChartLegend from '../legend/legend.vue';
|
|
@@ -24,13 +28,13 @@ describe('area component', () => {
|
|
|
24
28
|
|
|
25
29
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
26
30
|
|
|
27
|
-
const createShallowWrapper = ({ props = {},
|
|
31
|
+
const createShallowWrapper = ({ props = {}, ...options } = {}) => {
|
|
28
32
|
wrapper = shallowMount(AreaChart, {
|
|
29
33
|
propsData: { option: { series: [] }, data: [], ...props },
|
|
30
34
|
stubs: {
|
|
31
35
|
'chart-tooltip': ChartTooltipStub,
|
|
32
36
|
},
|
|
33
|
-
|
|
37
|
+
...options,
|
|
34
38
|
});
|
|
35
39
|
emitChartCreated();
|
|
36
40
|
};
|
|
@@ -136,13 +140,84 @@ describe('area component', () => {
|
|
|
136
140
|
});
|
|
137
141
|
});
|
|
138
142
|
|
|
139
|
-
describe('data tooltip
|
|
140
|
-
|
|
143
|
+
describe('data tooltip', () => {
|
|
144
|
+
it('is initialized', async () => {
|
|
141
145
|
createShallowWrapper();
|
|
146
|
+
|
|
147
|
+
await nextTick();
|
|
148
|
+
|
|
149
|
+
expect(findDataTooltip().props()).toMatchObject({
|
|
150
|
+
useDefaultTooltipFormatter: true,
|
|
151
|
+
chart: mockChartInstance,
|
|
152
|
+
});
|
|
142
153
|
});
|
|
143
154
|
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
describe('is customized via slots', () => {
|
|
156
|
+
const { params, title, content } = chartTooltipStubData;
|
|
157
|
+
const value = params.seriesData[0].value[1];
|
|
158
|
+
|
|
159
|
+
it('customizes tooltip value', async () => {
|
|
160
|
+
const tooltipValueSlot = jest.fn().mockReturnValue('Value');
|
|
161
|
+
|
|
162
|
+
createShallowWrapper({
|
|
163
|
+
scopedSlots: {
|
|
164
|
+
'tooltip-value': tooltipValueSlot,
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
await nextTick();
|
|
168
|
+
|
|
169
|
+
expect(tooltipValueSlot).toHaveBeenCalledWith({ value });
|
|
170
|
+
expect(findDataTooltip().text()).toBe('Value');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('customizes title', async () => {
|
|
174
|
+
const tooltipTitleSlot = jest.fn().mockReturnValue('Title');
|
|
175
|
+
|
|
176
|
+
createShallowWrapper({
|
|
177
|
+
scopedSlots: {
|
|
178
|
+
'tooltip-title': tooltipTitleSlot,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
await nextTick();
|
|
182
|
+
|
|
183
|
+
expect(tooltipTitleSlot).toHaveBeenCalledWith({
|
|
184
|
+
params,
|
|
185
|
+
title,
|
|
186
|
+
});
|
|
187
|
+
expect(findDataTooltip().text()).toBe('Title');
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('customizes content', async () => {
|
|
191
|
+
const tooltipContentSlot = jest.fn().mockReturnValue('Title');
|
|
192
|
+
|
|
193
|
+
createShallowWrapper({
|
|
194
|
+
scopedSlots: {
|
|
195
|
+
'tooltip-content': tooltipContentSlot,
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
await nextTick();
|
|
199
|
+
|
|
200
|
+
expect(tooltipContentSlot).toHaveBeenCalledWith({
|
|
201
|
+
params,
|
|
202
|
+
content,
|
|
203
|
+
});
|
|
204
|
+
expect(findDataTooltip().text()).toBe('Title');
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('is customized via formatting function', async () => {
|
|
209
|
+
createShallowWrapper({
|
|
210
|
+
props: {
|
|
211
|
+
formatTooltipText: jest.fn(),
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
await nextTick();
|
|
216
|
+
|
|
217
|
+
expect(findDataTooltip().props()).toMatchObject({
|
|
218
|
+
useDefaultTooltipFormatter: false,
|
|
219
|
+
chart: mockChartInstance,
|
|
220
|
+
});
|
|
146
221
|
});
|
|
147
222
|
});
|
|
148
223
|
|
|
@@ -7,6 +7,9 @@ import { timeSeriesDateFormatter } from '../../../utils/charts/utils';
|
|
|
7
7
|
import { generateTimeSeries } from '../../../utils/data_utils';
|
|
8
8
|
import { disableControls } from '../../../utils/stories_utils';
|
|
9
9
|
|
|
10
|
+
const components = {
|
|
11
|
+
GlAreaChart,
|
|
12
|
+
};
|
|
10
13
|
const defaultData = [
|
|
11
14
|
{
|
|
12
15
|
name: 'First Series',
|
|
@@ -29,7 +32,7 @@ const defaultOptions = {
|
|
|
29
32
|
},
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
const template = `<gl-area-chart
|
|
35
|
+
const template = (content) => `<gl-area-chart
|
|
33
36
|
:data="data"
|
|
34
37
|
:option="option"
|
|
35
38
|
:thresholds="thresholds"
|
|
@@ -37,7 +40,9 @@ const template = `<gl-area-chart
|
|
|
37
40
|
:includeLegendAvgMax="includeLegendAvgMax"
|
|
38
41
|
:height="height"
|
|
39
42
|
:legendSeriesInfo="legendSeriesInfo"
|
|
40
|
-
|
|
43
|
+
>
|
|
44
|
+
${content}
|
|
45
|
+
</gl-area-chart>`;
|
|
41
46
|
|
|
42
47
|
const generateProps = ({
|
|
43
48
|
data = defaultData,
|
|
@@ -58,11 +63,9 @@ const generateProps = ({
|
|
|
58
63
|
});
|
|
59
64
|
|
|
60
65
|
const Template = (args, { argTypes }) => ({
|
|
61
|
-
components
|
|
62
|
-
GlAreaChart,
|
|
63
|
-
},
|
|
66
|
+
components,
|
|
64
67
|
props: Object.keys(argTypes),
|
|
65
|
-
template,
|
|
68
|
+
template: template(),
|
|
66
69
|
});
|
|
67
70
|
|
|
68
71
|
export const Default = Template.bind({});
|
|
@@ -175,6 +178,21 @@ WithCustomLegendItems.args = generateProps({
|
|
|
175
178
|
],
|
|
176
179
|
});
|
|
177
180
|
|
|
181
|
+
export const WithCustomTooltip = (_args, { argTypes }) => ({
|
|
182
|
+
props: Object.keys(argTypes),
|
|
183
|
+
components,
|
|
184
|
+
template: template(`
|
|
185
|
+
<template #tooltip-title="{ params }">{{params && params.value}}</template>
|
|
186
|
+
<template #tooltip-content="{ params }">
|
|
187
|
+
<div v-if="params">{{params.seriesData[0].seriesName}}: {{params.seriesData[0].value[1]}}</div>
|
|
188
|
+
</template>
|
|
189
|
+
`),
|
|
190
|
+
});
|
|
191
|
+
WithCustomTooltip.args = generateProps();
|
|
192
|
+
WithCustomTooltip.parameters = {
|
|
193
|
+
storyshots: { disable: true },
|
|
194
|
+
};
|
|
195
|
+
|
|
178
196
|
export default {
|
|
179
197
|
title: 'charts/area-chart',
|
|
180
198
|
component: GlAreaChart,
|
|
@@ -27,8 +27,6 @@ import {
|
|
|
27
27
|
mergeSeriesToOptions,
|
|
28
28
|
mergeAnnotationAxisToOptions,
|
|
29
29
|
lineStyle,
|
|
30
|
-
// eslint-disable-next-line import/no-deprecated
|
|
31
|
-
getDefaultTooltipContent,
|
|
32
30
|
} from '../../../utils/charts/config';
|
|
33
31
|
import {
|
|
34
32
|
LEGEND_LAYOUT_INLINE,
|
|
@@ -41,7 +39,6 @@ import {
|
|
|
41
39
|
} from '../../../utils/charts/constants';
|
|
42
40
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
43
41
|
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
44
|
-
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
45
42
|
import Chart from '../chart/chart.vue';
|
|
46
43
|
import ChartLegend from '../legend/legend.vue';
|
|
47
44
|
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
@@ -52,7 +49,6 @@ export default {
|
|
|
52
49
|
Chart,
|
|
53
50
|
ChartLegend,
|
|
54
51
|
ChartTooltip,
|
|
55
|
-
TooltipDefaultFormat,
|
|
56
52
|
},
|
|
57
53
|
inheritAttrs: false,
|
|
58
54
|
props: {
|
|
@@ -85,6 +81,12 @@ export default {
|
|
|
85
81
|
required: false,
|
|
86
82
|
default: null,
|
|
87
83
|
},
|
|
84
|
+
/**
|
|
85
|
+
* Callback called when showing or refreshing a tooltip.
|
|
86
|
+
* **Deprecated:** Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
87
|
+
*
|
|
88
|
+
* @deprecated Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
89
|
+
*/
|
|
88
90
|
formatTooltipText: {
|
|
89
91
|
type: Function,
|
|
90
92
|
required: false,
|
|
@@ -139,8 +141,6 @@ export default {
|
|
|
139
141
|
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
|
|
140
142
|
return {
|
|
141
143
|
chart: null,
|
|
142
|
-
dataTooltipTitle: '',
|
|
143
|
-
dataTooltipContent: {},
|
|
144
144
|
showAnnotationsTooltip: false,
|
|
145
145
|
annotationsTooltipTitle: '',
|
|
146
146
|
annotationsTooltipContent: '',
|
|
@@ -148,7 +148,6 @@ export default {
|
|
|
148
148
|
left: '0',
|
|
149
149
|
top: '0',
|
|
150
150
|
},
|
|
151
|
-
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText,
|
|
152
151
|
};
|
|
153
152
|
},
|
|
154
153
|
computed: {
|
|
@@ -195,7 +194,7 @@ export default {
|
|
|
195
194
|
type: 'solid',
|
|
196
195
|
},
|
|
197
196
|
label: {
|
|
198
|
-
formatter: this.
|
|
197
|
+
formatter: this.formatTooltipText,
|
|
199
198
|
},
|
|
200
199
|
},
|
|
201
200
|
},
|
|
@@ -265,13 +264,6 @@ export default {
|
|
|
265
264
|
this.chart.off('mouseover', this.onChartMouseOver);
|
|
266
265
|
},
|
|
267
266
|
methods: {
|
|
268
|
-
defaultFormatTooltipText(params) {
|
|
269
|
-
// eslint-disable-next-line import/no-deprecated
|
|
270
|
-
const { xLabels, tooltipContent } = getDefaultTooltipContent(params, this.options.yAxis.name);
|
|
271
|
-
|
|
272
|
-
this.$set(this, 'dataTooltipContent', tooltipContent);
|
|
273
|
-
this.dataTooltipTitle = xLabels.join(', ');
|
|
274
|
-
},
|
|
275
267
|
defaultAnnotationTooltipText(params) {
|
|
276
268
|
return {
|
|
277
269
|
title: params.data.xAxis,
|
|
@@ -318,9 +310,6 @@ export default {
|
|
|
318
310
|
};
|
|
319
311
|
}
|
|
320
312
|
},
|
|
321
|
-
onLabelChange(params) {
|
|
322
|
-
this.selectedFormatTooltipText(params);
|
|
323
|
-
},
|
|
324
313
|
},
|
|
325
314
|
HEIGHT_AUTO_CLASSES,
|
|
326
315
|
};
|
|
@@ -351,16 +340,21 @@ export default {
|
|
|
351
340
|
</template>
|
|
352
341
|
<div>{{ annotationsTooltipContent }}</div>
|
|
353
342
|
</chart-tooltip>
|
|
354
|
-
<chart-tooltip
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
343
|
+
<chart-tooltip
|
|
344
|
+
v-if="chart"
|
|
345
|
+
ref="dataTooltip"
|
|
346
|
+
:chart="chart"
|
|
347
|
+
:use-default-tooltip-formatter="!formatTooltipText"
|
|
348
|
+
>
|
|
349
|
+
<template v-if="$scopedSlots['tooltip-title']" #title="scope">
|
|
350
|
+
<slot name="tooltip-title" v-bind="scope"></slot>
|
|
351
|
+
</template>
|
|
352
|
+
<template v-if="$scopedSlots['tooltip-content']" #default="scope">
|
|
353
|
+
<slot name="tooltip-content" v-bind="scope"></slot>
|
|
354
|
+
</template>
|
|
355
|
+
<template v-if="$scopedSlots['tooltip-value']" #tooltip-value="scope">
|
|
356
|
+
<slot name="tooltip-value" v-bind="scope"></slot>
|
|
361
357
|
</template>
|
|
362
|
-
<slot v-if="formatTooltipText" name="tooltip-content"></slot>
|
|
363
|
-
<tooltip-default-format v-else :tooltip-content="dataTooltipContent" />
|
|
364
358
|
</chart-tooltip>
|
|
365
359
|
<chart-legend
|
|
366
360
|
v-if="compiledOptions"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import TooltipDefaultFormat from '~/components/shared_components/charts/tooltip_default_format.vue';
|
|
3
2
|
import { createMockChartInstance } from '~helpers/chart_stubs';
|
|
4
3
|
import { expectHeightAutoClasses } from '~helpers/chart_height';
|
|
5
4
|
import Chart from '../chart/chart.vue';
|
|
5
|
+
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
6
6
|
import BarChart from './bar.vue';
|
|
7
7
|
|
|
8
8
|
let mockChartInstance;
|
|
@@ -27,15 +27,14 @@ describe('Bar chart component', () => {
|
|
|
27
27
|
let wrapper;
|
|
28
28
|
|
|
29
29
|
const findChart = () => wrapper.findComponent(Chart);
|
|
30
|
+
const findChartTooltip = () => wrapper.findComponent(ChartTooltip);
|
|
31
|
+
|
|
30
32
|
const getOptions = () => findChart().props('options');
|
|
31
33
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
32
34
|
|
|
33
35
|
const createComponent = (props = {}) => {
|
|
34
36
|
wrapper = shallowMount(BarChart, {
|
|
35
37
|
propsData: { ...defaultChartProps, ...props },
|
|
36
|
-
stubs: {
|
|
37
|
-
'tooltip-default-format': TooltipDefaultFormat,
|
|
38
|
-
},
|
|
39
38
|
});
|
|
40
39
|
};
|
|
41
40
|
|
|
@@ -75,45 +74,10 @@ describe('Bar chart component', () => {
|
|
|
75
74
|
defaultChartProps.data.Office.map(([, name]) => expect(formatter(name)).toMatchSnapshot());
|
|
76
75
|
});
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
seriesData: [
|
|
83
|
-
{
|
|
84
|
-
seriesId: 'Office',
|
|
85
|
-
data: [100, 'Jim'],
|
|
86
|
-
value: [100, 'Jim'],
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
it('calls custom method and returns title with y labels', () => {
|
|
92
|
-
const getDefaultTooltipContentReturnVal = { yLabels: [], tooltipContent: {} };
|
|
93
|
-
|
|
94
|
-
// stub the method
|
|
95
|
-
wrapper.vm.getDefaultTooltipContent = jest
|
|
96
|
-
.fn()
|
|
97
|
-
.mockReturnValue(getDefaultTooltipContentReturnVal);
|
|
98
|
-
|
|
99
|
-
// label formatter is triggered here which should eventually call
|
|
100
|
-
// getDefaultTooltipContent
|
|
101
|
-
getOptions().yAxis.axisPointer.label.formatter(labelParams);
|
|
102
|
-
|
|
103
|
-
return wrapper.vm.$nextTick(() => {
|
|
104
|
-
expect(wrapper.vm.getDefaultTooltipContent).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('sets accurate tooltip title and content state', () => {
|
|
109
|
-
getOptions().yAxis.axisPointer.label.formatter(labelParams);
|
|
110
|
-
|
|
111
|
-
return wrapper.vm.$nextTick(() => {
|
|
112
|
-
expect(wrapper.vm.tooltipTitle).toBe(labelParams.value);
|
|
113
|
-
expect(wrapper.vm.tooltipContent[defaultChartProps.xAxisTitle].value).toBe(
|
|
114
|
-
labelParams.seriesData[0].data[0]
|
|
115
|
-
);
|
|
116
|
-
});
|
|
77
|
+
it('configures chart tooltip', () => {
|
|
78
|
+
expect(findChartTooltip().props()).toMatchObject({
|
|
79
|
+
chart: mockChartInstance,
|
|
80
|
+
useDefaultTooltipFormatter: false,
|
|
117
81
|
});
|
|
118
82
|
});
|
|
119
83
|
});
|
|
@@ -173,21 +173,20 @@ export default {
|
|
|
173
173
|
this.$emit('created', chart);
|
|
174
174
|
},
|
|
175
175
|
onLabelChange(params) {
|
|
176
|
-
const { yLabels, tooltipContent } = this.
|
|
176
|
+
const { yLabels, tooltipContent } = this.getTooltipContent(params, this.xAxisTitle);
|
|
177
177
|
|
|
178
178
|
this.$set(this, 'tooltipContent', tooltipContent);
|
|
179
179
|
this.tooltipTitle = yLabels.join(', ');
|
|
180
180
|
},
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
183
|
-
* However, for bar charts, the tooltip should be against x-axis values.
|
|
182
|
+
* For bar charts, the tooltip should be against x-axis values.
|
|
184
183
|
* This method will be removed after https://gitlab.com/gitlab-org/gitlab-ui/-/issues/674
|
|
185
184
|
*
|
|
186
185
|
* @param {Object} params series data
|
|
187
186
|
* @param {String} xAxisTitle x-axis title
|
|
188
187
|
* @returns {Object} tooltip title and content
|
|
189
188
|
*/
|
|
190
|
-
|
|
189
|
+
getTooltipContent(params, xAxisTitle = null) {
|
|
191
190
|
const seriesDataLength = params.seriesData.length;
|
|
192
191
|
const { yLabels, tooltipContent } = params.seriesData.reduce(
|
|
193
192
|
(acc, chartItem) => {
|
|
@@ -69,10 +69,6 @@ Object {
|
|
|
69
69
|
"show": false,
|
|
70
70
|
},
|
|
71
71
|
"axisPointer": Object {
|
|
72
|
-
"label": Object {
|
|
73
|
-
"formatter": [Function],
|
|
74
|
-
},
|
|
75
|
-
"show": true,
|
|
76
72
|
"type": "none",
|
|
77
73
|
},
|
|
78
74
|
"boundaryGap": true,
|
|
@@ -161,10 +157,6 @@ Object {
|
|
|
161
157
|
"show": false,
|
|
162
158
|
},
|
|
163
159
|
"axisPointer": Object {
|
|
164
|
-
"label": Object {
|
|
165
|
-
"formatter": [Function],
|
|
166
|
-
},
|
|
167
|
-
"show": true,
|
|
168
160
|
"type": "none",
|
|
169
161
|
},
|
|
170
162
|
"boundaryGap": true,
|
|
@@ -290,10 +282,6 @@ Object {
|
|
|
290
282
|
"show": false,
|
|
291
283
|
},
|
|
292
284
|
"axisPointer": Object {
|
|
293
|
-
"label": Object {
|
|
294
|
-
"formatter": [Function],
|
|
295
|
-
},
|
|
296
|
-
"show": true,
|
|
297
285
|
"type": "none",
|
|
298
286
|
},
|
|
299
287
|
"boundaryGap": true,
|
|
@@ -8,15 +8,12 @@ import {
|
|
|
8
8
|
yAxis,
|
|
9
9
|
dataZoomAdjustments,
|
|
10
10
|
mergeSeriesToOptions,
|
|
11
|
-
// eslint-disable-next-line import/no-deprecated
|
|
12
|
-
getDefaultTooltipContent,
|
|
13
11
|
generateBarSeries,
|
|
14
12
|
generateLineSeries,
|
|
15
13
|
} from '../../../utils/charts/config';
|
|
16
14
|
import { CHART_TYPE_LINE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
17
15
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
18
16
|
import { columnOptions } from '../../../utils/constants';
|
|
19
|
-
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format.vue';
|
|
20
17
|
import Chart from '../chart/chart.vue';
|
|
21
18
|
import ChartTooltip from '../tooltip/tooltip.vue';
|
|
22
19
|
|
|
@@ -33,7 +30,6 @@ export default {
|
|
|
33
30
|
components: {
|
|
34
31
|
Chart,
|
|
35
32
|
ChartTooltip,
|
|
36
|
-
TooltipDefaultFormat,
|
|
37
33
|
},
|
|
38
34
|
inheritAttrs: false,
|
|
39
35
|
props: {
|
|
@@ -87,8 +83,6 @@ export default {
|
|
|
87
83
|
data() {
|
|
88
84
|
return {
|
|
89
85
|
chart: null,
|
|
90
|
-
tooltipTitle: '',
|
|
91
|
-
tooltipContent: {},
|
|
92
86
|
};
|
|
93
87
|
},
|
|
94
88
|
computed: {
|
|
@@ -141,11 +135,7 @@ export default {
|
|
|
141
135
|
show: false,
|
|
142
136
|
},
|
|
143
137
|
axisPointer: {
|
|
144
|
-
show: true,
|
|
145
138
|
type: 'none',
|
|
146
|
-
label: {
|
|
147
|
-
formatter: this.onLabelChange,
|
|
148
|
-
},
|
|
149
139
|
},
|
|
150
140
|
name: this.xAxisTitle,
|
|
151
141
|
type: this.xAxisType,
|
|
@@ -180,13 +170,6 @@ export default {
|
|
|
180
170
|
this.chart = chart;
|
|
181
171
|
this.$emit('created', chart);
|
|
182
172
|
},
|
|
183
|
-
onLabelChange(params) {
|
|
184
|
-
// eslint-disable-next-line import/no-deprecated
|
|
185
|
-
const { xLabels, tooltipContent } = getDefaultTooltipContent(params, this.yAxisTitle);
|
|
186
|
-
|
|
187
|
-
this.$set(this, 'tooltipContent', tooltipContent);
|
|
188
|
-
this.tooltipTitle = xLabels.join(', ');
|
|
189
|
-
},
|
|
190
173
|
},
|
|
191
174
|
HEIGHT_AUTO_CLASSES,
|
|
192
175
|
};
|
|
@@ -201,11 +184,6 @@ export default {
|
|
|
201
184
|
v-on="$listeners"
|
|
202
185
|
@created="onCreated"
|
|
203
186
|
/>
|
|
204
|
-
<chart-tooltip v-if="chart" :chart="chart"
|
|
205
|
-
<template #title>
|
|
206
|
-
<div>{{ tooltipTitle }} ({{ xAxisTitle }})</div>
|
|
207
|
-
</template>
|
|
208
|
-
<tooltip-default-format :tooltip-content="tooltipContent" />
|
|
209
|
-
</chart-tooltip>
|
|
187
|
+
<chart-tooltip v-if="chart" :chart="chart" :use-default-tooltip-formatter="true" />
|
|
210
188
|
</div>
|
|
211
189
|
</template>
|