@gitlab/ui 40.5.0 → 40.6.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
+ # [40.6.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v40.5.0...v40.6.0) (2022-05-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlLineChart:** allow chart legend to be hidden ([8d9fa8b](https://gitlab.com/gitlab-org/gitlab-ui/commit/8d9fa8b1c352a8894b3e36509402e4388380ffb0))
7
+
1
8
  # [40.5.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v40.4.0...v40.5.0) (2022-05-18)
2
9
 
3
10
 
@@ -82,6 +82,11 @@ var script = {
82
82
  return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
83
83
  }
84
84
 
85
+ },
86
+ showLegend: {
87
+ type: Boolean,
88
+ required: false,
89
+ default: true
85
90
  }
86
91
  },
87
92
 
@@ -197,6 +202,10 @@ var script = {
197
202
  };
198
203
  },
199
204
 
205
+ hasLegend() {
206
+ return this.compiledOptions && this.showLegend;
207
+ },
208
+
200
209
  seriesInfo() {
201
210
  return this.compiledOptions.series.reduce((acc, series, index) => {
202
211
  if (series.type === 'line') {
@@ -311,7 +320,7 @@ var script = {
311
320
  const __vue_script__ = script;
312
321
 
313
322
  /* template */
314
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"position-relative"},[_c('chart',_vm._g(_vm._b({attrs:{"options":_vm.options},on:{"created":_vm.onCreated}},'chart',_vm.$attrs,false),_vm.$listeners)),_vm._v(" "),(_vm.shouldShowAnnotationsTooltip)?_c('chart-tooltip',{ref:"annotationsTooltip",attrs:{"id":"annotationsTooltip","show":_vm.showAnnotationsTooltip,"chart":_vm.chart,"top":_vm.annotationsTooltipPosition.top,"left":_vm.annotationsTooltipPosition.left,"placement":"bottom"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipTitle))])]},proxy:true}],null,false,1889294429)},[_vm._v(" "),_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipContent))])]):_vm._e(),_vm._v(" "),(_vm.chart)?_c('chart-tooltip',{ref:"dataTooltip",staticClass:"gl-pointer-events-none",attrs:{"id":"dataTooltip","show":_vm.showDataTooltip,"chart":_vm.chart,"top":_vm.dataTooltipPosition.top,"left":_vm.dataTooltipPosition.left},scopedSlots:_vm._u([{key:"title",fn:function(){return [(_vm.formatTooltipText)?_vm._t("tooltip-title"):_c('div',[_vm._v("\n "+_vm._s(_vm.dataTooltipTitle)+"\n "),(_vm.options.xAxis.name)?[_vm._v("("+_vm._s(_vm.options.xAxis.name)+")")]:_vm._e()],2)]},proxy:true}],null,true)},[_vm._v(" "),(_vm.formatTooltipText)?_vm._t("tooltip-content"):_c('tooltip-default-format',{attrs:{"tooltip-content":_vm.dataTooltipContent}})],2):_vm._e(),_vm._v(" "),(_vm.compiledOptions)?_c('chart-legend',{style:(_vm.legendStyle),attrs:{"chart":_vm.chart,"series-info":_vm.seriesInfo,"text-style":_vm.compiledOptions.textStyle,"min-text":_vm.legendMinText,"max-text":_vm.legendMaxText,"average-text":_vm.legendAverageText,"current-text":_vm.legendCurrentText,"layout":_vm.legendLayout}}):_vm._e()],1)};
323
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"position-relative"},[_c('chart',_vm._g(_vm._b({attrs:{"options":_vm.options},on:{"created":_vm.onCreated}},'chart',_vm.$attrs,false),_vm.$listeners)),_vm._v(" "),(_vm.shouldShowAnnotationsTooltip)?_c('chart-tooltip',{ref:"annotationsTooltip",attrs:{"id":"annotationsTooltip","show":_vm.showAnnotationsTooltip,"chart":_vm.chart,"top":_vm.annotationsTooltipPosition.top,"left":_vm.annotationsTooltipPosition.left,"placement":"bottom"},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipTitle))])]},proxy:true}],null,false,1889294429)},[_vm._v(" "),_c('div',[_vm._v(_vm._s(_vm.annotationsTooltipContent))])]):_vm._e(),_vm._v(" "),(_vm.chart)?_c('chart-tooltip',{ref:"dataTooltip",staticClass:"gl-pointer-events-none",attrs:{"id":"dataTooltip","show":_vm.showDataTooltip,"chart":_vm.chart,"top":_vm.dataTooltipPosition.top,"left":_vm.dataTooltipPosition.left},scopedSlots:_vm._u([{key:"title",fn:function(){return [(_vm.formatTooltipText)?_vm._t("tooltip-title"):_c('div',[_vm._v("\n "+_vm._s(_vm.dataTooltipTitle)+"\n "),(_vm.options.xAxis.name)?[_vm._v("("+_vm._s(_vm.options.xAxis.name)+")")]:_vm._e()],2)]},proxy:true}],null,true)},[_vm._v(" "),(_vm.formatTooltipText)?_vm._t("tooltip-content"):_c('tooltip-default-format',{attrs:{"tooltip-content":_vm.dataTooltipContent}})],2):_vm._e(),_vm._v(" "),(_vm.hasLegend)?_c('chart-legend',{style:(_vm.legendStyle),attrs:{"chart":_vm.chart,"series-info":_vm.seriesInfo,"text-style":_vm.compiledOptions.textStyle,"min-text":_vm.legendMinText,"max-text":_vm.legendMaxText,"average-text":_vm.legendAverageText,"current-text":_vm.legendCurrentText,"layout":_vm.legendLayout}}):_vm._e()],1)};
315
324
  var __vue_staticRenderFns__ = [];
316
325
 
317
326
  /* style */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "40.5.0",
3
+ "version": "40.6.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -87,15 +87,15 @@
87
87
  "@rollup/plugin-commonjs": "^11.1.0",
88
88
  "@rollup/plugin-node-resolve": "^7.1.3",
89
89
  "@rollup/plugin-replace": "^2.3.2",
90
- "@storybook/addon-a11y": "6.4.22",
91
- "@storybook/addon-docs": "6.4.22",
92
- "@storybook/addon-essentials": "6.4.22",
90
+ "@storybook/addon-a11y": "6.5.0",
91
+ "@storybook/addon-docs": "6.5.0",
92
+ "@storybook/addon-essentials": "6.5.0",
93
93
  "@storybook/addon-knobs": "6.4.0",
94
- "@storybook/addon-storyshots": "6.4.22",
95
- "@storybook/addon-storyshots-puppeteer": "6.4.22",
96
- "@storybook/addon-viewport": "6.4.22",
97
- "@storybook/theming": "6.4.22",
98
- "@storybook/vue": "6.4.22",
94
+ "@storybook/addon-storyshots": "6.5.0",
95
+ "@storybook/addon-storyshots-puppeteer": "6.5.0",
96
+ "@storybook/addon-viewport": "6.5.0",
97
+ "@storybook/theming": "6.5.0",
98
+ "@storybook/vue": "6.5.0",
99
99
  "@vue/test-utils": "1.3.0",
100
100
  "autoprefixer": "^9.7.6",
101
101
  "babel-jest": "^26.6.3",
@@ -195,5 +195,14 @@ describe('line component', () => {
195
195
 
196
196
  expect(findLegend().props('layout')).toBe(LEGEND_LAYOUT_TABLE);
197
197
  });
198
+ it('can be hidden', async () => {
199
+ createShallowWrapper({
200
+ showLegend: false,
201
+ });
202
+
203
+ await wrapper.vm.$nextTick();
204
+
205
+ expect(findLegend().exists()).toBe(false);
206
+ });
198
207
  });
199
208
  });
@@ -62,6 +62,7 @@ const template = `<gl-line-chart
62
62
  :thresholds="thresholds"
63
63
  :annotations="annotations"
64
64
  :includeLegendAvgMax="includeLegendAvgMax"
65
+ :showLegend="showLegend"
65
66
  />`;
66
67
 
67
68
  const generateProps = ({
@@ -70,7 +71,9 @@ const generateProps = ({
70
71
  thresholds = [],
71
72
  annotations = [],
72
73
  includeLegendAvgMax = true,
74
+ showLegend = true,
73
75
  } = {}) => ({
76
+ showLegend,
74
77
  includeLegendAvgMax,
75
78
  option,
76
79
  thresholds,
@@ -173,6 +176,27 @@ WithToolbox.args = generateProps({
173
176
  },
174
177
  });
175
178
 
179
+ export const NoLegend = Template.bind({});
180
+ NoLegend.args = generateProps({
181
+ data: [
182
+ {
183
+ name: 'Time Series',
184
+ data: generateTimeSeries(),
185
+ },
186
+ ],
187
+ option: {
188
+ animation: false,
189
+ xAxis: {
190
+ type: 'time',
191
+ name: 'Time',
192
+ axisLabel: {
193
+ formatter: timeSeriesDateFormatter,
194
+ },
195
+ },
196
+ },
197
+ showLegend: false,
198
+ });
199
+
176
200
  export default {
177
201
  title: 'charts/line-chart',
178
202
  component: GlLineChart,
@@ -117,6 +117,11 @@ export default {
117
117
  return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
118
118
  },
119
119
  },
120
+ showLegend: {
121
+ type: Boolean,
122
+ required: false,
123
+ default: true,
124
+ },
120
125
  },
121
126
  data() {
122
127
  // Part of the tooltip related data can be
@@ -230,6 +235,9 @@ export default {
230
235
  legendStyle() {
231
236
  return { paddingLeft: `${grid.left}px` };
232
237
  },
238
+ hasLegend() {
239
+ return this.compiledOptions && this.showLegend;
240
+ },
233
241
  seriesInfo() {
234
242
  return this.compiledOptions.series.reduce((acc, series, index) => {
235
243
  if (series.type === 'line') {
@@ -366,7 +374,7 @@ export default {
366
374
  <tooltip-default-format v-else :tooltip-content="dataTooltipContent" />
367
375
  </chart-tooltip>
368
376
  <chart-legend
369
- v-if="compiledOptions"
377
+ v-if="hasLegend"
370
378
  :chart="chart"
371
379
  :style="legendStyle"
372
380
  :series-info="seriesInfo"