@gitlab/ui 59.3.2 → 59.4.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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [59.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v59.3.2...v59.4.0) (2023-04-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlAreaChart:** add legend-series-info prop ([6e855cc](https://gitlab.com/gitlab-org/gitlab-ui/commit/6e855cc1260c00a4a5821003b2dd0ec8d082d7bd))
|
|
7
|
+
|
|
1
8
|
## [59.3.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v59.3.1...v59.3.2) (2023-04-05)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -89,6 +89,11 @@ var script = {
|
|
|
89
89
|
type: [Number, String],
|
|
90
90
|
required: false,
|
|
91
91
|
default: null
|
|
92
|
+
},
|
|
93
|
+
legendSeriesInfo: {
|
|
94
|
+
type: Array,
|
|
95
|
+
required: false,
|
|
96
|
+
default: () => []
|
|
92
97
|
}
|
|
93
98
|
},
|
|
94
99
|
data() {
|
|
@@ -194,6 +199,7 @@ var script = {
|
|
|
194
199
|
};
|
|
195
200
|
},
|
|
196
201
|
seriesInfo() {
|
|
202
|
+
if (this.legendSeriesInfo.length > 0) return this.legendSeriesInfo;
|
|
197
203
|
return this.compiledOptions.series.reduce((acc, series, index) => {
|
|
198
204
|
if (series.type === 'line') {
|
|
199
205
|
acc.push({
|
package/package.json
CHANGED
|
@@ -23,12 +23,13 @@ describe('area component', () => {
|
|
|
23
23
|
|
|
24
24
|
const emitChartCreated = () => findChart().vm.$emit('created', mockChartInstance);
|
|
25
25
|
|
|
26
|
-
const createShallowWrapper = (props = {}) => {
|
|
26
|
+
const createShallowWrapper = ({ props = {}, slots = {} } = {}) => {
|
|
27
27
|
wrapper = shallowMount(AreaChart, {
|
|
28
28
|
propsData: { option: { series: [] }, data: [], ...props },
|
|
29
29
|
stubs: {
|
|
30
30
|
'chart-tooltip': ChartTooltipStub,
|
|
31
31
|
},
|
|
32
|
+
slots,
|
|
32
33
|
});
|
|
33
34
|
emitChartCreated();
|
|
34
35
|
};
|
|
@@ -57,12 +58,14 @@ describe('area component', () => {
|
|
|
57
58
|
|
|
58
59
|
it('are displayed if passed via annotations props', async () => {
|
|
59
60
|
createShallowWrapper({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
props: {
|
|
62
|
+
annotations: [
|
|
63
|
+
{
|
|
64
|
+
min: '',
|
|
65
|
+
max: '',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
66
69
|
});
|
|
67
70
|
|
|
68
71
|
await wrapper.vm.$nextTick();
|
|
@@ -72,20 +75,22 @@ describe('area component', () => {
|
|
|
72
75
|
|
|
73
76
|
it('are displayed if passed via option props', async () => {
|
|
74
77
|
createShallowWrapper({
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
props: {
|
|
79
|
+
option: {
|
|
80
|
+
series: [
|
|
81
|
+
{
|
|
82
|
+
name: 'annotations',
|
|
83
|
+
markPoint: {
|
|
84
|
+
data: [
|
|
85
|
+
{
|
|
86
|
+
xAxis: 10,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
data: [],
|
|
85
91
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
],
|
|
92
|
+
],
|
|
93
|
+
},
|
|
89
94
|
},
|
|
90
95
|
});
|
|
91
96
|
|
|
@@ -111,12 +116,14 @@ describe('area component', () => {
|
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
createShallowWrapper({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
props: {
|
|
120
|
+
annotations: [
|
|
121
|
+
{
|
|
122
|
+
min: '',
|
|
123
|
+
max: '',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
120
127
|
});
|
|
121
128
|
|
|
122
129
|
wrapper.vm.onChartDataPointMouseOver(params);
|
|
@@ -166,7 +173,9 @@ describe('area component', () => {
|
|
|
166
173
|
|
|
167
174
|
it('is inline if correct prop value is set', async () => {
|
|
168
175
|
createShallowWrapper({
|
|
169
|
-
|
|
176
|
+
props: {
|
|
177
|
+
legendLayout: LEGEND_LAYOUT_INLINE,
|
|
178
|
+
},
|
|
170
179
|
});
|
|
171
180
|
|
|
172
181
|
await wrapper.vm.$nextTick();
|
|
@@ -176,18 +185,41 @@ describe('area component', () => {
|
|
|
176
185
|
|
|
177
186
|
it('is tabular if correct prop value is set', async () => {
|
|
178
187
|
createShallowWrapper({
|
|
179
|
-
|
|
188
|
+
props: {
|
|
189
|
+
legendLayout: LEGEND_LAYOUT_TABLE,
|
|
190
|
+
},
|
|
180
191
|
});
|
|
181
192
|
|
|
182
193
|
await wrapper.vm.$nextTick();
|
|
183
194
|
|
|
184
195
|
expect(findLegend().props('layout')).toBe(LEGEND_LAYOUT_TABLE);
|
|
185
196
|
});
|
|
197
|
+
|
|
198
|
+
it('displays custom series info when prop is set', async () => {
|
|
199
|
+
const legendSeriesInfo = [
|
|
200
|
+
{
|
|
201
|
+
name: 'Custom Legend Item',
|
|
202
|
+
type: 'solid',
|
|
203
|
+
color: '#000',
|
|
204
|
+
data: [10, 20, 30],
|
|
205
|
+
},
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
createShallowWrapper({
|
|
209
|
+
props: {
|
|
210
|
+
legendSeriesInfo,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
await wrapper.vm.$nextTick();
|
|
215
|
+
|
|
216
|
+
expect(findLegend().props('seriesInfo')).toEqual(expect.arrayContaining(legendSeriesInfo));
|
|
217
|
+
});
|
|
186
218
|
});
|
|
187
219
|
|
|
188
220
|
describe('height', () => {
|
|
189
221
|
expectHeightAutoClasses({
|
|
190
|
-
createComponent: createShallowWrapper,
|
|
222
|
+
createComponent: (props) => createShallowWrapper({ props: { ...props } }),
|
|
191
223
|
findContainer: () => wrapper,
|
|
192
224
|
findChart,
|
|
193
225
|
});
|
|
@@ -2,6 +2,7 @@ import times from 'lodash/times';
|
|
|
2
2
|
import { GlAreaChart } from '../../../charts';
|
|
3
3
|
import { mockAnnotationsSeries, mockAnnotationsConfigs } from '../../../utils/charts/mock_data';
|
|
4
4
|
import { toolbox } from '../../../utils/charts/story_config';
|
|
5
|
+
import { dataVizAqua500, dataVizOrange600 } from '../../../../scss_to_js/scss_variables';
|
|
5
6
|
import { timeSeriesDateFormatter } from '../../../utils/charts/utils';
|
|
6
7
|
import { generateTimeSeries } from '../../../utils/data_utils';
|
|
7
8
|
import { disableControls } from '../../../utils/stories_utils';
|
|
@@ -35,6 +36,7 @@ const template = `<gl-area-chart
|
|
|
35
36
|
:annotations="annotations"
|
|
36
37
|
:includeLegendAvgMax="includeLegendAvgMax"
|
|
37
38
|
:height="height"
|
|
39
|
+
:legendSeriesInfo="legendSeriesInfo"
|
|
38
40
|
/>`;
|
|
39
41
|
|
|
40
42
|
const generateProps = ({
|
|
@@ -44,6 +46,7 @@ const generateProps = ({
|
|
|
44
46
|
annotations = [],
|
|
45
47
|
includeLegendAvgMax = true,
|
|
46
48
|
height = null,
|
|
49
|
+
legendSeriesInfo = [],
|
|
47
50
|
} = {}) => ({
|
|
48
51
|
data,
|
|
49
52
|
option,
|
|
@@ -51,6 +54,7 @@ const generateProps = ({
|
|
|
51
54
|
annotations,
|
|
52
55
|
includeLegendAvgMax,
|
|
53
56
|
height,
|
|
57
|
+
legendSeriesInfo,
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
const Template = (args, { argTypes }) => ({
|
|
@@ -153,6 +157,24 @@ MultSeries.args = generateProps({
|
|
|
153
157
|
})),
|
|
154
158
|
});
|
|
155
159
|
|
|
160
|
+
export const WithCustomLegendItems = Template.bind({});
|
|
161
|
+
WithCustomLegendItems.args = generateProps({
|
|
162
|
+
legendSeriesInfo: [
|
|
163
|
+
{
|
|
164
|
+
name: 'Custom Legend Item 1',
|
|
165
|
+
type: 'solid',
|
|
166
|
+
color: dataVizOrange600,
|
|
167
|
+
data: [10, 20],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'Custom Legend Item 2',
|
|
171
|
+
type: 'solid',
|
|
172
|
+
color: dataVizAqua500,
|
|
173
|
+
data: [30, 50],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
});
|
|
177
|
+
|
|
156
178
|
export default {
|
|
157
179
|
title: 'charts/area-chart',
|
|
158
180
|
component: GlAreaChart,
|
|
@@ -127,6 +127,11 @@ export default {
|
|
|
127
127
|
required: false,
|
|
128
128
|
default: null,
|
|
129
129
|
},
|
|
130
|
+
legendSeriesInfo: {
|
|
131
|
+
type: Array,
|
|
132
|
+
required: false,
|
|
133
|
+
default: () => [],
|
|
134
|
+
},
|
|
130
135
|
},
|
|
131
136
|
data() {
|
|
132
137
|
// Part of the tooltip related data can be
|
|
@@ -244,6 +249,8 @@ export default {
|
|
|
244
249
|
return { paddingLeft: `${grid.left}px` };
|
|
245
250
|
},
|
|
246
251
|
seriesInfo() {
|
|
252
|
+
if (this.legendSeriesInfo.length > 0) return this.legendSeriesInfo;
|
|
253
|
+
|
|
247
254
|
return this.compiledOptions.series.reduce((acc, series, index) => {
|
|
248
255
|
if (series.type === 'line') {
|
|
249
256
|
acc.push({
|