@gitlab/ui 32.44.0 → 32.45.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 +8 -0
- package/dist/components/charts/chart/chart.js +17 -4
- package/dist/components/charts/heatmap/heatmap.js +1 -9
- package/dist/components/charts/sparkline/sparkline.js +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/package.json +1 -1
- package/src/components/charts/chart/chart.spec.js +33 -4
- package/src/components/charts/chart/chart.vue +16 -4
- package/src/components/charts/heatmap/heatmap.vue +2 -9
- package/src/components/charts/sparkline/sparkline.vue +7 -1
- package/src/scss/utilities.scss +8 -0
- package/src/scss/utility-mixins/transform.scss +4 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils';
|
|
|
2
2
|
import * as echarts from 'echarts';
|
|
3
3
|
import Chart from './chart.vue';
|
|
4
4
|
import createTheme from '~/utils/charts/theme';
|
|
5
|
+
import { useMockResizeObserver } from '~helpers/mock_dom_observer';
|
|
5
6
|
|
|
6
7
|
const defaultHeight = 400;
|
|
7
8
|
|
|
@@ -21,11 +22,12 @@ describe('chart component', () => {
|
|
|
21
22
|
const themeName = 'gitlab';
|
|
22
23
|
let wrapper;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
const { trigger: triggerResize } = useMockResizeObserver();
|
|
26
|
+
|
|
27
|
+
it('initializes chart using $refs.chart', async () => {
|
|
25
28
|
wrapper = shallowMount(...mountArgs);
|
|
26
|
-
|
|
29
|
+
await wrapper.vm.$nextTick();
|
|
27
30
|
|
|
28
|
-
it('initializes chart using $refs.chart', () => {
|
|
29
31
|
expect(echarts.init).toHaveBeenCalledWith(
|
|
30
32
|
wrapper.findComponent({ ref: 'chart' }).element,
|
|
31
33
|
themeName,
|
|
@@ -37,11 +39,34 @@ describe('chart component', () => {
|
|
|
37
39
|
);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
|
-
it('
|
|
42
|
+
it('does not resize the chart when responsive = false', async () => {
|
|
43
|
+
wrapper = shallowMount(...mountArgs);
|
|
44
|
+
await wrapper.vm.$nextTick();
|
|
45
|
+
// initial call when chart gets created
|
|
46
|
+
expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
|
|
47
|
+
|
|
48
|
+
triggerResize(wrapper.element);
|
|
49
|
+
expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('resizes the chart when responsive = true', async () => {
|
|
53
|
+
wrapper = shallowMount(Chart, { propsData: { options: {}, responsive: true } });
|
|
54
|
+
await wrapper.vm.$nextTick();
|
|
55
|
+
expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(1);
|
|
56
|
+
|
|
57
|
+
triggerResize(wrapper.element);
|
|
58
|
+
|
|
59
|
+
expect(wrapper.vm.chart.resize).toHaveBeenCalledTimes(2);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('emits "created" after initializing chart', async () => {
|
|
63
|
+
wrapper = shallowMount(...mountArgs);
|
|
64
|
+
await wrapper.vm.$nextTick();
|
|
41
65
|
expect(wrapper.emitted('created')).toEqual([[wrapper.vm.chart]]);
|
|
42
66
|
});
|
|
43
67
|
|
|
44
68
|
it('uses GitLab theme', () => {
|
|
69
|
+
wrapper = shallowMount(...mountArgs);
|
|
45
70
|
const [firstRegisterThemeCall] = echarts.registerTheme.mock.calls;
|
|
46
71
|
expect(firstRegisterThemeCall[0]).toBe(themeName);
|
|
47
72
|
expect(JSON.stringify(firstRegisterThemeCall[1])).toEqual(JSON.stringify(createTheme()));
|
|
@@ -87,6 +112,10 @@ describe('chart component', () => {
|
|
|
87
112
|
});
|
|
88
113
|
|
|
89
114
|
describe('methods', () => {
|
|
115
|
+
beforeEach(() => {
|
|
116
|
+
wrapper = shallowMount(...mountArgs);
|
|
117
|
+
});
|
|
118
|
+
|
|
90
119
|
describe('draw method', () => {
|
|
91
120
|
it('sets chart options', () => {
|
|
92
121
|
wrapper.vm.draw();
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import * as echarts from 'echarts';
|
|
3
3
|
import { defaultHeight, defaultWidth, validRenderers } from '../../../utils/charts/config';
|
|
4
4
|
import createTheme, { themeName } from '../../../utils/charts/theme';
|
|
5
|
+
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
8
|
+
directives: {
|
|
9
|
+
resizeObserver: GlResizeObserverDirective,
|
|
10
|
+
},
|
|
7
11
|
props: {
|
|
8
12
|
options: {
|
|
9
13
|
type: Object,
|
|
@@ -42,6 +46,11 @@ export default {
|
|
|
42
46
|
return validRenderers.includes(renderer);
|
|
43
47
|
},
|
|
44
48
|
},
|
|
49
|
+
responsive: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
required: false,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
45
54
|
},
|
|
46
55
|
data() {
|
|
47
56
|
return {
|
|
@@ -80,7 +89,7 @@ export default {
|
|
|
80
89
|
echarts.connect(this.groupId);
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
this.chart.on('click', this.
|
|
92
|
+
this.chart.on('click', this.handleClick);
|
|
84
93
|
/**
|
|
85
94
|
* Emitted after calling `echarts.init`
|
|
86
95
|
*/
|
|
@@ -89,7 +98,7 @@ export default {
|
|
|
89
98
|
this.setChartSize();
|
|
90
99
|
},
|
|
91
100
|
beforeDestroy() {
|
|
92
|
-
this.chart.off('click', this.
|
|
101
|
+
this.chart.off('click', this.handleClick);
|
|
93
102
|
},
|
|
94
103
|
methods: {
|
|
95
104
|
draw() {
|
|
@@ -105,7 +114,7 @@ export default {
|
|
|
105
114
|
height: this.height || defaultHeight,
|
|
106
115
|
});
|
|
107
116
|
},
|
|
108
|
-
|
|
117
|
+
handleClick(params) {
|
|
109
118
|
/**
|
|
110
119
|
* Emitted when clicked on a data item in the chart (e.g., a bar/column).
|
|
111
120
|
*
|
|
@@ -114,10 +123,13 @@ export default {
|
|
|
114
123
|
*/
|
|
115
124
|
this.$emit('chartItemClicked', { chart: this.chart, params });
|
|
116
125
|
},
|
|
126
|
+
handleResize() {
|
|
127
|
+
if (this.responsive) this.chart.resize();
|
|
128
|
+
},
|
|
117
129
|
},
|
|
118
130
|
};
|
|
119
131
|
</script>
|
|
120
132
|
|
|
121
133
|
<template>
|
|
122
|
-
<div ref="chart"></div>
|
|
134
|
+
<div ref="chart" v-resize-observer="handleResize"></div>
|
|
123
135
|
</template>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
3
|
import { white, gray100 } from '../../../../scss_to_js/scss_variables';
|
|
4
|
-
import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
|
|
5
4
|
import { getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
6
5
|
import { TOOLTIP_LEFT_OFFSET } from '../../../utils/charts/constants';
|
|
7
6
|
import { heatmapHues } from '../../../utils/charts/theme';
|
|
@@ -49,9 +48,6 @@ export default {
|
|
|
49
48
|
ChartTooltip,
|
|
50
49
|
TooltipDefaultFormat,
|
|
51
50
|
},
|
|
52
|
-
directives: {
|
|
53
|
-
resizeObserver: GlResizeObserverDirective,
|
|
54
|
-
},
|
|
55
51
|
mixins: [ToolboxMixin],
|
|
56
52
|
props: {
|
|
57
53
|
options: {
|
|
@@ -237,9 +233,6 @@ export default {
|
|
|
237
233
|
this.chart = chart;
|
|
238
234
|
this.$emit('created', chart);
|
|
239
235
|
},
|
|
240
|
-
handleResize() {
|
|
241
|
-
return this.responsive && this.chart.resize();
|
|
242
|
-
},
|
|
243
236
|
showHideTooltip(mouseEvent) {
|
|
244
237
|
this.tooltip.show = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
245
238
|
},
|
|
@@ -262,8 +255,8 @@ export default {
|
|
|
262
255
|
</script>
|
|
263
256
|
|
|
264
257
|
<template>
|
|
265
|
-
<div
|
|
266
|
-
<chart :options="computedOptions" @created="onCreated" />
|
|
258
|
+
<div class="gl-heatmap">
|
|
259
|
+
<chart v-bind="$attrs" :options="computedOptions" @created="onCreated" v-on="$listeners" />
|
|
267
260
|
<chart-tooltip
|
|
268
261
|
v-if="chart"
|
|
269
262
|
:show="tooltip.show"
|
|
@@ -181,7 +181,13 @@ export default {
|
|
|
181
181
|
>
|
|
182
182
|
<slot name="default"></slot>
|
|
183
183
|
<div class="gl-flex-grow-1 gl-relative">
|
|
184
|
-
<chart
|
|
184
|
+
<chart
|
|
185
|
+
v-bind="$attrs"
|
|
186
|
+
:height="height"
|
|
187
|
+
:options="options"
|
|
188
|
+
@created="onChartCreated"
|
|
189
|
+
v-on="$listeners"
|
|
190
|
+
/>
|
|
185
191
|
<chart-tooltip
|
|
186
192
|
v-if="chartInstance"
|
|
187
193
|
:show="tooltip.show"
|
package/src/scss/utilities.scss
CHANGED
|
@@ -6113,6 +6113,14 @@
|
|
|
6113
6113
|
transform: translateX(100%) !important
|
|
6114
6114
|
}
|
|
6115
6115
|
|
|
6116
|
+
.gl-translate-x-n50 {
|
|
6117
|
+
transform: translateX(-50%)
|
|
6118
|
+
}
|
|
6119
|
+
|
|
6120
|
+
.gl-translate-x-n50\! {
|
|
6121
|
+
transform: translateX(-50%) !important
|
|
6122
|
+
}
|
|
6123
|
+
|
|
6116
6124
|
.gl-translate-y-0 {
|
|
6117
6125
|
transform: translateY(0)
|
|
6118
6126
|
}
|