@gitlab/ui 71.9.1 → 71.11.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/components/charts/area/area.js +11 -22
  3. package/dist/components/charts/bar/bar.js +3 -4
  4. package/dist/components/charts/column/column.js +5 -22
  5. package/dist/components/charts/heatmap/heatmap.js +4 -9
  6. package/dist/components/charts/line/line.js +11 -22
  7. package/dist/components/experimental/duo/chat/duo_chat.js +9 -5
  8. package/dist/tokens/common_story_options.js +1 -0
  9. package/dist/tokens/css/tokens.css +14 -1
  10. package/dist/tokens/css/tokens.dark.css +1 -1
  11. package/dist/tokens/js/tokens.dark.js +1 -1
  12. package/dist/tokens/js/tokens.js +14 -1
  13. package/dist/tokens/json/tokens.dark.grouped.json +14 -1
  14. package/dist/tokens/json/tokens.dark.json +264 -0
  15. package/dist/tokens/json/tokens.grouped.json +14 -1
  16. package/dist/tokens/json/tokens.json +264 -0
  17. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  18. package/dist/tokens/scss/_tokens.scss +14 -1
  19. package/package.json +1 -1
  20. package/src/components/charts/area/area.spec.js +82 -7
  21. package/src/components/charts/area/area.stories.js +24 -6
  22. package/src/components/charts/area/area.vue +21 -27
  23. package/src/components/charts/bar/bar.spec.js +7 -43
  24. package/src/components/charts/bar/bar.vue +3 -4
  25. package/src/components/charts/column/__snapshots__/column_chart.spec.js.snap +0 -12
  26. package/src/components/charts/column/column.vue +1 -23
  27. package/src/components/charts/column/column_chart.spec.js +13 -27
  28. package/src/components/charts/heatmap/heatmap.vue +4 -14
  29. package/src/components/charts/line/line.spec.js +120 -38
  30. package/src/components/charts/line/line.stories.js +21 -4
  31. package/src/components/charts/line/line.vue +21 -32
  32. package/src/components/experimental/duo/chat/duo_chat.spec.js +18 -0
  33. package/src/components/experimental/duo/chat/duo_chat.vue +11 -5
  34. package/src/scss/variables.scss +0 -7
  35. package/src/tokens/color.transparency.tokens.json +84 -0
  36. package/src/tokens/color.transparency.tokens.stories.js +26 -0
  37. package/src/tokens/common_story_options.js +1 -0
@@ -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 { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
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 = {}, slots = {} } = {}) => {
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
- slots,
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 is set', () => {
140
- beforeEach(() => {
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
- it('is initialized', () => {
145
- expect(findDataTooltip().props('chart')).toBe(mockChartInstance);
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.onLabelChange,
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 v-if="chart" ref="dataTooltip" :chart="chart">
355
- <template #title>
356
- <slot v-if="formatTooltipText" name="tooltip-title"></slot>
357
- <template v-else>
358
- {{ dataTooltipTitle }}
359
- <template v-if="options.xAxis.name">({{ options.xAxis.name }})</template>
360
- </template>
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
- describe('Tooltip', () => {
79
- const labelParams = {
80
- value: 'Jim',
81
- seriesName: 'Office',
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.getDefaultTooltipContent(params, this.xAxisTitle);
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
- * The existing getDefaultTooltipContent in utils works against the y-axis value.
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
- getDefaultTooltipContent(params, xAxisTitle = null) {
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>
@@ -1,5 +1,5 @@
1
1
  import { shallowMount } from '@vue/test-utils';
2
- import { createMockChartInstance, ChartTooltipStub } from '~helpers/chart_stubs';
2
+ import { createMockChartInstance } from '~helpers/chart_stubs';
3
3
  import { expectHeightAutoClasses } from '~helpers/chart_height';
4
4
  import {
5
5
  mockDefaultLineData,
@@ -8,6 +8,7 @@ import {
8
8
  mockDefaultStackedBarData,
9
9
  } from '../../../utils/charts/mock_data';
10
10
  import Chart from '../chart/chart.vue';
11
+ import ChartTooltip from '../tooltip/tooltip.vue';
11
12
  import ColumnChart from './column.vue';
12
13
 
13
14
  let mockChartInstance;
@@ -27,36 +28,28 @@ describe('column chart component', () => {
27
28
 
28
29
  const chartItemClickedSpy = jest.fn();
29
30
  const findChart = () => wrapper.findComponent(Chart);
30
- const findTooltip = () => wrapper.findComponent(ChartTooltipStub);
31
- const getChartOptions = () => findChart().props('options');
31
+ const findChartTooltip = () => wrapper.findComponent(ChartTooltip);
32
+
33
+ const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
32
34
 
33
35
  const factory = (props = defaultChartProps, slots = {}) => {
34
36
  wrapper = shallowMount(ColumnChart, {
35
37
  propsData: { ...props },
36
- stubs: {
37
- 'chart-tooltip': ChartTooltipStub,
38
- },
39
38
  listeners: {
40
39
  chartItemClicked: chartItemClickedSpy,
41
40
  },
42
- data() {
43
- return {
44
- chart: mockChartInstance,
45
- };
46
- },
47
41
  slots,
48
42
  });
49
43
  };
50
44
 
51
45
  beforeEach(() => {
52
- mockChartInstance = createMockChartInstance();
53
-
54
46
  factory();
47
+
48
+ mockChartInstance = createMockChartInstance();
49
+ emitChartCreated();
55
50
  });
56
51
 
57
52
  it('emits "created" when onCreated is called', () => {
58
- wrapper.vm.onCreated(wrapper.vm.chart);
59
-
60
53
  expect(wrapper.emitted('created')).toHaveLength(1);
61
54
  });
62
55
 
@@ -126,18 +119,11 @@ describe('column chart component', () => {
126
119
  });
127
120
 
128
121
  describe('tooltip', () => {
129
- it('displays the generic tooltip content', async () => {
130
- const params = {
131
- seriesData: [{ seriesIndex: '0', seriesName: 'Full', value: ['Mary', 934] }],
132
- };
133
-
134
- getChartOptions().xAxis.axisPointer.label.formatter(params);
135
-
136
- await wrapper.vm.$nextTick();
137
-
138
- const expectedTooltipTitle = `${params.seriesData[0].value[0]} (${defaultChartProps.xAxisTitle})`;
139
-
140
- expect(findTooltip().text()).toContain(expectedTooltipTitle);
122
+ it('configures chart tooltip', async () => {
123
+ expect(findChartTooltip().props()).toMatchObject({
124
+ chart: mockChartInstance,
125
+ useDefaultTooltipFormatter: true,
126
+ });
141
127
  });
142
128
  });
143
129
 
@@ -2,8 +2,7 @@
2
2
  <script>
3
3
  import merge from 'lodash/merge';
4
4
  import { WHITE, GRAY_100 } from '../../../../dist/tokens/js/tokens';
5
- // eslint-disable-next-line import/no-deprecated
6
- import { getDefaultTooltipContent } from '../../../utils/charts/config';
5
+ import { getTooltipTitle, getTooltipContent } from '../../../utils/charts/config';
7
6
  import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
8
7
  import { heatmapHues } from '../../../utils/charts/theme';
9
8
  import { engineeringNotation } from '../../../utils/number_utils';
@@ -223,14 +222,8 @@ export default {
223
222
  },
224
223
  methods: {
225
224
  defaultFormatTooltipText(params) {
226
- // eslint-disable-next-line import/no-deprecated
227
- const { xLabels, tooltipContent } = getDefaultTooltipContent(
228
- params,
229
- this.computedOptions.yAxis.name
230
- );
231
-
232
- this.$set(this.tooltip, 'content', tooltipContent);
233
- this.tooltip.title = xLabels.join(', ');
225
+ this.tooltip.title = getTooltipTitle(params, this.computedOptions.xAxis.name);
226
+ this.tooltip.content = getTooltipContent(params, this.computedOptions.yAxis.name);
234
227
  },
235
228
  onCreated(chart) {
236
229
  this.chart = chart;
@@ -268,10 +261,7 @@ export default {
268
261
  <chart-tooltip v-if="chart" :chart="chart" :top="tooltip.top" :left="tooltip.left">
269
262
  <template #title>
270
263
  <slot v-if="formatTooltipText" name="tooltip-title"></slot>
271
- <div v-else>
272
- {{ tooltip.title }}
273
- <template v-if="computedOptions.xAxis.name">({{ computedOptions.xAxis.name }})</template>
274
- </div>
264
+ <div v-else>{{ tooltip.title }}</div>
275
265
  </template>
276
266
  <slot v-if="formatTooltipText" name="tooltip-content"></slot>
277
267
  <tooltip-default-format v-else :tooltip-content="tooltip.content" />