@gitlab/ui 72.12.0 → 72.12.1
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 +7 -0
- package/dist/charts.js +14 -0
- package/dist/components/base/accordion/accordion.js +73 -0
- package/dist/components/base/accordion/accordion_item.js +133 -0
- package/dist/components/base/alert/alert.js +222 -0
- package/dist/components/base/avatar/avatar.js +160 -0
- package/dist/components/base/avatar_labeled/avatar_labeled.js +107 -0
- package/dist/components/base/avatar_link/avatar_link.js +47 -0
- package/dist/components/base/avatars_inline/avatars_inline.js +119 -0
- package/dist/components/base/badge/badge.js +105 -0
- package/dist/components/base/banner/banner.js +139 -0
- package/dist/components/base/breadcrumb/breadcrumb.js +122 -0
- package/dist/components/base/breadcrumb/breadcrumb_item.js +73 -0
- package/dist/components/base/broadcast_message/broadcast_message.js +112 -0
- package/dist/components/base/broadcast_message/constants.js +5 -0
- package/dist/components/base/button/button.js +151 -0
- package/dist/components/base/button_group/button_group.js +47 -0
- package/dist/components/base/card/card.js +71 -0
- package/dist/components/base/carousel/carousel.js +48 -0
- package/dist/components/base/carousel/carousel_slide.js +47 -0
- package/dist/components/base/collapse/collapse.js +59 -0
- package/dist/components/base/datepicker/datepicker.js +386 -0
- package/dist/components/base/daterange_picker/daterange_picker.js +288 -0
- package/dist/components/base/drawer/drawer.js +127 -0
- package/dist/components/base/dropdown/dropdown.js +261 -0
- package/dist/components/base/dropdown/dropdown_divider.js +48 -0
- package/dist/components/base/dropdown/dropdown_form.js +48 -0
- package/dist/components/base/dropdown/dropdown_item.js +131 -0
- package/dist/components/base/dropdown/dropdown_section_header.js +48 -0
- package/dist/components/base/dropdown/dropdown_text.js +48 -0
- package/dist/components/base/filtered_search/common_story_options.js +14 -0
- package/dist/components/base/filtered_search/filtered_search.js +388 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion.js +89 -0
- package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +138 -0
- package/dist/components/base/filtered_search/filtered_search_term.js +203 -0
- package/dist/components/base/filtered_search/filtered_search_token.js +384 -0
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +420 -0
- package/dist/components/base/filtered_search/filtered_search_utils.js +242 -0
- package/dist/components/base/form/form.js +49 -0
- package/dist/components/base/form/form_checkbox/form_checkbox.js +78 -0
- package/dist/components/base/form/form_checkbox/form_checkbox_group.js +60 -0
- package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +79 -0
- package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +138 -0
- package/dist/components/base/form/form_checkbox_tree/models/constants.js +12 -0
- package/dist/components/base/form/form_checkbox_tree/models/node.js +51 -0
- package/dist/components/base/form/form_checkbox_tree/models/tree.js +199 -0
- package/dist/components/base/form/form_combobox/constants.js +55 -0
- package/dist/components/base/form/form_combobox/form_combobox.js +230 -0
- package/dist/components/base/form/form_date/form_date.js +143 -0
- package/dist/components/base/form/form_fields/form_field_validator.js +93 -0
- package/dist/components/base/form/form_fields/form_fields.js +214 -0
- package/dist/components/base/form/form_fields/mappers.js +13 -0
- package/dist/components/base/form/form_fields/validators.js +48 -0
- package/dist/components/base/form/form_group/form_group.js +97 -0
- package/dist/components/base/form/form_input/form_input.js +121 -0
- package/dist/components/base/form/form_input_group/form_input_group.js +108 -0
- package/dist/components/base/form/form_input_group/form_input_group_mixin.js +41 -0
- package/dist/components/base/form/form_radio/form_radio.js +65 -0
- package/dist/components/base/form/form_radio_group/form_radio_group.js +78 -0
- package/dist/components/base/form/form_select/constants.js +12 -0
- package/dist/components/base/form/form_select/form_select.js +82 -0
- package/dist/components/base/form/form_text/form_text.js +38 -0
- package/dist/components/base/form/form_textarea/form_textarea.js +112 -0
- package/dist/components/base/form/input_group_text/input_group_text.js +48 -0
- package/dist/components/base/icon/icon.js +111 -0
- package/dist/components/base/infinite_scroll/infinite_scroll.js +197 -0
- package/dist/components/base/keyset_pagination/keyset_pagination.js +151 -0
- package/dist/components/base/label/label.js +163 -0
- package/dist/components/base/link/link.js +50 -0
- package/dist/components/base/loading_icon/loading_icon.js +111 -0
- package/dist/components/base/markdown/markdown.js +52 -0
- package/dist/components/base/modal/modal.js +204 -0
- package/dist/components/base/nav/nav.js +48 -0
- package/dist/components/base/nav/nav_item.js +48 -0
- package/dist/components/base/nav/nav_item_dropdown.js +62 -0
- package/dist/components/base/navbar/navbar.js +48 -0
- package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +453 -0
- package/dist/components/base/new_dropdowns/base_dropdown/constants.js +4 -0
- package/dist/components/base/new_dropdowns/constants.js +21 -0
- package/dist/components/base/new_dropdowns/disclosure/constants.js +8 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +370 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +110 -0
- package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +143 -0
- package/dist/components/base/new_dropdowns/disclosure/mock_data.js +147 -0
- package/dist/components/base/new_dropdowns/disclosure/utils.js +39 -0
- package/dist/components/base/new_dropdowns/listbox/listbox.js +767 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_group.js +58 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_item.js +91 -0
- package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +93 -0
- package/dist/components/base/new_dropdowns/listbox/mock_data.js +118 -0
- package/dist/components/base/new_dropdowns/listbox/utils.js +34 -0
- package/dist/components/base/paginated_list/paginated_list.js +180 -0
- package/dist/components/base/pagination/pagination.js +399 -0
- package/dist/components/base/path/data.js +34 -0
- package/dist/components/base/path/path.js +189 -0
- package/dist/components/base/popover/popover.js +110 -0
- package/dist/components/base/progress_bar/progress_bar.js +48 -0
- package/dist/components/base/search_box_by_click/search_box_by_click.js +235 -0
- package/dist/components/base/search_box_by_type/search_box_by_type.js +167 -0
- package/dist/components/base/segmented_control/segmented_control.js +109 -0
- package/dist/components/base/skeleton_loader/skeleton_loader.js +224 -0
- package/dist/components/base/sorting/sorting.js +171 -0
- package/dist/components/base/sorting/sorting_item.js +109 -0
- package/dist/components/base/table/constants.js +5 -0
- package/dist/components/base/table/table.js +89 -0
- package/dist/components/base/table_lite/table_lite.js +72 -0
- package/dist/components/base/tabs/constants.js +3 -0
- package/dist/components/base/tabs/tab/tab.js +83 -0
- package/dist/components/base/tabs/tabs/scrollable_tabs.js +143 -0
- package/dist/components/base/tabs/tabs/tabs.js +224 -0
- package/dist/components/base/toast/toast.js +82 -0
- package/dist/components/base/toggle/toggle.js +180 -0
- package/dist/components/base/token/token.js +85 -0
- package/dist/components/base/token_selector/helpers.js +5 -0
- package/dist/components/base/token_selector/token_container.js +165 -0
- package/dist/components/base/token_selector/token_selector.js +403 -0
- package/dist/components/base/token_selector/token_selector_dropdown.js +199 -0
- package/dist/components/base/tooltip/tooltip.js +55 -0
- package/dist/components/charts/area/area.js +311 -0
- package/dist/components/charts/bar/bar.js +253 -0
- package/dist/components/charts/chart/chart.js +215 -0
- package/dist/components/charts/column/column.js +226 -0
- package/dist/components/charts/discrete_scatter/discrete_scatter.js +203 -0
- package/dist/components/charts/gauge/gauge.js +208 -0
- package/dist/components/charts/heatmap/heatmap.js +295 -0
- package/dist/components/charts/heatmap/index.js +2 -0
- package/dist/components/charts/legend/legend.js +228 -0
- package/dist/components/charts/line/line.js +308 -0
- package/dist/components/charts/series_label/series_label.js +100 -0
- package/dist/components/charts/single_stat/single_stat.js +152 -0
- package/dist/components/charts/sparkline/sparkline.js +261 -0
- package/dist/components/charts/stacked_column/stacked_column.js +335 -0
- package/dist/components/charts/tooltip/tooltip.js +251 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +83 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +100 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +35 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +115 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +104 -0
- package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +64 -0
- package/dist/components/experimental/duo/chat/constants.js +23 -0
- package/dist/components/experimental/duo/chat/duo_chat.js +359 -0
- package/dist/components/experimental/duo/chat/mock_data.js +83 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback.js +94 -0
- package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +124 -0
- package/dist/components/experimental/experiment_badge/constants.js +4 -0
- package/dist/components/experimental/experiment_badge/experiment_badge.js +107 -0
- package/dist/components/mixins/button_mixin.js +11 -0
- package/dist/components/mixins/safe_link_mixin.js +30 -0
- package/dist/components/mixins/tooltip_mixin.js +21 -0
- package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +53 -0
- package/dist/components/regions/empty_state/empty_state.js +154 -0
- package/dist/components/shared_components/charts/tooltip_default_format.js +53 -0
- package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +64 -0
- package/dist/components/shared_components/close_button/close_button.js +54 -0
- package/dist/components/utilities/animated_number/animated_number.js +131 -0
- package/dist/components/utilities/friendly_wrap/friendly_wrap.js +75 -0
- package/dist/components/utilities/intersection_observer/intersection_observer.js +88 -0
- package/dist/components/utilities/intersperse/intersperse.js +86 -0
- package/dist/components/utilities/sprintf/sprintf.js +172 -0
- package/dist/components/utilities/truncate/constants.js +7 -0
- package/dist/components/utilities/truncate/truncate.js +111 -0
- package/dist/components/utilities/truncate_text/constants.js +7 -0
- package/dist/components/utilities/truncate_text/truncate_text.js +146 -0
- package/dist/config.js +86 -0
- package/dist/directives/collapse_toggle.js +1 -0
- package/dist/directives/hover_load/hover_load.js +45 -0
- package/dist/directives/modal.js +1 -0
- package/dist/directives/outside/get_event_like_time_stamp.js +33 -0
- package/dist/directives/outside/outside.js +106 -0
- package/dist/directives/resize_observer/resize_observer.js +51 -0
- package/dist/directives/safe_html/constants.js +6 -0
- package/dist/directives/safe_html/safe_html.js +39 -0
- package/dist/directives/safe_link/mock_data.js +10 -0
- package/dist/directives/safe_link/safe_link.js +65 -0
- package/dist/directives/tooltip.js +1 -0
- package/dist/index.css +7 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +105 -0
- package/dist/tokens/common_story_options.js +54 -0
- 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/utils/breakpoints.js +20 -0
- package/dist/utils/charts/config.js +556 -0
- package/dist/utils/charts/constants.js +63 -0
- package/dist/utils/charts/mock_data.js +211 -0
- package/dist/utils/charts/story_config.js +42 -0
- package/dist/utils/charts/theme.js +192 -0
- package/dist/utils/charts/utils.js +54 -0
- package/dist/utils/constants.js +288 -0
- package/dist/utils/data_utils.js +21 -0
- package/dist/utils/datetime_utility.js +61 -0
- package/dist/utils/i18n.js +15 -0
- package/dist/utils/is_slot_empty.js +38 -0
- package/dist/utils/number_utils.js +124 -0
- package/dist/utils/stories_constants.js +29 -0
- package/dist/utils/stories_utils.js +13 -0
- package/dist/utils/story_decorators/container.js +16 -0
- package/dist/utils/string_utils.js +69 -0
- package/dist/utils/svgs/svg_paths.js +7 -0
- package/dist/utils/test_utils.js +33 -0
- package/dist/utils/use_fake_date.js +29 -0
- package/dist/utils/use_mock_intersection_observer.js +108 -0
- package/dist/utils/utils.js +197 -0
- package/dist/utils.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as echarts from 'echarts';
|
|
2
|
+
import { GRAY_200 } from '../../../../dist/tokens/js/tokens';
|
|
3
|
+
import { defaultFontSize } from '../../../utils/charts/config';
|
|
4
|
+
import { LEGEND_AVERAGE_TEXT, LEGEND_CURRENT_TEXT, LEGEND_MIN_TEXT, LEGEND_MAX_TEXT, LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE } from '../../../utils/charts/constants';
|
|
5
|
+
import { engineeringNotation, average } from '../../../utils/number_utils';
|
|
6
|
+
import GlTruncate from '../../utilities/truncate/truncate';
|
|
7
|
+
import GlChartSeriesLabel from '../series_label/series_label';
|
|
8
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
var script = {
|
|
12
|
+
name: 'GlChartLegend',
|
|
13
|
+
components: {
|
|
14
|
+
GlChartSeriesLabel,
|
|
15
|
+
GlTruncate
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
chart: {
|
|
19
|
+
type: Object,
|
|
20
|
+
required: true,
|
|
21
|
+
validator(chart) {
|
|
22
|
+
return Object.is(chart, echarts.getInstanceByDom(chart.getDom()));
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
seriesInfo: {
|
|
26
|
+
type: Array,
|
|
27
|
+
required: true,
|
|
28
|
+
validator(seriesInfo) {
|
|
29
|
+
return seriesInfo.every(series => series.type && series.name && series.color);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
textStyle: {
|
|
33
|
+
type: Object,
|
|
34
|
+
required: false,
|
|
35
|
+
default: () => ({})
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Text for data average (overridden by prop if needed for internationalization)
|
|
39
|
+
*/
|
|
40
|
+
averageText: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false,
|
|
43
|
+
default: LEGEND_AVERAGE_TEXT
|
|
44
|
+
},
|
|
45
|
+
currentText: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: false,
|
|
48
|
+
default: LEGEND_CURRENT_TEXT
|
|
49
|
+
},
|
|
50
|
+
minText: {
|
|
51
|
+
type: String,
|
|
52
|
+
required: false,
|
|
53
|
+
default: LEGEND_MIN_TEXT
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Text for max amount (overridden by prop if needed for internationalization)
|
|
57
|
+
*/
|
|
58
|
+
maxText: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: false,
|
|
61
|
+
default: LEGEND_MAX_TEXT
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Sets the display layout
|
|
65
|
+
*/
|
|
66
|
+
layout: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: false,
|
|
69
|
+
default: LEGEND_LAYOUT_INLINE,
|
|
70
|
+
validator(layout) {
|
|
71
|
+
return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
data() {
|
|
76
|
+
return {
|
|
77
|
+
disabledSeries: {},
|
|
78
|
+
lastActiveSeriesLabel: null
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
fontStyle() {
|
|
83
|
+
return {
|
|
84
|
+
fontFamily: this.textStyle.fontFamily || 'sans-serif',
|
|
85
|
+
fontSize: `${this.textStyle.fontSize || defaultFontSize}px`
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
hasOneSeriesElement() {
|
|
89
|
+
return this.seriesInfo.length === 1;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
created() {
|
|
93
|
+
this.chart.on('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
|
|
94
|
+
},
|
|
95
|
+
beforeDestroy() {
|
|
96
|
+
this.chart.off('legendselectchanged', this.suppressLastActiveSeriesLabelToggle);
|
|
97
|
+
},
|
|
98
|
+
methods: {
|
|
99
|
+
sanitizeSeriesData(seriesData) {
|
|
100
|
+
var _seriesData$filter;
|
|
101
|
+
return (_seriesData$filter = seriesData === null || seriesData === void 0 ? void 0 : seriesData.filter(d => !Number.isNaN(d))) !== null && _seriesData$filter !== void 0 ? _seriesData$filter : [];
|
|
102
|
+
},
|
|
103
|
+
seriesAverage(seriesData) {
|
|
104
|
+
const sanitized = this.sanitizeSeriesData(seriesData);
|
|
105
|
+
return engineeringNotation(average(...sanitized));
|
|
106
|
+
},
|
|
107
|
+
seriesMax(seriesData) {
|
|
108
|
+
const sanitized = this.sanitizeSeriesData(seriesData);
|
|
109
|
+
return engineeringNotation(Math.max(...sanitized));
|
|
110
|
+
},
|
|
111
|
+
seriesMin(seriesData) {
|
|
112
|
+
const sanitized = this.sanitizeSeriesData(seriesData);
|
|
113
|
+
return engineeringNotation(Math.min(...sanitized));
|
|
114
|
+
},
|
|
115
|
+
seriesLast(seriesData) {
|
|
116
|
+
const sanitized = this.sanitizeSeriesData(seriesData);
|
|
117
|
+
return engineeringNotation(sanitized[sanitized.length - 1]);
|
|
118
|
+
},
|
|
119
|
+
seriesNameIsLong(seriesName) {
|
|
120
|
+
return seriesName.length > 120;
|
|
121
|
+
},
|
|
122
|
+
handleClick(_ref, key) {
|
|
123
|
+
let {
|
|
124
|
+
name,
|
|
125
|
+
disabled
|
|
126
|
+
} = _ref;
|
|
127
|
+
if (this.hasOneSeriesElement || this.isToggleDisabled(name, disabled)) return;
|
|
128
|
+
this.chart.dispatchAction({
|
|
129
|
+
type: 'legendToggleSelect',
|
|
130
|
+
name
|
|
131
|
+
});
|
|
132
|
+
this.disabledSeries = {
|
|
133
|
+
...this.disabledSeries,
|
|
134
|
+
[key]: !this.disabledSeries[key]
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
handleMouseEnter(name) {
|
|
138
|
+
this.chart.dispatchAction({
|
|
139
|
+
type: 'highlight',
|
|
140
|
+
seriesName: name
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
handleMouseLeave(name) {
|
|
144
|
+
this.chart.dispatchAction({
|
|
145
|
+
type: 'downplay',
|
|
146
|
+
seriesName: name
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
getColor(color, key) {
|
|
150
|
+
return this.disabledSeries[key] ? GRAY_200 : color;
|
|
151
|
+
},
|
|
152
|
+
suppressLastActiveSeriesLabelToggle(_ref2) {
|
|
153
|
+
let {
|
|
154
|
+
selected
|
|
155
|
+
} = _ref2;
|
|
156
|
+
const selectedSeriesLabels = Object.entries(selected).filter(_ref3 => {
|
|
157
|
+
let [, isSelected] = _ref3;
|
|
158
|
+
return Boolean(isSelected);
|
|
159
|
+
});
|
|
160
|
+
this.lastActiveSeriesLabel = null;
|
|
161
|
+
if (selectedSeriesLabels.length === 1) {
|
|
162
|
+
const [lastActiveSeriesLabelName] = selectedSeriesLabels[0];
|
|
163
|
+
this.lastActiveSeriesLabel = lastActiveSeriesLabelName;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Disables toggling legend if it is the last active one or if its data series
|
|
168
|
+
* has a disabled property set to true
|
|
169
|
+
* @param {String} name Series name
|
|
170
|
+
* @param {Boolean} isDisabled Value of the series element's disabled property
|
|
171
|
+
* @returns {boolean}
|
|
172
|
+
*/
|
|
173
|
+
isToggleDisabled(name, isDisabled) {
|
|
174
|
+
return name === this.lastActiveSeriesLabel || isDisabled;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
legendLayoutTypes: {
|
|
178
|
+
LEGEND_LAYOUT_INLINE,
|
|
179
|
+
LEGEND_LAYOUT_TABLE
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/* script */
|
|
184
|
+
const __vue_script__ = script;
|
|
185
|
+
|
|
186
|
+
/* template */
|
|
187
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-legend",attrs:{"data-testid":"gl-chart-legend"}},[(_vm.layout === _vm.$options.legendLayoutTypes.LEGEND_LAYOUT_INLINE)?[_c('div',{staticClass:"gl-legend-inline"},_vm._l((_vm.seriesInfo),function(series,key){return _c('div',{key:key,staticClass:"gl-legend-inline-series",class:{
|
|
188
|
+
'text-muted': _vm.disabledSeries[key],
|
|
189
|
+
'w-100': _vm.seriesNameIsLong(series.name),
|
|
190
|
+
'gl-hover-cursor-not-allowed!':
|
|
191
|
+
_vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),
|
|
192
|
+
},style:(_vm.fontStyle),attrs:{"aria-disabled":_vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),"role":"button"},on:{"click":function($event){return _vm.handleClick(series, key)},"mouseenter":function($event){return _vm.handleMouseEnter(series.name)},"mouseleave":function($event){return _vm.handleMouseLeave(series.name)}}},[_c('gl-chart-series-label',{staticClass:"gl-legend-inline-series-label",class:{ 'w-75': _vm.seriesNameIsLong(series.name) },attrs:{"color":_vm.getColor(series.color, key),"type":series.type}},[_c('gl-truncate',{staticClass:"gl-font-weight-bold",attrs:{"text":series.name}})],1),_vm._v(" "),(series.data && series.data.length)?_c('span',{class:{ 'gl-white-space-nowrap': _vm.seriesNameIsLong(series.name) }},[_vm._v("\n "+_vm._s(_vm.averageText)+": "+_vm._s(_vm.seriesAverage(series.data))+" · "+_vm._s(_vm.maxText)+":\n "+_vm._s(_vm.seriesMax(series.data))+"\n ")]):_vm._e()],1)}),0)]:_vm._e(),_vm._v(" "),(_vm.layout === _vm.$options.legendLayoutTypes.LEGEND_LAYOUT_TABLE)?[_c('div',{staticClass:"gl-legend-tabular",style:(_vm.fontStyle)},[_c('header',{staticClass:"gl-legend-tabular-header"},[_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.minText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.maxText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.averageText))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-header-cell"},[_vm._v(_vm._s(_vm.currentText))])]),_vm._v(" "),_c('section',{staticClass:"gl-legend-tabular-body"},_vm._l((_vm.seriesInfo),function(series,key){return _c('div',{key:key,staticClass:"gl-legend-tabular-row",class:{
|
|
193
|
+
'text-muted': _vm.disabledSeries[key],
|
|
194
|
+
'gl-hover-cursor-not-allowed!':
|
|
195
|
+
_vm.hasOneSeriesElement || _vm.isToggleDisabled(series.name, series.disabled),
|
|
196
|
+
},style:(_vm.fontStyle),attrs:{"aria-disabled":_vm.isToggleDisabled(series.name, series.disabled),"role":"button"},on:{"click":function($event){return _vm.handleClick(series, key)},"mouseenter":function($event){return _vm.handleMouseEnter(series.name)},"mouseleave":function($event){return _vm.handleMouseLeave(series.name)}}},[_c('div',{staticClass:"gl-legend-tabular-title-cell"},[_c('gl-chart-series-label',{style:(_vm.fontStyle),attrs:{"color":_vm.getColor(series.color, key),"type":series.type}},[_c('gl-truncate',{staticClass:"gl-font-weight-bold",attrs:{"text":series.name}})],1)],1),_vm._v(" "),(_vm.sanitizeSeriesData(series.data).length)?[_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesMin(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesMax(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesAverage(series.data)))]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v(_vm._s(_vm.seriesLast(series.data)))])]:[_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")]),_vm._v(" "),_c('div',{staticClass:"gl-legend-tabular-details-cell"},[_vm._v("-")])]],2)}),0)])]:_vm._e()],2)};
|
|
197
|
+
var __vue_staticRenderFns__ = [];
|
|
198
|
+
|
|
199
|
+
/* style */
|
|
200
|
+
const __vue_inject_styles__ = undefined;
|
|
201
|
+
/* scoped */
|
|
202
|
+
const __vue_scope_id__ = undefined;
|
|
203
|
+
/* module identifier */
|
|
204
|
+
const __vue_module_identifier__ = undefined;
|
|
205
|
+
/* functional template */
|
|
206
|
+
const __vue_is_functional_template__ = false;
|
|
207
|
+
/* style inject */
|
|
208
|
+
|
|
209
|
+
/* style inject SSR */
|
|
210
|
+
|
|
211
|
+
/* style inject shadow dom */
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
const __vue_component__ = __vue_normalize__(
|
|
216
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
217
|
+
__vue_inject_styles__,
|
|
218
|
+
__vue_script__,
|
|
219
|
+
__vue_scope_id__,
|
|
220
|
+
__vue_is_functional_template__,
|
|
221
|
+
__vue_module_identifier__,
|
|
222
|
+
false,
|
|
223
|
+
undefined,
|
|
224
|
+
undefined,
|
|
225
|
+
undefined
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
export default __vue_component__;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
import { GRAY_200 } from '../../../../dist/tokens/js/tokens';
|
|
3
|
+
import { symbolSize, lineStyle, getThresholdConfig, generateAnnotationSeries, defaultChartOptions, dataZoomAdjustments, mergeSeriesToOptions, mergeAnnotationAxisToOptions, grid } from '../../../utils/charts/config';
|
|
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
|
+
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
6
|
+
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
7
|
+
import Chart from '../chart/chart';
|
|
8
|
+
import ChartLegend from '../legend/legend';
|
|
9
|
+
import ChartTooltip from '../tooltip/tooltip';
|
|
10
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
var script = {
|
|
14
|
+
name: 'GlLineChart',
|
|
15
|
+
components: {
|
|
16
|
+
Chart,
|
|
17
|
+
ChartLegend,
|
|
18
|
+
ChartTooltip
|
|
19
|
+
},
|
|
20
|
+
inheritAttrs: false,
|
|
21
|
+
props: {
|
|
22
|
+
data: {
|
|
23
|
+
type: Array,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
option: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: false,
|
|
29
|
+
default: () => ({})
|
|
30
|
+
},
|
|
31
|
+
thresholds: {
|
|
32
|
+
type: Array,
|
|
33
|
+
required: false,
|
|
34
|
+
default: () => []
|
|
35
|
+
},
|
|
36
|
+
annotations: {
|
|
37
|
+
type: Array,
|
|
38
|
+
required: false,
|
|
39
|
+
default: () => []
|
|
40
|
+
},
|
|
41
|
+
includeLegendAvgMax: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
required: false,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Callback called when showing or refreshing a tooltip.
|
|
48
|
+
* **Deprecated:** Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
49
|
+
*
|
|
50
|
+
* @deprecated Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
51
|
+
*/
|
|
52
|
+
formatTooltipText: {
|
|
53
|
+
type: Function,
|
|
54
|
+
required: false,
|
|
55
|
+
default: null
|
|
56
|
+
},
|
|
57
|
+
legendAverageText: {
|
|
58
|
+
type: String,
|
|
59
|
+
required: false,
|
|
60
|
+
default: LEGEND_AVERAGE_TEXT
|
|
61
|
+
},
|
|
62
|
+
legendMaxText: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: false,
|
|
65
|
+
default: LEGEND_MAX_TEXT
|
|
66
|
+
},
|
|
67
|
+
legendMinText: {
|
|
68
|
+
type: String,
|
|
69
|
+
required: false,
|
|
70
|
+
default: LEGEND_MIN_TEXT
|
|
71
|
+
},
|
|
72
|
+
legendCurrentText: {
|
|
73
|
+
type: String,
|
|
74
|
+
required: false,
|
|
75
|
+
default: LEGEND_CURRENT_TEXT
|
|
76
|
+
},
|
|
77
|
+
legendLayout: {
|
|
78
|
+
type: String,
|
|
79
|
+
required: false,
|
|
80
|
+
default: LEGEND_LAYOUT_INLINE,
|
|
81
|
+
validator(layout) {
|
|
82
|
+
return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
showLegend: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
required: false,
|
|
88
|
+
default: true
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Sets the chart's height in pixels. Set to `"auto"` to use the height of the container.
|
|
92
|
+
*/
|
|
93
|
+
height: {
|
|
94
|
+
type: [Number, String],
|
|
95
|
+
required: false,
|
|
96
|
+
default: null
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
data() {
|
|
100
|
+
// Part of the tooltip related data can be
|
|
101
|
+
// moved into the tooltip component.
|
|
102
|
+
// Tracking that progress in
|
|
103
|
+
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
|
|
104
|
+
return {
|
|
105
|
+
chart: null,
|
|
106
|
+
showAnnotationsTooltip: false,
|
|
107
|
+
annotationsTooltipTitle: '',
|
|
108
|
+
annotationsTooltipContent: '',
|
|
109
|
+
annotationsTooltipPosition: {
|
|
110
|
+
left: '0',
|
|
111
|
+
top: '0'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
computed: {
|
|
116
|
+
series() {
|
|
117
|
+
const dataSeries = this.data.map((series, index) => {
|
|
118
|
+
const defaultColor = colorFromDefaultPalette(index);
|
|
119
|
+
const getColor = type => {
|
|
120
|
+
var _series$type$color, _series$type;
|
|
121
|
+
return (_series$type$color = (_series$type = series[type]) === null || _series$type === void 0 ? void 0 : _series$type.color) !== null && _series$type$color !== void 0 ? _series$type$color : defaultColor;
|
|
122
|
+
};
|
|
123
|
+
return merge({
|
|
124
|
+
showSymbol: true,
|
|
125
|
+
lineStyle: {
|
|
126
|
+
color: getColor('lineStyle')
|
|
127
|
+
},
|
|
128
|
+
itemStyle: {
|
|
129
|
+
color: getColor('itemStyle')
|
|
130
|
+
}
|
|
131
|
+
}, symbolSize, lineStyle, series, getThresholdConfig(this.thresholds));
|
|
132
|
+
});
|
|
133
|
+
// if annotation series exists, append it
|
|
134
|
+
// along with data series
|
|
135
|
+
if (this.annotationSeries) {
|
|
136
|
+
return [...dataSeries, this.annotationSeries];
|
|
137
|
+
}
|
|
138
|
+
return dataSeries;
|
|
139
|
+
},
|
|
140
|
+
annotationSeries() {
|
|
141
|
+
return generateAnnotationSeries(this.annotations);
|
|
142
|
+
},
|
|
143
|
+
options() {
|
|
144
|
+
const defaultLineChartOptions = {
|
|
145
|
+
xAxis: {
|
|
146
|
+
axisPointer: {
|
|
147
|
+
show: true,
|
|
148
|
+
label: {
|
|
149
|
+
formatter: this.formatTooltipText
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
axisTick: {
|
|
153
|
+
alignWithLabel: true,
|
|
154
|
+
show: true,
|
|
155
|
+
lineStyle: {
|
|
156
|
+
color: GRAY_200
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
legend: {
|
|
161
|
+
show: false
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const mergedOptions = merge({}, defaultChartOptions, defaultLineChartOptions, this.option, dataZoomAdjustments(this.option.dataZoom));
|
|
165
|
+
// All chart options can be merged but series
|
|
166
|
+
// needs to be handled specially
|
|
167
|
+
return mergeSeriesToOptions(mergeAnnotationAxisToOptions(mergedOptions, this.hasAnnotations), this.series);
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Annotations currently are passed as series options in monitoring dashboard.
|
|
171
|
+
* Once https://gitlab.com/gitlab-org/gitlab/-/issues/213390 is closed,
|
|
172
|
+
* annotations will be passed as props and not as series options.
|
|
173
|
+
*
|
|
174
|
+
* For backward compatibility, we're having to check for both.
|
|
175
|
+
*/
|
|
176
|
+
hasAnnotations() {
|
|
177
|
+
return this.annotations.length !== 0 || seriesHasAnnotations(this.option.series);
|
|
178
|
+
},
|
|
179
|
+
shouldShowAnnotationsTooltip() {
|
|
180
|
+
return this.chart && this.hasAnnotations;
|
|
181
|
+
},
|
|
182
|
+
compiledOptions() {
|
|
183
|
+
return this.chart ? this.chart.getOption() : null;
|
|
184
|
+
},
|
|
185
|
+
legendStyle() {
|
|
186
|
+
return {
|
|
187
|
+
paddingLeft: `${grid.left}px`
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
hasLegend() {
|
|
191
|
+
return this.compiledOptions && this.showLegend;
|
|
192
|
+
},
|
|
193
|
+
seriesInfo() {
|
|
194
|
+
return this.compiledOptions.series.reduce((acc, series, index) => {
|
|
195
|
+
if (series.type === 'line') {
|
|
196
|
+
acc.push({
|
|
197
|
+
name: series.name,
|
|
198
|
+
type: series.lineStyle.type,
|
|
199
|
+
color: series.lineStyle.color || colorFromDefaultPalette(index),
|
|
200
|
+
data: this.includeLegendAvgMax ? series.data.map(data => data[1]) : undefined
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return acc;
|
|
204
|
+
}, []);
|
|
205
|
+
},
|
|
206
|
+
autoHeight() {
|
|
207
|
+
return this.height === 'auto';
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
beforeDestroy() {
|
|
211
|
+
this.chart.off('mouseout', this.onChartDataPointMouseOut);
|
|
212
|
+
this.chart.off('mouseover', this.onChartDataPointMouseOver);
|
|
213
|
+
},
|
|
214
|
+
methods: {
|
|
215
|
+
defaultAnnotationTooltipText(params) {
|
|
216
|
+
var _params$data$tooltipD;
|
|
217
|
+
return {
|
|
218
|
+
title: params.data.xAxis,
|
|
219
|
+
content: (_params$data$tooltipD = params.data.tooltipData) === null || _params$data$tooltipD === void 0 ? void 0 : _params$data$tooltipD.content
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
onCreated(chart) {
|
|
223
|
+
// eCharts inbuild mouse events
|
|
224
|
+
// https://echarts.apache.org/en/api.html#events.Mouse%20events
|
|
225
|
+
// is used to attach listeners to markPoints. These listeners
|
|
226
|
+
// are currently used for annotation arrows at the bottom of the chart.
|
|
227
|
+
|
|
228
|
+
// Because data points and annotations arrows are in different
|
|
229
|
+
// sections of the charts with their own mouseovers and mouseouts,
|
|
230
|
+
// there shouldn't be an overlapping situation where both tooltips
|
|
231
|
+
// are visible.
|
|
232
|
+
|
|
233
|
+
if (this.hasAnnotations) {
|
|
234
|
+
chart.on('mouseout', this.onChartDataPointMouseOut);
|
|
235
|
+
chart.on('mouseover', this.onChartDataPointMouseOver);
|
|
236
|
+
}
|
|
237
|
+
this.chart = chart;
|
|
238
|
+
this.$emit('created', chart);
|
|
239
|
+
},
|
|
240
|
+
onChartDataPointMouseOut() {
|
|
241
|
+
this.showAnnotationsTooltip = false;
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Check if the hovered data point is an annotation
|
|
245
|
+
* point to show the annotation tooltip.
|
|
246
|
+
*/
|
|
247
|
+
onChartDataPointMouseOver(params) {
|
|
248
|
+
if (isDataPointAnnotation(params)) {
|
|
249
|
+
const {
|
|
250
|
+
event
|
|
251
|
+
} = params;
|
|
252
|
+
const toolTipFormatter = this.formatAnnotationsTooltipText || this.defaultAnnotationTooltipText;
|
|
253
|
+
const {
|
|
254
|
+
title = '',
|
|
255
|
+
content = ''
|
|
256
|
+
} = toolTipFormatter(params);
|
|
257
|
+
this.showAnnotationsTooltip = true;
|
|
258
|
+
this.annotationsTooltipTitle = title;
|
|
259
|
+
this.annotationsTooltipContent = content;
|
|
260
|
+
this.annotationsTooltipPosition = {
|
|
261
|
+
left: `${event.event.zrX}px`,
|
|
262
|
+
top: `${event.event.zrY}px`
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
HEIGHT_AUTO_CLASSES
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/* script */
|
|
271
|
+
const __vue_script__ = script;
|
|
272
|
+
|
|
273
|
+
/* template */
|
|
274
|
+
var __vue_render__ = function () {
|
|
275
|
+
var _obj;
|
|
276
|
+
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,"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",attrs:{"chart":_vm.chart,"use-default-tooltip-formatter":!_vm.formatTooltipText},scopedSlots:_vm._u([(_vm.$scopedSlots['tooltip-title'])?{key:"title",fn:function(scope){return [_vm._t("tooltip-title",null,null,scope)]}}:null,(_vm.$scopedSlots['tooltip-content'])?{key:"default",fn:function(scope){return [_vm._t("tooltip-content",null,null,scope)]}}:null,(_vm.$scopedSlots['tooltip-value'])?{key:"tooltip-value",fn:function(scope){return [_vm._t("tooltip-value",null,null,scope)]}}:null],null,true)}):_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)};
|
|
277
|
+
var __vue_staticRenderFns__ = [];
|
|
278
|
+
|
|
279
|
+
/* style */
|
|
280
|
+
const __vue_inject_styles__ = undefined;
|
|
281
|
+
/* scoped */
|
|
282
|
+
const __vue_scope_id__ = undefined;
|
|
283
|
+
/* module identifier */
|
|
284
|
+
const __vue_module_identifier__ = undefined;
|
|
285
|
+
/* functional template */
|
|
286
|
+
const __vue_is_functional_template__ = false;
|
|
287
|
+
/* style inject */
|
|
288
|
+
|
|
289
|
+
/* style inject SSR */
|
|
290
|
+
|
|
291
|
+
/* style inject shadow dom */
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
const __vue_component__ = __vue_normalize__(
|
|
296
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
297
|
+
__vue_inject_styles__,
|
|
298
|
+
__vue_script__,
|
|
299
|
+
__vue_scope_id__,
|
|
300
|
+
__vue_is_functional_template__,
|
|
301
|
+
__vue_module_identifier__,
|
|
302
|
+
false,
|
|
303
|
+
undefined,
|
|
304
|
+
undefined,
|
|
305
|
+
undefined
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
export default __vue_component__;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
2
|
+
|
|
3
|
+
const makePathRect = (startX, startY, width, height) => `M${startX},${startY}H${startX + width}V${startY + height}H${startX}Z`;
|
|
4
|
+
var script = {
|
|
5
|
+
name: 'GlChartSeriesLabel',
|
|
6
|
+
props: {
|
|
7
|
+
color: {
|
|
8
|
+
type: String,
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
type: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: false,
|
|
14
|
+
default: 'solid'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
labelLineHeight: 0
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
computed: {
|
|
23
|
+
pathContent() {
|
|
24
|
+
const width = this.$options.svgWidth;
|
|
25
|
+
const height = this.$options.svgHeight;
|
|
26
|
+
if (this.type === 'dashed') {
|
|
27
|
+
const dashWidth = Math.ceil(width / 3);
|
|
28
|
+
const firstDash = makePathRect(0, 0, dashWidth, height);
|
|
29
|
+
const secondDash = makePathRect(width - dashWidth, 0, dashWidth, height);
|
|
30
|
+
return `${firstDash}${secondDash}`;
|
|
31
|
+
}
|
|
32
|
+
return makePathRect(0, 0, width, height);
|
|
33
|
+
},
|
|
34
|
+
svgStyles() {
|
|
35
|
+
return {
|
|
36
|
+
fill: this.color,
|
|
37
|
+
transform: `translateY(${this.formatPixelDimension(this.svgYTranslationValue)})`,
|
|
38
|
+
width: 'auto'
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
svgYTranslationValue() {
|
|
42
|
+
const value = this.labelLineHeight / 2 - this.$options.svgHeight / 2;
|
|
43
|
+
return Math.round(value) || 0;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
mounted() {
|
|
47
|
+
if (getComputedStyle && this.$refs.label) {
|
|
48
|
+
const computedStyle = getComputedStyle(this.$refs.label);
|
|
49
|
+
const lineHeight = computedStyle['line-height'].match(/(\d+)px/);
|
|
50
|
+
if (lineHeight !== null) {
|
|
51
|
+
this.labelLineHeight = parseFloat(lineHeight[1]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
formatPixelDimension(dimension) {
|
|
57
|
+
return `${dimension}px`;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
svgWidth: 16,
|
|
61
|
+
svgHeight: 4
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/* script */
|
|
65
|
+
const __vue_script__ = script;
|
|
66
|
+
|
|
67
|
+
/* template */
|
|
68
|
+
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-series-label-container"},[(_vm.color.length)?_c('div',{staticClass:"gl-series-label-color"},[_c('svg',{style:(_vm.svgStyles),attrs:{"width":_vm.formatPixelDimension(_vm.$options.svgWidth),"height":_vm.formatPixelDimension(_vm.$options.svgHeight)}},[_c('path',{attrs:{"d":_vm.pathContent}})])]):_vm._e(),_vm._v(" "),_c('div',{ref:"label",staticClass:"gl-series-label-text"},[_vm._t("default")],2)])};
|
|
69
|
+
var __vue_staticRenderFns__ = [];
|
|
70
|
+
|
|
71
|
+
/* style */
|
|
72
|
+
const __vue_inject_styles__ = undefined;
|
|
73
|
+
/* scoped */
|
|
74
|
+
const __vue_scope_id__ = undefined;
|
|
75
|
+
/* module identifier */
|
|
76
|
+
const __vue_module_identifier__ = undefined;
|
|
77
|
+
/* functional template */
|
|
78
|
+
const __vue_is_functional_template__ = false;
|
|
79
|
+
/* style inject */
|
|
80
|
+
|
|
81
|
+
/* style inject SSR */
|
|
82
|
+
|
|
83
|
+
/* style inject shadow dom */
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const __vue_component__ = __vue_normalize__(
|
|
88
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
89
|
+
__vue_inject_styles__,
|
|
90
|
+
__vue_script__,
|
|
91
|
+
__vue_scope_id__,
|
|
92
|
+
__vue_is_functional_template__,
|
|
93
|
+
__vue_module_identifier__,
|
|
94
|
+
false,
|
|
95
|
+
undefined,
|
|
96
|
+
undefined,
|
|
97
|
+
undefined
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export default __vue_component__;
|