@gitlab/ui 68.8.0 → 69.1.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 +40 -0
- package/dist/components/charts/area/area.js +3 -30
- package/dist/components/charts/bar/bar.js +2 -2
- package/dist/components/charts/column/column.js +2 -2
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +1 -0
- package/dist/components/charts/heatmap/heatmap.js +2 -2
- package/dist/components/charts/line/line.js +3 -3
- package/dist/components/charts/stacked_column/stacked_column.js +2 -2
- package/dist/components/charts/tooltip/tooltip.js +121 -12
- 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/scss/_tokens.dark.scss +1 -1
- package/dist/tokens/scss/_tokens.scss +1 -1
- package/dist/utility_classes.css +1 -1
- package/dist/utility_classes.css.map +1 -1
- package/dist/utils/charts/constants.js +4 -12
- package/package.json +2 -2
- package/src/components/charts/area/area.spec.js +2 -19
- package/src/components/charts/area/area.vue +3 -40
- package/src/components/charts/bar/bar.vue +2 -2
- package/src/components/charts/column/column.vue +2 -6
- package/src/components/charts/discrete_scatter/discrete_scatter.vue +1 -0
- package/src/components/charts/heatmap/heatmap.spec.js +1 -2
- package/src/components/charts/heatmap/heatmap.vue +2 -2
- package/src/components/charts/line/line.vue +2 -4
- package/src/components/charts/sparkline/sparkline.spec.js +6 -6
- package/src/components/charts/stacked_column/stacked_column.vue +1 -2
- package/src/components/charts/tooltip/tooltip.spec.js +158 -11
- package/src/components/charts/tooltip/tooltip.vue +117 -23
- package/src/scss/utilities.scss +90 -46
- package/src/scss/utility-mixins/flex.scss +6 -14
- package/src/scss/utility-mixins/sizing.scss +24 -7
- package/src/scss/utility-mixins/spacing.scss +18 -8
- package/src/utils/charts/constants.js +3 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
# [69.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v69.0.0...v69.1.0) (2023-11-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **css:** Add gl-{size}-mr-0 utility classes ([4ce256c](https://gitlab.com/gitlab-org/gitlab-ui/commit/4ce256c8eba06c8ecdbddb67c92b2a097e415518))
|
|
7
|
+
|
|
8
|
+
# [69.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v68.8.0...v69.0.0) (2023-11-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **css:** remove desktop-first CSS utils ([797f198](https://gitlab.com/gitlab-org/gitlab-ui/commit/797f19868bf6cd4d10e1c7775744391e82aa81e1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **css:** add responsive CSS utils ([ca0d144](https://gitlab.com/gitlab-org/gitlab-ui/commit/ca0d1440f861fa0b83f0446d34c66661f329450d))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
* **css:** This removes the remaining desktop-first CSS utilities
|
|
24
|
+
form the library. Any usages of those should be replaced with
|
|
25
|
+
mobile-first alternatives. See below for replacement suggestions. Note
|
|
26
|
+
that the proposed replacements should work in the most simple cases.
|
|
27
|
+
Some use cases might require using different utils combinations.
|
|
28
|
+
|
|
29
|
+
* `gl-sm-flex-direction-column`
|
|
30
|
+
Replace with `gl-flex-direction-column gl-md-flex-direction-row`.
|
|
31
|
+
|
|
32
|
+
* `gl-xs-flex-direction-column`
|
|
33
|
+
Replace with `gl-flex-direction-column gl-sm-flex-direction-row`.
|
|
34
|
+
|
|
35
|
+
* `gl-xs-w-full`
|
|
36
|
+
Replace with `gl-w-full gl-sm-w-auto`.
|
|
37
|
+
|
|
38
|
+
* `gl-xs-mb-3`
|
|
39
|
+
Replace with `gl-mb-3 gl-sm-mb-0`.
|
|
40
|
+
|
|
1
41
|
# [68.8.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v68.7.0...v68.8.0) (2023-11-15)
|
|
2
42
|
|
|
3
43
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import { defaultAreaOpacity, lineStyle, getThresholdConfig, generateAnnotationSeries, defaultChartOptions, dataZoomAdjustments, mergeSeriesToOptions, mergeAnnotationAxisToOptions, grid, getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
3
|
-
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE,
|
|
3
|
+
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
4
4
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
5
5
|
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
6
|
-
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
7
6
|
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format';
|
|
8
7
|
import Chart from '../chart/chart';
|
|
9
8
|
import ChartLegend from '../legend/legend';
|
|
@@ -104,13 +103,8 @@ var script = {
|
|
|
104
103
|
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
|
|
105
104
|
return {
|
|
106
105
|
chart: null,
|
|
107
|
-
showDataTooltip: false,
|
|
108
106
|
dataTooltipTitle: '',
|
|
109
107
|
dataTooltipContent: {},
|
|
110
|
-
dataTooltipPosition: {
|
|
111
|
-
left: '0',
|
|
112
|
-
top: '0'
|
|
113
|
-
},
|
|
114
108
|
showAnnotationsTooltip: false,
|
|
115
109
|
annotationsTooltipTitle: '',
|
|
116
110
|
annotationsTooltipContent: '',
|
|
@@ -118,7 +112,6 @@ var script = {
|
|
|
118
112
|
left: '0',
|
|
119
113
|
top: '0'
|
|
120
114
|
},
|
|
121
|
-
debouncedShowHideTooltip: debounceByAnimationFrame(this.showHideTooltip),
|
|
122
115
|
selectedFormatTooltipText: this.formatTooltipText || this.defaultFormatTooltipText
|
|
123
116
|
};
|
|
124
117
|
},
|
|
@@ -218,8 +211,6 @@ var script = {
|
|
|
218
211
|
}
|
|
219
212
|
},
|
|
220
213
|
beforeDestroy() {
|
|
221
|
-
this.chart.getZr().off('mousemove', this.debouncedShowHideTooltip);
|
|
222
|
-
this.chart.getZr().off('mouseout', this.debouncedShowHideTooltip);
|
|
223
214
|
this.chart.off('mouseout', this.hideAnnotationsTooltip);
|
|
224
215
|
this.chart.off('mouseover', this.onChartMouseOver);
|
|
225
216
|
},
|
|
@@ -240,13 +231,6 @@ var script = {
|
|
|
240
231
|
};
|
|
241
232
|
},
|
|
242
233
|
onCreated(chart) {
|
|
243
|
-
// These listeners are used to show/hide data tooltips
|
|
244
|
-
// when the mouse is hovered over the parent container
|
|
245
|
-
// of echarts' svg element. This works only for data points
|
|
246
|
-
// and not markPoints.
|
|
247
|
-
chart.getZr().on('mousemove', this.debouncedShowHideTooltip);
|
|
248
|
-
chart.getZr().on('mouseout', this.debouncedShowHideTooltip);
|
|
249
|
-
|
|
250
234
|
// eCharts inbuild mouse events
|
|
251
235
|
// https://echarts.apache.org/en/api.html#events.Mouse%20events
|
|
252
236
|
// is used to attach listeners to markPoints. These listeners
|
|
@@ -256,7 +240,6 @@ var script = {
|
|
|
256
240
|
// sections of the charts with their own mouseovers and mouseouts,
|
|
257
241
|
// there shouldn't be an overlapping situation where both tooltips
|
|
258
242
|
// are visible.
|
|
259
|
-
|
|
260
243
|
if (this.hasAnnotations) {
|
|
261
244
|
chart.on('mouseout', this.onChartDataPointMouseOut);
|
|
262
245
|
chart.on('mouseover', this.onChartDataPointMouseOver);
|
|
@@ -264,16 +247,6 @@ var script = {
|
|
|
264
247
|
this.chart = chart;
|
|
265
248
|
this.$emit('created', chart);
|
|
266
249
|
},
|
|
267
|
-
showHideTooltip(_ref) {
|
|
268
|
-
let {
|
|
269
|
-
event: mouseEvent
|
|
270
|
-
} = _ref;
|
|
271
|
-
this.showDataTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
272
|
-
this.dataTooltipPosition = {
|
|
273
|
-
left: `${mouseEvent.zrX + DATA_TOOLTIP_LEFT_OFFSET}px`,
|
|
274
|
-
top: `${mouseEvent.zrY}px`
|
|
275
|
-
};
|
|
276
|
-
},
|
|
277
250
|
onChartDataPointMouseOut() {
|
|
278
251
|
this.showAnnotationsTooltip = false;
|
|
279
252
|
},
|
|
@@ -296,7 +269,7 @@ var script = {
|
|
|
296
269
|
this.annotationsTooltipContent = content;
|
|
297
270
|
this.annotationsTooltipPosition = {
|
|
298
271
|
left: `${event.event.zrX}px`,
|
|
299
|
-
top: `${event.event.zrY
|
|
272
|
+
top: `${event.event.zrY}px`
|
|
300
273
|
};
|
|
301
274
|
}
|
|
302
275
|
},
|
|
@@ -313,7 +286,7 @@ const __vue_script__ = script;
|
|
|
313
286
|
/* template */
|
|
314
287
|
var __vue_render__ = function () {
|
|
315
288
|
var _obj;
|
|
316
|
-
var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"position-relative",class:( _obj = {}, _obj[_vm.$options.HEIGHT_AUTO_CLASSES] = _vm.autoHeight, _obj )},[_c('chart',_vm._g(_vm._b({class:{ 'gl-flex-grow-1': _vm.autoHeight },attrs:{"height":_vm.height,"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,"
|
|
289
|
+
var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"position-relative",class:( _obj = {}, _obj[_vm.$options.HEIGHT_AUTO_CLASSES] = _vm.autoHeight, _obj )},[_c('chart',_vm._g(_vm._b({class:{ 'gl-flex-grow-1': _vm.autoHeight },attrs:{"height":_vm.height,"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,"top":_vm.annotationsTooltipPosition.top,"left":_vm.annotationsTooltipPosition.left,"chart":_vm.chart,"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",attrs:{"chart":_vm.chart},scopedSlots:_vm._u([{key:"title",fn:function(){return [(_vm.formatTooltipText)?_vm._t("tooltip-title"):[_vm._v("\n "+_vm._s(_vm.dataTooltipTitle)+"\n "),(_vm.options.xAxis.name)?[_vm._v("("+_vm._s(_vm.options.xAxis.name)+")")]:_vm._e()]]},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)};
|
|
317
290
|
var __vue_staticRenderFns__ = [];
|
|
318
291
|
|
|
319
292
|
/* style */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import truncate from 'lodash/truncate';
|
|
3
3
|
import { dataZoomAdjustments, mergeSeriesToOptions, grid } from '../../../utils/charts/config';
|
|
4
|
-
import {
|
|
4
|
+
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
5
5
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
6
6
|
import { engineeringNotation } from '../../../utils/number_utils';
|
|
7
7
|
import { debounceByAnimationFrame, hexToRgba } from '../../../utils/utils';
|
|
@@ -177,7 +177,7 @@ var script = {
|
|
|
177
177
|
event: mouseEvent
|
|
178
178
|
} = _ref;
|
|
179
179
|
this.tooltipPosition = {
|
|
180
|
-
left: `${mouseEvent.zrX
|
|
180
|
+
left: `${mouseEvent.zrX}px`,
|
|
181
181
|
top: `${mouseEvent.zrY}px`
|
|
182
182
|
};
|
|
183
183
|
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import { yAxis, generateBarSeries, generateLineSeries, defaultChartOptions, gridWithSecondaryYAxis, grid, dataZoomAdjustments, mergeSeriesToOptions, getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
3
|
-
import { CHART_TYPE_LINE,
|
|
3
|
+
import { CHART_TYPE_LINE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
4
4
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
5
5
|
import { columnOptions } from '../../../utils/constants';
|
|
6
6
|
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
@@ -198,7 +198,7 @@ var script = {
|
|
|
198
198
|
methods: {
|
|
199
199
|
moveShowTooltip(mouseEvent) {
|
|
200
200
|
this.tooltipPosition = {
|
|
201
|
-
left: `${mouseEvent.zrX
|
|
201
|
+
left: `${mouseEvent.zrX}px`,
|
|
202
202
|
top: `${mouseEvent.zrY}px`
|
|
203
203
|
};
|
|
204
204
|
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import { GRAY_100, WHITE } from '../../../../dist/tokens/js/tokens';
|
|
3
3
|
import { getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
4
|
-
import {
|
|
4
|
+
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
5
5
|
import { heatmapHues } from '../../../utils/charts/theme';
|
|
6
6
|
import { engineeringNotation } from '../../../utils/number_utils';
|
|
7
7
|
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
@@ -261,7 +261,7 @@ var script = {
|
|
|
261
261
|
}, value);
|
|
262
262
|
this.tooltip = {
|
|
263
263
|
...this.tooltip,
|
|
264
|
-
left: `${left
|
|
264
|
+
left: `${left}px`,
|
|
265
265
|
top: `${top}px`
|
|
266
266
|
};
|
|
267
267
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import { GRAY_200 } from '../../../../dist/tokens/js/tokens';
|
|
3
3
|
import { symbolSize, lineStyle, getThresholdConfig, generateAnnotationSeries, defaultChartOptions, dataZoomAdjustments, mergeSeriesToOptions, mergeAnnotationAxisToOptions, grid, getDefaultTooltipContent } from '../../../utils/charts/config';
|
|
4
|
-
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE,
|
|
4
|
+
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
5
5
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
6
6
|
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
7
7
|
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
@@ -263,7 +263,7 @@ var script = {
|
|
|
263
263
|
showHideTooltip(mouseEvent) {
|
|
264
264
|
this.showDataTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
265
265
|
this.dataTooltipPosition = {
|
|
266
|
-
left: `${mouseEvent.zrX
|
|
266
|
+
left: `${mouseEvent.zrX}px`,
|
|
267
267
|
top: `${mouseEvent.zrY}px`
|
|
268
268
|
};
|
|
269
269
|
},
|
|
@@ -289,7 +289,7 @@ var script = {
|
|
|
289
289
|
this.annotationsTooltipContent = content;
|
|
290
290
|
this.annotationsTooltipPosition = {
|
|
291
291
|
left: `${event.event.zrX}px`,
|
|
292
|
-
top: `${event.event.zrY
|
|
292
|
+
top: `${event.event.zrY}px`
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
295
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
2
|
import { yAxis, generateBarSeries, generateLineSeries, defaultChartOptions, gridWithSecondaryYAxis, grid, dataZoomAdjustments, mergeSeriesToOptions } from '../../../utils/charts/config';
|
|
3
|
-
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, CHART_TYPE_LINE,
|
|
3
|
+
import { LEGEND_AVERAGE_TEXT, LEGEND_MAX_TEXT, LEGEND_MIN_TEXT, LEGEND_CURRENT_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE, CHART_TYPE_LINE, HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
4
4
|
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
5
5
|
import { columnOptions } from '../../../utils/constants';
|
|
6
6
|
import { debounceByAnimationFrame } from '../../../utils/utils';
|
|
@@ -280,7 +280,7 @@ var script = {
|
|
|
280
280
|
} = _ref4;
|
|
281
281
|
this.tooltipPosition = {
|
|
282
282
|
left: `${mouseEvent.zrX}px`,
|
|
283
|
-
top: `${mouseEvent.zrY
|
|
283
|
+
top: `${mouseEvent.zrY}px`
|
|
284
284
|
};
|
|
285
285
|
this.showTooltip = this.chart.containPixel('grid', [mouseEvent.zrX, mouseEvent.zrY]);
|
|
286
286
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as echarts from 'echarts';
|
|
2
|
-
import { uid } from '../../../utils/utils';
|
|
2
|
+
import { uid, debounceByAnimationFrame } from '../../../utils/utils';
|
|
3
3
|
import GlPopover from '../../base/popover/popover';
|
|
4
4
|
import { popoverPlacements } from '../../../utils/constants';
|
|
5
|
+
import { TOOLTIP_LEFT_OFFSET, TOOLTIP_TOP_OFFSET } from '../../../utils/charts/constants';
|
|
5
6
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
6
7
|
|
|
7
8
|
//
|
|
@@ -24,47 +25,155 @@ var script = {
|
|
|
24
25
|
required: false,
|
|
25
26
|
default: () => uid()
|
|
26
27
|
},
|
|
28
|
+
/**
|
|
29
|
+
* Position of the popover respective to the chart.
|
|
30
|
+
* Sets the `top` style property.
|
|
31
|
+
*/
|
|
27
32
|
top: {
|
|
28
33
|
type: String,
|
|
29
34
|
required: false,
|
|
30
35
|
default: null
|
|
31
36
|
},
|
|
37
|
+
/**
|
|
38
|
+
* Position of the popover respective to the chart.
|
|
39
|
+
* Sets the `bottom` style property.
|
|
40
|
+
*/
|
|
32
41
|
bottom: {
|
|
33
42
|
type: String,
|
|
34
43
|
required: false,
|
|
35
44
|
default: null
|
|
36
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* Position of the popover respective to the chart.
|
|
48
|
+
* Sets the `left` style property.
|
|
49
|
+
*/
|
|
37
50
|
left: {
|
|
38
51
|
type: String,
|
|
39
52
|
required: false,
|
|
40
53
|
default: null
|
|
41
54
|
},
|
|
55
|
+
/**
|
|
56
|
+
* Position of the popover respective to the chart.
|
|
57
|
+
* Sets the `right` style property.
|
|
58
|
+
*/
|
|
42
59
|
right: {
|
|
43
60
|
type: String,
|
|
44
61
|
required: false,
|
|
45
62
|
default: null
|
|
46
63
|
},
|
|
64
|
+
/**
|
|
65
|
+
* Set to `true` to show, set to `false` to not show.
|
|
66
|
+
* Set to `null` to show only when the mouse is in the chart.
|
|
67
|
+
*/
|
|
68
|
+
show: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
required: false,
|
|
71
|
+
default: null
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* Popover placement
|
|
75
|
+
*/
|
|
47
76
|
placement: {
|
|
48
77
|
type: String,
|
|
49
78
|
required: false,
|
|
50
79
|
default: popoverPlacements.right
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Distance between the popover and the pointer when
|
|
83
|
+
* no position is defined
|
|
84
|
+
*/
|
|
85
|
+
xOffset: {
|
|
86
|
+
type: Number,
|
|
87
|
+
required: false,
|
|
88
|
+
default: TOOLTIP_LEFT_OFFSET,
|
|
89
|
+
validator(value) {
|
|
90
|
+
// popover target must have a size of at least 1
|
|
91
|
+
return value >= 1;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Distance between the popover and the pointer when
|
|
96
|
+
* no position is defined
|
|
97
|
+
*/
|
|
98
|
+
yOffset: {
|
|
99
|
+
type: Number,
|
|
100
|
+
required: false,
|
|
101
|
+
default: TOOLTIP_TOP_OFFSET,
|
|
102
|
+
validator(value) {
|
|
103
|
+
// popover target must have a size of at least 1
|
|
104
|
+
return value >= 1;
|
|
105
|
+
}
|
|
51
106
|
}
|
|
52
107
|
},
|
|
108
|
+
data() {
|
|
109
|
+
return {
|
|
110
|
+
pointerPosition: null,
|
|
111
|
+
isPointerInChart: false,
|
|
112
|
+
debouncedMouseHandler: debounceByAnimationFrame(this.mouseHandler)
|
|
113
|
+
};
|
|
114
|
+
},
|
|
53
115
|
computed: {
|
|
54
|
-
|
|
116
|
+
targetId() {
|
|
55
117
|
// if multiple tooltips are used in a chart component,
|
|
56
118
|
// `this.id` can be used to uniquely identify them
|
|
57
119
|
return `${this.chart.getDom().getAttribute('_echarts_instance_')}-tooltip-${this.id}`;
|
|
58
120
|
},
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
121
|
+
targetStyle() {
|
|
122
|
+
// the target is a rectangular space between cursor and popover
|
|
123
|
+
return {
|
|
124
|
+
marginTop: `${-this.yOffset}px`,
|
|
125
|
+
height: `${this.yOffset * 2}px`,
|
|
126
|
+
marginLeft: `${-this.xOffset}px`,
|
|
127
|
+
width: `${this.xOffset * 2}px`
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
fixedPosition() {
|
|
131
|
+
const {
|
|
132
|
+
top,
|
|
133
|
+
left,
|
|
134
|
+
bottom,
|
|
135
|
+
right
|
|
136
|
+
} = this;
|
|
137
|
+
if (top || left || bottom || right) {
|
|
138
|
+
return {
|
|
139
|
+
top,
|
|
140
|
+
left,
|
|
141
|
+
bottom,
|
|
142
|
+
right
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
},
|
|
147
|
+
shouldShowPopover() {
|
|
148
|
+
if (this.show !== null) {
|
|
149
|
+
return this.show;
|
|
150
|
+
}
|
|
151
|
+
return this.isPointerInChart;
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
created() {
|
|
155
|
+
this.chart.getZr().on('mousemove', this.debouncedMouseHandler);
|
|
156
|
+
this.chart.getZr().on('mouseout', this.debouncedMouseHandler);
|
|
157
|
+
},
|
|
158
|
+
beforeDestroy() {
|
|
159
|
+
this.chart.getZr().off('mousemove', this.debouncedMouseHandler);
|
|
160
|
+
this.chart.getZr().off('mouseout', this.debouncedMouseHandler);
|
|
161
|
+
},
|
|
162
|
+
methods: {
|
|
163
|
+
mouseHandler(event) {
|
|
164
|
+
let {
|
|
165
|
+
zrX: x,
|
|
166
|
+
zrY: y
|
|
167
|
+
} = event.event;
|
|
168
|
+
if (Number.isFinite(x) && Number.isFinite(y)) {
|
|
169
|
+
x = Math.round(x);
|
|
170
|
+
y = Math.round(y);
|
|
171
|
+
this.pointerPosition = {
|
|
172
|
+
left: `${x}px`,
|
|
173
|
+
top: `${y}px`
|
|
174
|
+
};
|
|
175
|
+
this.isPointerInChart = this.chart.containPixel('grid', [x, y]);
|
|
176
|
+
}
|
|
68
177
|
}
|
|
69
178
|
}
|
|
70
179
|
};
|
|
@@ -73,7 +182,7 @@ var script = {
|
|
|
73
182
|
const __vue_script__ = script;
|
|
74
183
|
|
|
75
184
|
/* template */
|
|
76
|
-
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('div',{staticClass:"gl-chart-tooltip",
|
|
185
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.chart)?_c('div',{staticClass:"gl-pointer-events-none"},[_c('div',{staticClass:"gl-chart-tooltip",style:(Object.assign({}, (_vm.fixedPosition || _vm.pointerPosition), _vm.targetStyle)),attrs:{"id":_vm.targetId}}),_vm._v(" "),_c('gl-popover',_vm._b({attrs:{"show":_vm.shouldShowPopover,"target":_vm.targetId,"container":_vm.targetId,"placement":_vm.placement,"triggers":""},scopedSlots:_vm._u([(_vm.$scopedSlots.title)?{key:"title",fn:function(){return [_vm._t("title")]},proxy:true}:null],null,true)},'gl-popover',_vm.$attrs,false),[_vm._v(" "),_vm._t("default")],2)],1):_vm._e()};
|
|
77
186
|
var __vue_staticRenderFns__ = [];
|
|
78
187
|
|
|
79
188
|
/* style */
|
package/dist/tokens/js/tokens.js
CHANGED