@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,311 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
import { defaultAreaOpacity, lineStyle, getThresholdConfig, generateAnnotationSeries, defaultChartOptions, dataZoomAdjustments, mergeSeriesToOptions, mergeAnnotationAxisToOptions, grid } from '../../../utils/charts/config';
|
|
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
|
+
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
5
|
+
import { seriesHasAnnotations, isDataPointAnnotation } from '../../../utils/charts/utils';
|
|
6
|
+
import Chart from '../chart/chart';
|
|
7
|
+
import ChartLegend from '../legend/legend';
|
|
8
|
+
import ChartTooltip from '../tooltip/tooltip';
|
|
9
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
10
|
+
|
|
11
|
+
//
|
|
12
|
+
var script = {
|
|
13
|
+
name: 'GlAreaChart',
|
|
14
|
+
components: {
|
|
15
|
+
Chart,
|
|
16
|
+
ChartLegend,
|
|
17
|
+
ChartTooltip
|
|
18
|
+
},
|
|
19
|
+
inheritAttrs: false,
|
|
20
|
+
props: {
|
|
21
|
+
data: {
|
|
22
|
+
type: Array,
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
option: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: false,
|
|
28
|
+
default: () => ({})
|
|
29
|
+
},
|
|
30
|
+
thresholds: {
|
|
31
|
+
type: Array,
|
|
32
|
+
required: false,
|
|
33
|
+
default: () => []
|
|
34
|
+
},
|
|
35
|
+
annotations: {
|
|
36
|
+
type: Array,
|
|
37
|
+
required: false,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
includeLegendAvgMax: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
required: false,
|
|
43
|
+
default: true
|
|
44
|
+
},
|
|
45
|
+
formatAnnotationsTooltipText: {
|
|
46
|
+
type: Function,
|
|
47
|
+
required: false,
|
|
48
|
+
default: null
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Callback called when showing or refreshing a tooltip.
|
|
52
|
+
* **Deprecated:** Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated Use slots `#tooltip-title`, `#tooltip-content` or `#tooltip-value`.
|
|
55
|
+
*/
|
|
56
|
+
formatTooltipText: {
|
|
57
|
+
type: Function,
|
|
58
|
+
required: false,
|
|
59
|
+
default: null
|
|
60
|
+
},
|
|
61
|
+
legendAverageText: {
|
|
62
|
+
type: String,
|
|
63
|
+
required: false,
|
|
64
|
+
default: LEGEND_AVERAGE_TEXT
|
|
65
|
+
},
|
|
66
|
+
legendMaxText: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: false,
|
|
69
|
+
default: LEGEND_MAX_TEXT
|
|
70
|
+
},
|
|
71
|
+
legendMinText: {
|
|
72
|
+
type: String,
|
|
73
|
+
required: false,
|
|
74
|
+
default: LEGEND_MIN_TEXT
|
|
75
|
+
},
|
|
76
|
+
legendCurrentText: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: false,
|
|
79
|
+
default: LEGEND_CURRENT_TEXT
|
|
80
|
+
},
|
|
81
|
+
legendLayout: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: false,
|
|
84
|
+
default: LEGEND_LAYOUT_INLINE,
|
|
85
|
+
validator(layout) {
|
|
86
|
+
return [LEGEND_LAYOUT_INLINE, LEGEND_LAYOUT_TABLE].indexOf(layout) !== -1;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Sets the chart's height in pixels. Set to `"auto"` to use the height of the container.
|
|
91
|
+
*/
|
|
92
|
+
height: {
|
|
93
|
+
type: [Number, String],
|
|
94
|
+
required: false,
|
|
95
|
+
default: null
|
|
96
|
+
},
|
|
97
|
+
legendSeriesInfo: {
|
|
98
|
+
type: Array,
|
|
99
|
+
required: false,
|
|
100
|
+
default: () => []
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
data() {
|
|
104
|
+
// Part of the tooltip related data can be
|
|
105
|
+
// moved into the tooltip component.
|
|
106
|
+
// Tracking that progress in
|
|
107
|
+
// https://gitlab.com/gitlab-org/gitlab-ui/-/issues/618
|
|
108
|
+
return {
|
|
109
|
+
chart: null,
|
|
110
|
+
showAnnotationsTooltip: false,
|
|
111
|
+
annotationsTooltipTitle: '',
|
|
112
|
+
annotationsTooltipContent: '',
|
|
113
|
+
annotationsTooltipPosition: {
|
|
114
|
+
left: '0',
|
|
115
|
+
top: '0'
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
computed: {
|
|
120
|
+
series() {
|
|
121
|
+
const dataSeries = this.data.map((series, index) => {
|
|
122
|
+
const defaultColor = colorFromDefaultPalette(index);
|
|
123
|
+
const getColor = type => series[type] && series[type].color ? series[type].color : defaultColor;
|
|
124
|
+
return merge({
|
|
125
|
+
areaStyle: {
|
|
126
|
+
opacity: defaultAreaOpacity,
|
|
127
|
+
color: getColor('areaStyle')
|
|
128
|
+
},
|
|
129
|
+
showSymbol: false,
|
|
130
|
+
lineStyle: {
|
|
131
|
+
color: getColor('lineStyle')
|
|
132
|
+
},
|
|
133
|
+
itemStyle: {
|
|
134
|
+
color: getColor('itemStyle')
|
|
135
|
+
}
|
|
136
|
+
}, lineStyle, series, getThresholdConfig(this.thresholds));
|
|
137
|
+
});
|
|
138
|
+
// if annotation series exists, append it
|
|
139
|
+
// along with data series
|
|
140
|
+
if (this.annotationSeries) {
|
|
141
|
+
return [...dataSeries, this.annotationSeries];
|
|
142
|
+
}
|
|
143
|
+
return dataSeries;
|
|
144
|
+
},
|
|
145
|
+
annotationSeries() {
|
|
146
|
+
return generateAnnotationSeries(this.annotations);
|
|
147
|
+
},
|
|
148
|
+
options() {
|
|
149
|
+
const defaultAreaChartOptions = {
|
|
150
|
+
xAxis: {
|
|
151
|
+
axisPointer: {
|
|
152
|
+
show: true,
|
|
153
|
+
lineStyle: {
|
|
154
|
+
type: 'solid'
|
|
155
|
+
},
|
|
156
|
+
label: {
|
|
157
|
+
formatter: this.formatTooltipText
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
yAxis: {
|
|
162
|
+
axisTick: {
|
|
163
|
+
show: false
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
legend: {
|
|
167
|
+
show: false
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const mergedOptions = merge({}, defaultChartOptions, defaultAreaChartOptions, this.option, dataZoomAdjustments(this.option.dataZoom));
|
|
171
|
+
// All chart options can be merged but series
|
|
172
|
+
// needs to be handled specially.
|
|
173
|
+
return mergeSeriesToOptions(mergeAnnotationAxisToOptions(mergedOptions, this.hasAnnotations), this.series);
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* Annotations currently are passed as series options in monitoring dashboard.
|
|
177
|
+
* Once https://gitlab.com/gitlab-org/gitlab/-/issues/213390 is closed,
|
|
178
|
+
* annotations will be passed as props and not as series options.
|
|
179
|
+
*
|
|
180
|
+
* For backward compatibility, we're having to check for both.
|
|
181
|
+
*/
|
|
182
|
+
hasAnnotations() {
|
|
183
|
+
return this.annotations.length !== 0 || seriesHasAnnotations(this.option.series);
|
|
184
|
+
},
|
|
185
|
+
shouldShowAnnotationsTooltip() {
|
|
186
|
+
return this.chart && this.hasAnnotations;
|
|
187
|
+
},
|
|
188
|
+
compiledOptions() {
|
|
189
|
+
return this.chart ? this.chart.getOption() : null;
|
|
190
|
+
},
|
|
191
|
+
legendStyle() {
|
|
192
|
+
return {
|
|
193
|
+
paddingLeft: `${grid.left}px`
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
seriesInfo() {
|
|
197
|
+
if (this.legendSeriesInfo.length > 0) return this.legendSeriesInfo;
|
|
198
|
+
return this.compiledOptions.series.reduce((acc, series, index) => {
|
|
199
|
+
if (series.type === 'line') {
|
|
200
|
+
acc.push({
|
|
201
|
+
name: series.name,
|
|
202
|
+
type: series.lineStyle.type,
|
|
203
|
+
color: series.lineStyle.color || colorFromDefaultPalette(index),
|
|
204
|
+
data: this.includeLegendAvgMax ? series.data.map(data => data[1]) : undefined
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return acc;
|
|
208
|
+
}, []);
|
|
209
|
+
},
|
|
210
|
+
autoHeight() {
|
|
211
|
+
return this.height === 'auto';
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
beforeDestroy() {
|
|
215
|
+
this.chart.off('mouseout', this.hideAnnotationsTooltip);
|
|
216
|
+
this.chart.off('mouseover', this.onChartMouseOver);
|
|
217
|
+
},
|
|
218
|
+
methods: {
|
|
219
|
+
defaultAnnotationTooltipText(params) {
|
|
220
|
+
var _params$data$tooltipD;
|
|
221
|
+
return {
|
|
222
|
+
title: params.data.xAxis,
|
|
223
|
+
content: (_params$data$tooltipD = params.data.tooltipData) === null || _params$data$tooltipD === void 0 ? void 0 : _params$data$tooltipD.content
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
onCreated(chart) {
|
|
227
|
+
// eCharts inbuild mouse events
|
|
228
|
+
// https://echarts.apache.org/en/api.html#events.Mouse%20events
|
|
229
|
+
// is used to attach listeners to markPoints. These listeners
|
|
230
|
+
// are currently used for annotation arrows at the bottom of the chart.
|
|
231
|
+
|
|
232
|
+
// Because data points and annotations arrows are in different
|
|
233
|
+
// sections of the charts with their own mouseovers and mouseouts,
|
|
234
|
+
// there shouldn't be an overlapping situation where both tooltips
|
|
235
|
+
// are visible.
|
|
236
|
+
if (this.hasAnnotations) {
|
|
237
|
+
chart.on('mouseout', this.onChartDataPointMouseOut);
|
|
238
|
+
chart.on('mouseover', this.onChartDataPointMouseOver);
|
|
239
|
+
}
|
|
240
|
+
this.chart = chart;
|
|
241
|
+
this.$emit('created', chart);
|
|
242
|
+
},
|
|
243
|
+
onChartDataPointMouseOut() {
|
|
244
|
+
this.showAnnotationsTooltip = false;
|
|
245
|
+
},
|
|
246
|
+
/**
|
|
247
|
+
* Check if the hovered data point is an annotation
|
|
248
|
+
* point to show the annotation tooltip.
|
|
249
|
+
*/
|
|
250
|
+
onChartDataPointMouseOver(params) {
|
|
251
|
+
if (isDataPointAnnotation(params)) {
|
|
252
|
+
const {
|
|
253
|
+
event
|
|
254
|
+
} = params;
|
|
255
|
+
const toolTipFormatter = this.formatAnnotationsTooltipText || this.defaultAnnotationTooltipText;
|
|
256
|
+
const {
|
|
257
|
+
title = '',
|
|
258
|
+
content = ''
|
|
259
|
+
} = toolTipFormatter(params);
|
|
260
|
+
this.showAnnotationsTooltip = true;
|
|
261
|
+
this.annotationsTooltipTitle = title;
|
|
262
|
+
this.annotationsTooltipContent = content;
|
|
263
|
+
this.annotationsTooltipPosition = {
|
|
264
|
+
left: `${event.event.zrX}px`,
|
|
265
|
+
top: `${event.event.zrY}px`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
HEIGHT_AUTO_CLASSES
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/* script */
|
|
274
|
+
const __vue_script__ = script;
|
|
275
|
+
|
|
276
|
+
/* template */
|
|
277
|
+
var __vue_render__ = function () {
|
|
278
|
+
var _obj;
|
|
279
|
+
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,"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.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)};
|
|
280
|
+
var __vue_staticRenderFns__ = [];
|
|
281
|
+
|
|
282
|
+
/* style */
|
|
283
|
+
const __vue_inject_styles__ = undefined;
|
|
284
|
+
/* scoped */
|
|
285
|
+
const __vue_scope_id__ = undefined;
|
|
286
|
+
/* module identifier */
|
|
287
|
+
const __vue_module_identifier__ = undefined;
|
|
288
|
+
/* functional template */
|
|
289
|
+
const __vue_is_functional_template__ = false;
|
|
290
|
+
/* style inject */
|
|
291
|
+
|
|
292
|
+
/* style inject SSR */
|
|
293
|
+
|
|
294
|
+
/* style inject shadow dom */
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
const __vue_component__ = __vue_normalize__(
|
|
299
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
300
|
+
__vue_inject_styles__,
|
|
301
|
+
__vue_script__,
|
|
302
|
+
__vue_scope_id__,
|
|
303
|
+
__vue_is_functional_template__,
|
|
304
|
+
__vue_module_identifier__,
|
|
305
|
+
false,
|
|
306
|
+
undefined,
|
|
307
|
+
undefined,
|
|
308
|
+
undefined
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
export default __vue_component__;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
import truncate from 'lodash/truncate';
|
|
3
|
+
import { dataZoomAdjustments, mergeSeriesToOptions, grid } from '../../../utils/charts/config';
|
|
4
|
+
import { HEIGHT_AUTO_CLASSES } from '../../../utils/charts/constants';
|
|
5
|
+
import { colorFromDefaultPalette } from '../../../utils/charts/theme';
|
|
6
|
+
import { engineeringNotation } from '../../../utils/number_utils';
|
|
7
|
+
import { hexToRgba } from '../../../utils/utils';
|
|
8
|
+
import TooltipDefaultFormat from '../../shared_components/charts/tooltip_default_format';
|
|
9
|
+
import Chart from '../chart/chart';
|
|
10
|
+
import ChartTooltip from '../tooltip/tooltip';
|
|
11
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
12
|
+
|
|
13
|
+
//
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `nameGap` in charts/config is set to 50 but it is not
|
|
17
|
+
* used for bar charts as the axes are flipped. That is why
|
|
18
|
+
* we're explicitly setting it here
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_NAME_GAP = 50;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This is the magic number at which the y-axis name
|
|
24
|
+
* and y-axis labels don't overlap
|
|
25
|
+
* @Number
|
|
26
|
+
*/
|
|
27
|
+
const AXIS_LABEL_LENGTH = 7;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Because the axes are reversed in bar charts defaultChartOptions
|
|
31
|
+
* xAxis and yAxis needs to be handled specifically.
|
|
32
|
+
*/
|
|
33
|
+
const defaultOptions = {
|
|
34
|
+
grid,
|
|
35
|
+
xAxis: {
|
|
36
|
+
nameLocation: 'center',
|
|
37
|
+
axisLabel: {
|
|
38
|
+
formatter: num => engineeringNotation(num, 2)
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
yAxis: {
|
|
42
|
+
nameGap: DEFAULT_NAME_GAP,
|
|
43
|
+
boundaryGap: true,
|
|
44
|
+
nameLocation: 'center',
|
|
45
|
+
splitLine: {
|
|
46
|
+
show: false
|
|
47
|
+
},
|
|
48
|
+
axisLabel: {
|
|
49
|
+
interval: 0,
|
|
50
|
+
formatter: str => truncate(str, {
|
|
51
|
+
length: AXIS_LABEL_LENGTH,
|
|
52
|
+
separator: '...'
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var script = {
|
|
58
|
+
name: 'GlBarChart',
|
|
59
|
+
components: {
|
|
60
|
+
Chart,
|
|
61
|
+
ChartTooltip,
|
|
62
|
+
TooltipDefaultFormat
|
|
63
|
+
},
|
|
64
|
+
inheritAttrs: false,
|
|
65
|
+
props: {
|
|
66
|
+
data: {
|
|
67
|
+
type: Object,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
option: {
|
|
71
|
+
type: Object,
|
|
72
|
+
required: false,
|
|
73
|
+
default: () => ({})
|
|
74
|
+
},
|
|
75
|
+
yAxisTitle: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: true
|
|
78
|
+
},
|
|
79
|
+
xAxisTitle: {
|
|
80
|
+
type: String,
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
xAxisType: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: false,
|
|
86
|
+
default: 'value'
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Sets the chart's height in pixels. Set to `"auto"` to use the height of the container.
|
|
90
|
+
*/
|
|
91
|
+
height: {
|
|
92
|
+
type: [Number, String],
|
|
93
|
+
required: false,
|
|
94
|
+
default: null
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
chart: null,
|
|
100
|
+
tooltipTitle: '',
|
|
101
|
+
tooltipContent: {}
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
computed: {
|
|
105
|
+
series() {
|
|
106
|
+
return Object.keys(this.data).map((key, index) => {
|
|
107
|
+
const barColor = colorFromDefaultPalette(index);
|
|
108
|
+
return {
|
|
109
|
+
name: key,
|
|
110
|
+
data: this.data[key],
|
|
111
|
+
type: 'bar',
|
|
112
|
+
stack: 'chart',
|
|
113
|
+
itemStyle: {
|
|
114
|
+
color: hexToRgba(barColor, 0.2),
|
|
115
|
+
borderColor: barColor,
|
|
116
|
+
borderWidth: 1
|
|
117
|
+
},
|
|
118
|
+
emphasis: {
|
|
119
|
+
itemStyle: {
|
|
120
|
+
color: hexToRgba(barColor, 0.4)
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
barMaxWidth: '50%'
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
options() {
|
|
128
|
+
const mergedOptions = merge({}, defaultOptions, {
|
|
129
|
+
xAxis: {
|
|
130
|
+
axisLine: {
|
|
131
|
+
show: false
|
|
132
|
+
},
|
|
133
|
+
name: this.xAxisTitle,
|
|
134
|
+
type: this.xAxisType
|
|
135
|
+
},
|
|
136
|
+
yAxis: {
|
|
137
|
+
name: this.yAxisTitle,
|
|
138
|
+
type: 'category',
|
|
139
|
+
axisTick: {
|
|
140
|
+
show: true
|
|
141
|
+
},
|
|
142
|
+
axisPointer: {
|
|
143
|
+
show: true,
|
|
144
|
+
type: 'none',
|
|
145
|
+
label: {
|
|
146
|
+
formatter: this.onLabelChange
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
legend: {
|
|
151
|
+
show: false
|
|
152
|
+
}
|
|
153
|
+
}, this.option, dataZoomAdjustments(this.option.dataZoom));
|
|
154
|
+
// All chart options can be merged but series
|
|
155
|
+
// needs to be handled specially
|
|
156
|
+
return mergeSeriesToOptions(mergedOptions, this.series);
|
|
157
|
+
},
|
|
158
|
+
autoHeight() {
|
|
159
|
+
return this.height === 'auto';
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
methods: {
|
|
163
|
+
onCreated(chart) {
|
|
164
|
+
this.chart = chart;
|
|
165
|
+
this.$emit('created', chart);
|
|
166
|
+
},
|
|
167
|
+
onLabelChange(params) {
|
|
168
|
+
const {
|
|
169
|
+
yLabels,
|
|
170
|
+
tooltipContent
|
|
171
|
+
} = this.getTooltipContent(params, this.xAxisTitle);
|
|
172
|
+
this.$set(this, 'tooltipContent', tooltipContent);
|
|
173
|
+
this.tooltipTitle = yLabels.join(', ');
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* For bar charts, the tooltip should be against x-axis values.
|
|
177
|
+
* This method will be removed after https://gitlab.com/gitlab-org/gitlab-ui/-/issues/674
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} params series data
|
|
180
|
+
* @param {String} xAxisTitle x-axis title
|
|
181
|
+
* @returns {Object} tooltip title and content
|
|
182
|
+
*/
|
|
183
|
+
getTooltipContent(params) {
|
|
184
|
+
let xAxisTitle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
185
|
+
const seriesDataLength = params.seriesData.length;
|
|
186
|
+
const {
|
|
187
|
+
yLabels,
|
|
188
|
+
tooltipContent
|
|
189
|
+
} = params.seriesData.reduce((acc, chartItem) => {
|
|
190
|
+
const [value, title] = chartItem.value || [];
|
|
191
|
+
// The x axis title is used instead of y axis
|
|
192
|
+
const seriesName = seriesDataLength === 1 && xAxisTitle ? xAxisTitle : chartItem.seriesName;
|
|
193
|
+
const color = seriesDataLength === 1 ? '' : chartItem.color;
|
|
194
|
+
acc.tooltipContent[seriesName] = {
|
|
195
|
+
value,
|
|
196
|
+
color
|
|
197
|
+
};
|
|
198
|
+
if (!acc.yLabels.includes(title)) {
|
|
199
|
+
acc.yLabels.push(title);
|
|
200
|
+
}
|
|
201
|
+
return acc;
|
|
202
|
+
}, {
|
|
203
|
+
yLabels: [],
|
|
204
|
+
tooltipContent: {}
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
yLabels,
|
|
208
|
+
tooltipContent
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
HEIGHT_AUTO_CLASSES
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/* script */
|
|
216
|
+
const __vue_script__ = script;
|
|
217
|
+
|
|
218
|
+
/* template */
|
|
219
|
+
var __vue_render__ = function () {
|
|
220
|
+
var _obj;
|
|
221
|
+
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.chart)?_c('chart-tooltip',{attrs:{"chart":_vm.chart},scopedSlots:_vm._u([{key:"title",fn:function(){return [_c('div',[_vm._v(_vm._s(_vm.tooltipTitle)+" ("+_vm._s(_vm.yAxisTitle)+")")])]},proxy:true}],null,false,1644826356)},[_vm._v(" "),_c('tooltip-default-format',{attrs:{"tooltip-content":_vm.tooltipContent}})],1):_vm._e()],1)};
|
|
222
|
+
var __vue_staticRenderFns__ = [];
|
|
223
|
+
|
|
224
|
+
/* style */
|
|
225
|
+
const __vue_inject_styles__ = undefined;
|
|
226
|
+
/* scoped */
|
|
227
|
+
const __vue_scope_id__ = undefined;
|
|
228
|
+
/* module identifier */
|
|
229
|
+
const __vue_module_identifier__ = undefined;
|
|
230
|
+
/* functional template */
|
|
231
|
+
const __vue_is_functional_template__ = false;
|
|
232
|
+
/* style inject */
|
|
233
|
+
|
|
234
|
+
/* style inject SSR */
|
|
235
|
+
|
|
236
|
+
/* style inject shadow dom */
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
const __vue_component__ = __vue_normalize__(
|
|
241
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
242
|
+
__vue_inject_styles__,
|
|
243
|
+
__vue_script__,
|
|
244
|
+
__vue_scope_id__,
|
|
245
|
+
__vue_is_functional_template__,
|
|
246
|
+
__vue_module_identifier__,
|
|
247
|
+
false,
|
|
248
|
+
undefined,
|
|
249
|
+
undefined,
|
|
250
|
+
undefined
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
export default __vue_component__;
|