misp-ui-library-test 0.0.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/README.md +113 -0
- package/dist/theme-chalk/alert/index.scss +152 -0
- package/dist/theme-chalk/avatar/index.scss +51 -0
- package/dist/theme-chalk/backtop/index.scss +38 -0
- package/dist/theme-chalk/badge/index.scss +63 -0
- package/dist/theme-chalk/breadcrumb/index.scss +36 -0
- package/dist/theme-chalk/breadcrumb-item/index.scss +36 -0
- package/dist/theme-chalk/button/index.scss +157 -0
- package/dist/theme-chalk/card/index.scss +38 -0
- package/dist/theme-chalk/chart/index.scss +21 -0
- package/dist/theme-chalk/checkbox/index.scss +358 -0
- package/dist/theme-chalk/col/index.scss +131 -0
- package/dist/theme-chalk/container/index.scss +40 -0
- package/dist/theme-chalk/css/alert.css +484 -0
- package/dist/theme-chalk/css/avatar.css +409 -0
- package/dist/theme-chalk/css/backtop.css +401 -0
- package/dist/theme-chalk/css/badge.css +419 -0
- package/dist/theme-chalk/css/breadcrumb-item.css +395 -0
- package/dist/theme-chalk/css/breadcrumb.css +395 -0
- package/dist/theme-chalk/css/button.css +587 -0
- package/dist/theme-chalk/css/card.css +397 -0
- package/dist/theme-chalk/css/chart.css +386 -0
- package/dist/theme-chalk/css/checkbox.css +648 -0
- package/dist/theme-chalk/css/col.css +2111 -0
- package/dist/theme-chalk/css/container.css +404 -0
- package/dist/theme-chalk/css/dialog.css +505 -0
- package/dist/theme-chalk/css/divider.css +405 -0
- package/dist/theme-chalk/css/drawer.css +546 -0
- package/dist/theme-chalk/css/empty.css +394 -0
- package/dist/theme-chalk/css/form.css +561 -0
- package/dist/theme-chalk/css/icon.css +1534 -0
- package/dist/theme-chalk/css/image.css +400 -0
- package/dist/theme-chalk/css/input-number.css +424 -0
- package/dist/theme-chalk/css/input.css +721 -0
- package/dist/theme-chalk/css/link.css +424 -0
- package/dist/theme-chalk/css/loading.css +483 -0
- package/dist/theme-chalk/css/message-box.css +479 -0
- package/dist/theme-chalk/css/message.css +456 -0
- package/dist/theme-chalk/css/no-data.css +397 -0
- package/dist/theme-chalk/css/notification.css +431 -0
- package/dist/theme-chalk/css/page-header.css +396 -0
- package/dist/theme-chalk/css/pagination.css +565 -0
- package/dist/theme-chalk/css/popover.css +421 -0
- package/dist/theme-chalk/css/popper.css +454 -0
- package/dist/theme-chalk/css/progress.css +451 -0
- package/dist/theme-chalk/css/radio.css +626 -0
- package/dist/theme-chalk/css/rate.css +414 -0
- package/dist/theme-chalk/css/result.css +403 -0
- package/dist/theme-chalk/css/row.css +433 -0
- package/dist/theme-chalk/css/scrollbar.css +422 -0
- package/dist/theme-chalk/css/select.css +1897 -0
- package/dist/theme-chalk/css/skeleton-item.css +407 -0
- package/dist/theme-chalk/css/skeleton.css +390 -0
- package/dist/theme-chalk/css/slider.css +460 -0
- package/dist/theme-chalk/css/spinner.css +403 -0
- package/dist/theme-chalk/css/statistic.css +396 -0
- package/dist/theme-chalk/css/status-timeline-chart.css +388 -0
- package/dist/theme-chalk/css/step.css +496 -0
- package/dist/theme-chalk/css/steps.css +496 -0
- package/dist/theme-chalk/css/switch.css +507 -0
- package/dist/theme-chalk/css/tab-pane.css +457 -0
- package/dist/theme-chalk/css/table.css +461 -0
- package/dist/theme-chalk/css/tabs-navigation.css +925 -0
- package/dist/theme-chalk/css/tabs.css +457 -0
- package/dist/theme-chalk/css/tag.css +599 -0
- package/dist/theme-chalk/css/time-picker.css +683 -0
- package/dist/theme-chalk/css/timeline-item.css +459 -0
- package/dist/theme-chalk/css/timeline.css +459 -0
- package/dist/theme-chalk/css/tooltip.css +485 -0
- package/dist/theme-chalk/css/tree.css +473 -0
- package/dist/theme-chalk/css/upload.css +665 -0
- package/dist/theme-chalk/dialog/index.scss +168 -0
- package/dist/theme-chalk/divider/index.scss +46 -0
- package/dist/theme-chalk/drawer/index.scss +172 -0
- package/dist/theme-chalk/empty/index.scss +36 -0
- package/dist/theme-chalk/fonts/element-icons.ttf +0 -0
- package/dist/theme-chalk/fonts/element-icons.woff +0 -0
- package/dist/theme-chalk/form/index.scss +220 -0
- package/dist/theme-chalk/icon/index.scss +1171 -0
- package/dist/theme-chalk/image/index.scss +39 -0
- package/dist/theme-chalk/index.scss +127 -0
- package/dist/theme-chalk/input/index.scss +363 -0
- package/dist/theme-chalk/input-number/index.scss +71 -0
- package/dist/theme-chalk/link/index.scss +75 -0
- package/dist/theme-chalk/loading/index.scss +131 -0
- package/dist/theme-chalk/message/index.scss +100 -0
- package/dist/theme-chalk/message-box/index.scss +131 -0
- package/dist/theme-chalk/mixins.scss +203 -0
- package/dist/theme-chalk/no-data/index.scss +36 -0
- package/dist/theme-chalk/notification/index.scss +76 -0
- package/dist/theme-chalk/page-header/index.scss +36 -0
- package/dist/theme-chalk/pagination/index.scss +225 -0
- package/dist/theme-chalk/popover/index.scss +56 -0
- package/dist/theme-chalk/popper/index.scss +89 -0
- package/dist/theme-chalk/progress/index.scss +105 -0
- package/dist/theme-chalk/radio/index.scss +328 -0
- package/dist/theme-chalk/rate/index.scss +56 -0
- package/dist/theme-chalk/reset.scss +262 -0
- package/dist/theme-chalk/result/index.scss +46 -0
- package/dist/theme-chalk/row/index.scss +88 -0
- package/dist/theme-chalk/scrollbar/index.scss +67 -0
- package/dist/theme-chalk/select/index.scss +223 -0
- package/dist/theme-chalk/skeleton/index.scss +30 -0
- package/dist/theme-chalk/skeleton-item/index.scss +49 -0
- package/dist/theme-chalk/slider/index.scss +113 -0
- package/dist/theme-chalk/spinner/index.scss +40 -0
- package/dist/theme-chalk/statistic/index.scss +38 -0
- package/dist/theme-chalk/status-timeline-chart/index.scss +23 -0
- package/dist/theme-chalk/step/index.scss +160 -0
- package/dist/theme-chalk/steps/index.scss +160 -0
- package/dist/theme-chalk/switch/index.scss +153 -0
- package/dist/theme-chalk/tab-pane/index.scss +112 -0
- package/dist/theme-chalk/table/index.scss +110 -0
- package/dist/theme-chalk/tabs/index.scss +112 -0
- package/dist/theme-chalk/tabs-navigation/index.scss +631 -0
- package/dist/theme-chalk/tag/index.scss +138 -0
- package/dist/theme-chalk/themes/blue.scss +76 -0
- package/dist/theme-chalk/themes/dark.scss +99 -0
- package/dist/theme-chalk/themes/index.scss +260 -0
- package/dist/theme-chalk/themes/light.scss +99 -0
- package/dist/theme-chalk/time-picker/index.scss +332 -0
- package/dist/theme-chalk/timeline/index.scss +119 -0
- package/dist/theme-chalk/timeline-item/index.scss +119 -0
- package/dist/theme-chalk/tooltip/index.scss +122 -0
- package/dist/theme-chalk/tree/index.scss +125 -0
- package/dist/theme-chalk/upload/index.scss +348 -0
- package/dist/theme-chalk/variables.scss +93 -0
- package/dist/vue2-ui-library.cjs.temp.js.map +1 -0
- package/dist/vue2-ui-library.common.js +28 -0
- package/dist/vue2-ui-library.common.js.map +1 -0
- package/dist/vue2-ui-library.esm.js +29 -0
- package/dist/vue2-ui-library.umd.js +27 -0
- package/package.json +161 -0
- package/src/directives/clickoutside/index.js +111 -0
- package/src/directives/init/index.js +50 -0
- package/src/directives/resize/index.js +69 -0
- package/src/index.js +174 -0
- package/src/mixins/emitter.js +47 -0
- package/src/mixins/focus.js +42 -0
- package/src/mixins/locale.js +24 -0
- package/src/mixins/migrating.js +46 -0
- package/src/packages/alert/index.js +12 -0
- package/src/packages/alert/src/main.vue +98 -0
- package/src/packages/aside/index.js +12 -0
- package/src/packages/aside/src/main.vue +20 -0
- package/src/packages/auto-grid-layout/index.js +18 -0
- package/src/packages/auto-grid-layout/prop.js +92 -0
- package/src/packages/auto-grid-layout/src/components/GridItem.vue +759 -0
- package/src/packages/auto-grid-layout/src/components/GridLayout.vue +367 -0
- package/src/packages/auto-grid-layout/src/main.vue +287 -0
- package/src/packages/auto-grid-layout/src/utils/DOM.js +46 -0
- package/src/packages/auto-grid-layout/src/utils/interact.js +333 -0
- package/src/packages/auto-grid-layout/src/utils/responsiveUtils.js +75 -0
- package/src/packages/auto-grid-layout/src/utils/utils.js +339 -0
- package/src/packages/autocomplete/index.js +12 -0
- package/src/packages/autocomplete/src/main.vue +170 -0
- package/src/packages/avatar/index.js +12 -0
- package/src/packages/avatar/src/main.vue +87 -0
- package/src/packages/backtop/index.js +12 -0
- package/src/packages/backtop/src/main.vue +120 -0
- package/src/packages/badge/index.js +12 -0
- package/src/packages/badge/src/main.vue +53 -0
- package/src/packages/breadcrumb/index.js +12 -0
- package/src/packages/breadcrumb/src/main.vue +34 -0
- package/src/packages/breadcrumb-item/index.js +12 -0
- package/src/packages/breadcrumb-item/src/main.vue +41 -0
- package/src/packages/button/index.js +13 -0
- package/src/packages/button/src/main.vue +106 -0
- package/src/packages/calendar/index.js +12 -0
- package/src/packages/calendar/src/main.vue +173 -0
- package/src/packages/card/index.js +12 -0
- package/src/packages/card/src/main.vue +26 -0
- package/src/packages/carousel/index.js +12 -0
- package/src/packages/carousel/src/main.vue +186 -0
- package/src/packages/carousel-item/index.js +12 -0
- package/src/packages/carousel-item/src/main.vue +34 -0
- package/src/packages/cascader/index.js +12 -0
- package/src/packages/cascader/src/main.vue +232 -0
- package/src/packages/chart/index.js +7 -0
- package/src/packages/chart/src/axis-chart.js +700 -0
- package/src/packages/chart/src/main.vue +828 -0
- package/src/packages/chart/src/utils.js +21 -0
- package/src/packages/checkbox/index.js +44 -0
- package/src/packages/checkbox/src/main.vue +312 -0
- package/src/packages/col/index.js +12 -0
- package/src/packages/col/src/main.vue +85 -0
- package/src/packages/collapse/index.js +12 -0
- package/src/packages/collapse/src/main.vue +69 -0
- package/src/packages/collapse-item/index.js +12 -0
- package/src/packages/collapse-item/src/main.vue +75 -0
- package/src/packages/color-picker/index.js +12 -0
- package/src/packages/color-picker/src/main.vue +206 -0
- package/src/packages/container/index.js +12 -0
- package/src/packages/container/src/main.vue +33 -0
- package/src/packages/date-picker/index.js +12 -0
- package/src/packages/date-picker/src/main.vue +246 -0
- package/src/packages/descriptions/index.js +12 -0
- package/src/packages/descriptions/src/main.vue +89 -0
- package/src/packages/descriptions-item/index.js +12 -0
- package/src/packages/descriptions-item/src/main.vue +26 -0
- package/src/packages/dialog/index.js +12 -0
- package/src/packages/dialog/src/main.vue +336 -0
- package/src/packages/divider/index.js +12 -0
- package/src/packages/divider/src/main.vue +37 -0
- package/src/packages/drawer/index.js +7 -0
- package/src/packages/drawer/src/main.vue +310 -0
- package/src/packages/dropdown/index.js +12 -0
- package/src/packages/dropdown/src/main.vue +82 -0
- package/src/packages/dropdown-menu-item/index.js +12 -0
- package/src/packages/dropdown-menu-item/src/main.vue +29 -0
- package/src/packages/empty/index.js +12 -0
- package/src/packages/empty/src/img-empty.vue +12 -0
- package/src/packages/empty/src/main.vue +49 -0
- package/src/packages/footer/index.js +12 -0
- package/src/packages/footer/src/main.vue +20 -0
- package/src/packages/form/index.js +13 -0
- package/src/packages/form/src/form-field.vue +790 -0
- package/src/packages/form/src/form-item.vue +464 -0
- package/src/packages/form/src/label-wrap.vue +127 -0
- package/src/packages/form/src/main.vue +442 -0
- package/src/packages/form-item/index.js +11 -0
- package/src/packages/header/index.js +12 -0
- package/src/packages/header/src/main.vue +20 -0
- package/src/packages/icon/index.js +12 -0
- package/src/packages/icon/src/main.vue +48 -0
- package/src/packages/image/index.js +12 -0
- package/src/packages/image/src/main.vue +224 -0
- package/src/packages/input/index.js +13 -0
- package/src/packages/input/src/calcTextareaHeight.js +123 -0
- package/src/packages/input/src/main.vue +510 -0
- package/src/packages/input-number/index.js +12 -0
- package/src/packages/input-number/src/main.vue +121 -0
- package/src/packages/link/index.js +12 -0
- package/src/packages/link/src/main.vue +53 -0
- package/src/packages/loading/index.js +17 -0
- package/src/packages/loading/src/directive.js +54 -0
- package/src/packages/loading/src/main.vue +38 -0
- package/src/packages/loading/src/service.js +63 -0
- package/src/packages/main/index.js +12 -0
- package/src/packages/main/src/main.vue +12 -0
- package/src/packages/menu/index.js +12 -0
- package/src/packages/menu/src/main.vue +117 -0
- package/src/packages/menu-item/index.js +12 -0
- package/src/packages/menu-item/src/main.vue +61 -0
- package/src/packages/message/index.js +95 -0
- package/src/packages/message/src/main.vue +131 -0
- package/src/packages/message-box/index.js +75 -0
- package/src/packages/message-box/src/main.vue +207 -0
- package/src/packages/no-data/index.js +8 -0
- package/src/packages/no-data/src/main.vue +23 -0
- package/src/packages/notification/index.js +72 -0
- package/src/packages/notification/src/main.vue +139 -0
- package/src/packages/option/index.js +13 -0
- package/src/packages/page-header/index.js +12 -0
- package/src/packages/page-header/src/main.vue +27 -0
- package/src/packages/pagination/index.js +12 -0
- package/src/packages/pagination/src/main.vue +255 -0
- package/src/packages/popconfirm/index.js +12 -0
- package/src/packages/popconfirm/src/main.vue +89 -0
- package/src/packages/popover/index.js +12 -0
- package/src/packages/popover/src/main.vue +452 -0
- package/src/packages/progress/index.js +12 -0
- package/src/packages/progress/src/main.vue +236 -0
- package/src/packages/radio/index.js +44 -0
- package/src/packages/radio/src/main.vue +291 -0
- package/src/packages/rate/index.js +12 -0
- package/src/packages/rate/src/main.vue +129 -0
- package/src/packages/result/index.js +12 -0
- package/src/packages/result/src/main.vue +52 -0
- package/src/packages/row/index.js +12 -0
- package/src/packages/row/src/main.vue +57 -0
- package/src/packages/scrollbar/index.js +12 -0
- package/src/packages/scrollbar/src/bar.vue +116 -0
- package/src/packages/scrollbar/src/main.vue +124 -0
- package/src/packages/select/index.js +15 -0
- package/src/packages/select/src/clickoutside.js +20 -0
- package/src/packages/select/src/main.vue +1055 -0
- package/src/packages/select/src/navigation-mixin.js +49 -0
- package/src/packages/select/src/option.vue +249 -0
- package/src/packages/select/src/select-dropdown.vue +95 -0
- package/src/packages/select/src/utils.js +5 -0
- package/src/packages/skeleton/index.js +12 -0
- package/src/packages/skeleton/src/main.vue +76 -0
- package/src/packages/skeleton-item/index.js +12 -0
- package/src/packages/skeleton-item/src/img-placeholder.vue +13 -0
- package/src/packages/skeleton-item/src/main.vue +22 -0
- package/src/packages/slider/index.js +12 -0
- package/src/packages/slider/src/main.vue +176 -0
- package/src/packages/spinner/index.js +12 -0
- package/src/packages/spinner/src/main.vue +27 -0
- package/src/packages/statistic/index.js +12 -0
- package/src/packages/statistic/src/main.vue +100 -0
- package/src/packages/status-timeline-chart/index.js +7 -0
- package/src/packages/status-timeline-chart/src/constants.js +20 -0
- package/src/packages/status-timeline-chart/src/main.vue +499 -0
- package/src/packages/status-timeline-chart/src/option-builder.js +475 -0
- package/src/packages/step/index.js +12 -0
- package/src/packages/step/src/main.vue +183 -0
- package/src/packages/steps/index.js +12 -0
- package/src/packages/steps/src/main.vue +57 -0
- package/src/packages/submenu/index.js +12 -0
- package/src/packages/submenu/src/main.vue +68 -0
- package/src/packages/switch/index.js +12 -0
- package/src/packages/switch/src/main.vue +166 -0
- package/src/packages/tab-pane/index.js +12 -0
- package/src/packages/tab-pane/src/main.vue +74 -0
- package/src/packages/table/index.js +8 -0
- package/src/packages/table/src/components/PagePagination.vue +82 -0
- package/src/packages/table/src/main.vue +153 -0
- package/src/packages/tabs/index.js +12 -0
- package/src/packages/tabs/src/main.vue +167 -0
- package/src/packages/tabs-navigation/index.js +7 -0
- package/src/packages/tabs-navigation/src/main.vue +462 -0
- package/src/packages/tag/index.js +12 -0
- package/src/packages/tag/src/main.vue +194 -0
- package/src/packages/time-picker/index.js +17 -0
- package/src/packages/time-picker/src/date-utils.js +455 -0
- package/src/packages/time-picker/src/main.vue +321 -0
- package/src/packages/time-picker/src/pane/date-range.vue +193 -0
- package/src/packages/time-picker/src/pane/date-time-range.vue +362 -0
- package/src/packages/time-picker/src/pane/date-time.vue +362 -0
- package/src/packages/time-picker/src/pane/date.vue +441 -0
- package/src/packages/time-picker/src/pane/time.vue +260 -0
- package/src/packages/time-picker/src/time-input.vue +203 -0
- package/src/packages/time-picker/src/time-range-input.vue +170 -0
- package/src/packages/timeline/index.js +12 -0
- package/src/packages/timeline/src/main.vue +24 -0
- package/src/packages/timeline-item/index.js +12 -0
- package/src/packages/timeline-item/src/main.vue +78 -0
- package/src/packages/tooltip/index.js +12 -0
- package/src/packages/tooltip/src/main.js +367 -0
- package/src/packages/transfer/index.js +8 -0
- package/src/packages/transfer/src/main.vue +229 -0
- package/src/packages/transfer/src/transfer-panel.vue +245 -0
- package/src/packages/transitions/collapse-transition.js +75 -0
- package/src/packages/tree/index.js +12 -0
- package/src/packages/tree/src/main.vue +322 -0
- package/src/packages/tree/src/model/node.js +348 -0
- package/src/packages/tree/src/model/tree-store.js +354 -0
- package/src/packages/tree/src/model/util.js +10 -0
- package/src/packages/tree/src/tree-node.vue +262 -0
- package/src/packages/upload/index.js +9 -0
- package/src/packages/upload/src/main.vue +415 -0
- package/src/playground/mixins/element.js +98 -0
- package/src/playground/types/element.js +197 -0
- package/src/playground/types/layout.js +80 -0
- package/src/plugins/i18n.js +125 -0
- package/src/styles/fonts/element-icons.ttf +0 -0
- package/src/styles/fonts/element-icons.woff +0 -0
- package/src/styles/index.scss +138 -0
- package/src/styles/reset.scss +257 -0
- package/src/styles/themes/blue.scss +75 -0
- package/src/styles/themes/dark.scss +98 -0
- package/src/styles/themes/index.scss +34 -0
- package/src/styles/themes/light.scss +98 -0
- package/src/styles/themes/variables.scss +233 -0
- package/src/styles/variables.scss +146 -0
- package/src/utils/async-validator/index.js +659 -0
- package/src/utils/browser/index.js +39 -0
- package/src/utils/color.js +76 -0
- package/src/utils/dom/index.js +421 -0
- package/src/utils/dom/scrollbar-width.js +49 -0
- package/src/utils/draggable/core.js +379 -0
- package/src/utils/draggable/draggable.js +478 -0
- package/src/utils/draggable/index.js +61 -0
- package/src/utils/draggable/sortable.js +751 -0
- package/src/utils/lodash/index.js +2395 -0
- package/src/utils/moment/index.js +909 -0
- package/src/utils/playground/index.js +37 -0
- package/src/utils/popper/index.js +308 -0
- package/src/utils/popper/popper.js +1132 -0
- package/src/utils/popper/popup-manager.js +288 -0
- package/src/utils/popper/popup.js +344 -0
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {'bar' | 'line' | 'scatter' | 'custom'} SeriesType 图表系列类型
|
|
3
|
+
*/
|
|
4
|
+
/** @typedef {string} ImageUrl 图片地址, 形如 image://[url] */
|
|
5
|
+
/** @typedef {string} SvgPath SvgPath, 形如 path://[path] */
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {'circle' | 'rect' | 'roundRect' | 'triangle' | 'diamond' | 'pin' | 'arrow' | 'none' | ImageUrl | SvgPath } SymbolType 图例标记类型
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {[number | string, number | string]} DotData 点数据
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef ChartItemProperty 图表图形原型
|
|
14
|
+
* @property {string} color 颜色
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef DotDataProp 自定义点数据
|
|
18
|
+
* @property {DotData} value 点坐标
|
|
19
|
+
* @property {number} [symbolSize] 点大小
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef MarklineDataProp
|
|
23
|
+
* @property {number} xAxis 横坐标
|
|
24
|
+
* @property {number} yAxis 纵坐标
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @typedef MarkLineItem 标记线元数据
|
|
28
|
+
* @property {Array<MarklineDataProp | Number> | null} data 标记线数据
|
|
29
|
+
* @property {ChartItemProperty} [lineStyle] 线条样式
|
|
30
|
+
* @property {ChartItemProperty} [label] 标签
|
|
31
|
+
* @property {SymbolType} [symbol] 图标样式
|
|
32
|
+
* @property {number | [number, number]} symbolSize 图标大小, 左右统一配置/分别配置
|
|
33
|
+
* @property {number} [zlevel] 标记线 Z 层级
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @typedef SeriesItem 系列元数据
|
|
37
|
+
* @property {SeriesType} type - 系列类型
|
|
38
|
+
* @property {string} name - 系列名称
|
|
39
|
+
* @property {string} [stack] - 堆叠名称
|
|
40
|
+
* @property {DotData[] | DotDataProp[]} data 图表类型
|
|
41
|
+
* @property {number} [symbolSize] 点大小
|
|
42
|
+
* @property {boolean} downArea 是否显示区域色块
|
|
43
|
+
* @property {MarkLineItem} [markLine] 元素样式
|
|
44
|
+
* @property {number} [zlevel] 系列数据 Z 层级
|
|
45
|
+
* @property {boolean} [onlyLabel] - 是否仅显示标签(柱状图用)
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @typedef TooltipBatchItem Tooltip 系列元数据
|
|
49
|
+
* @property {string} seriesName 系列名称
|
|
50
|
+
* @property {string} axisValueLabel 当前元素的轴标签
|
|
51
|
+
* @property {number} value 当前元素值
|
|
52
|
+
* @property {string} marker 系列标记图标
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @typedef AxisItem 坐标轴元数据
|
|
56
|
+
* @property {string} [type]
|
|
57
|
+
* @property {string} [name]
|
|
58
|
+
* @property {array} [data]
|
|
59
|
+
* @property {object} [axisLine]
|
|
60
|
+
* @property {object} [axisLabel]
|
|
61
|
+
* @property {object} [nameTextStyle]
|
|
62
|
+
* @property {object} [splitLine]
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* @typedef EchartsOption 图表配置项
|
|
66
|
+
* @property {AxisItem | AxisItem[]} xAxis X 轴配置
|
|
67
|
+
* @property {AxisItem | AxisItem[]} yAxis Y 轴配置
|
|
68
|
+
* @property {SeriesItem[]} series 系列数据
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
import { colorOpacityTrans } from '../../../utils/color'
|
|
72
|
+
import { isEmpty, isNumber, isArray, merge } from '../../../utils/lodash'
|
|
73
|
+
import { defaultColorCard } from './utils'
|
|
74
|
+
|
|
75
|
+
// Bar / Line / Scatter
|
|
76
|
+
const BARTYPECODE = 'bar' // 柱状图类型标识
|
|
77
|
+
const LINETYPECODE = 'line' // 折线图类型标识
|
|
78
|
+
const SCATTERTYPECODE = 'scatter' // 散点图类型标识
|
|
79
|
+
// 图表 Tooltip
|
|
80
|
+
const TOOLTIP_AXIS_POINTER_TYPE = 'cross' // Tooltip 轴标签样式
|
|
81
|
+
const ZOOM_HANDLER_ICON = 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z'
|
|
82
|
+
const ZOOM_ICON = 'image://data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNzE4ODQ5MjI4NzQzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQyNDUiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTAgMTgyLjg1NzE0M2MwIDI5LjI1NzE0MyAyMS45NDI4NTcgNTEuMiA1MS4yIDUxLjJoNzMuMTQyODU3djczLjE0Mjg1N2MwIDI5LjI1NzE0MyAyMS45NDI4NTcgNTEuMiA1MS4yIDUxLjJzNTEuMi0yMS45NDI4NTcgNTEuMi01MS4ydi03My4xNDI4NTdoNzMuMTQyODU3YzI5LjI1NzE0MyAwIDUxLjItMjEuOTQyODU3IDUxLjItNTEuMnMtMjEuOTQyODU3LTUxLjItNTEuMi01MS4yaC03My4xNDI4NTdWNTEuMmMwLTI5LjI1NzE0My0yMS45NDI4NTctNTEuMi01MS4yLTUxLjJzLTUxLjIgMjEuOTQyODU3LTUxLjIgNTEuMnY3My4xNDI4NTdoLTczLjE0Mjg1N2MtMjkuMjU3MTQzIDAtNTEuMiAyMS45NDI4NTctNTEuMiA1MS4yek0wIDk4MC4xMTQyODZWNjgwLjIyODU3MWMwLTIxLjk0Mjg1NyAyMS45NDI4NTctNDMuODg1NzE0IDQzLjg4NTcxNC00My44ODU3MTRzNDMuODg1NzE0IDIxLjk0Mjg1NyA0My44ODU3MTUgNDMuODg1NzE0djI1Nmg4NTUuNzcxNDI4Vjg3Ljc3MTQyOUg2ODcuNTQyODU3Yy0yMS45NDI4NTcgMC00My44ODU3MTQtMjEuOTQyODU3LTQzLjg4NTcxNC00My44ODU3MTVTNjU4LjI4NTcxNCAwIDY4MC4yMjg5NzEgMEgxMDAyLjA1NzE0M2M3LjMxNDI4NiA3LjMxNDI4NiAxNC42Mjg1NzEgMTQuNjI4NTcxIDE0LjYyODU3MSAyOS4yNTcxNDNWOTg3LjQyODU3MWMtNy4zMTQyODYgNy4zMTQyODYtMjEuOTQyODU3IDE0LjYyODU3MS0yOS4yNTcxNDMgMTQuNjI4NTcySDIxLjk0Mjg1N2MtMjEuOTQyODU3IDAtMjEuOTQyODU3LTcuMzE0Mjg2LTIxLjk0Mjg1Ny0yMS45NDI4NTd6IiBwLWlkPSI0MjQ2IiBmaWxsPSIjMDA2ZWRjIj48L3BhdGg+PC9zdmc+'
|
|
83
|
+
|
|
84
|
+
const textStyle = {
|
|
85
|
+
overflow: 'truncate',
|
|
86
|
+
ellipsis: '...'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 给定一个二维数组,将其中的每个数组的长度规整为最长的一个数组的长度,使用各自数组中首个元素类型的空值进行填充,原有的元素保持不变
|
|
91
|
+
* 元素类型的空值,如string型的空值为'',number型的空值为0,boolean型的空值为false,object型的空值为{},array型的空值为[],等。
|
|
92
|
+
* @param {Array<Array>} arrays 输入二维数组
|
|
93
|
+
* @return {Array<Array>} 返回规整后的二维数组
|
|
94
|
+
*/
|
|
95
|
+
function arrayRound(arrays) {
|
|
96
|
+
if (!Array.isArray(arrays) || arrays.length === 0) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 统计最大长度
|
|
101
|
+
let maxLength = 0;
|
|
102
|
+
for (const arr of arrays) {
|
|
103
|
+
if (Array.isArray(arr) && arr.length > maxLength) {
|
|
104
|
+
maxLength = arr.length;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 如果最大长度为0(例如所有子数组都是空的),直接返回原数组的副本或空处理
|
|
109
|
+
if (maxLength === 0) {
|
|
110
|
+
return arrays.map(arr => [...arr]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 获取值对应类型下的空值
|
|
114
|
+
const getEmptyValueByType = (value) => {
|
|
115
|
+
if (value === null || value === undefined) return null;
|
|
116
|
+
|
|
117
|
+
const type = typeof value;
|
|
118
|
+
switch (type) {
|
|
119
|
+
case 'string':
|
|
120
|
+
return '';
|
|
121
|
+
case 'number':
|
|
122
|
+
return 0;
|
|
123
|
+
case 'boolean':
|
|
124
|
+
return false;
|
|
125
|
+
case 'object':
|
|
126
|
+
// 区分 Array 和 Object 以及 null (null 上面已处理,但为了保险)
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
if (value instanceof Date) {
|
|
131
|
+
return new Date(0); // 或者 null,视具体业务而定,这里暂定为空对象逻辑之外的特殊处理,通常归为object
|
|
132
|
+
}
|
|
133
|
+
return {};
|
|
134
|
+
default:
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// 开始遍历与填充
|
|
140
|
+
return arrays.map(subArray => {
|
|
141
|
+
// 如果不是数组,返回一个填充最大长度的数组
|
|
142
|
+
if (!Array.isArray(subArray)) {
|
|
143
|
+
return Array(maxLength).fill(null)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 如果当前数组长度已经等于最大长度,无需填充(返回副本以防修改原数据)
|
|
147
|
+
const currentLength = subArray.length;
|
|
148
|
+
if (currentLength >= maxLength) {
|
|
149
|
+
return [...subArray];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 确定填充用的模板值
|
|
153
|
+
let fillValue = null;
|
|
154
|
+
if (subArray.length > 0) {
|
|
155
|
+
fillValue = getEmptyValueByType(subArray[0]);
|
|
156
|
+
}
|
|
157
|
+
// 创建新数组并填充
|
|
158
|
+
const newArray = [...subArray, ...Array(maxLength - currentLength).fill(fillValue)];
|
|
159
|
+
|
|
160
|
+
return newArray;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* X 轴配置整合
|
|
166
|
+
* @returns {object | Array<object>}
|
|
167
|
+
*/
|
|
168
|
+
export function xAxis() {
|
|
169
|
+
if (isArray(this.xAxisName) || (isArray(this.xAxisData) && this.xAxisData.some(isArray)) || isArray(this.xAxisValueMin) || isArray(this.xAxisValueMin)) {
|
|
170
|
+
// 检测到多个 X 轴配置
|
|
171
|
+
const nameList = isArray(this.xAxisName) ? this.xAxisName : [this.xAxisName]
|
|
172
|
+
const axisDataList = isArray(this.xAxisData) && this.xAxisData.some(isArray) ? this.xAxisData : [this.xAxisData]
|
|
173
|
+
const minList = isArray(this.xAxisValueMin) ? this.xAxisValueMin : [this.xAxisValueMin]
|
|
174
|
+
const maxList = isArray(this.xAxisValueMax) ? this.xAxisValueMax : [this.xAxisValueMax]
|
|
175
|
+
|
|
176
|
+
const [newNameList, newAxisDataList, newMinList, newMaxList] = arrayRound([nameList, axisDataList, minList, maxList])
|
|
177
|
+
return newNameList.map((name, index) => ({
|
|
178
|
+
...xAxisItem.call(this),
|
|
179
|
+
name,
|
|
180
|
+
data: newAxisDataList[index] || undefined,
|
|
181
|
+
...(!(this.xAxisType === 'category') && { min: newMinList[index] || undefined, max: newMaxList[index] || undefined })
|
|
182
|
+
}))
|
|
183
|
+
} else {
|
|
184
|
+
// 单一 X 轴
|
|
185
|
+
return {
|
|
186
|
+
...xAxisItem.call(this),
|
|
187
|
+
name: this.xAxisName,
|
|
188
|
+
data: this.xAxisData || undefined,
|
|
189
|
+
...(!(this.xAxisType === 'category') && { min: this.xAxisValueMin || undefined, max: this.xAxisValueMax || undefined })
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 生成单个 X 轴配置
|
|
195
|
+
* @returns {object}
|
|
196
|
+
*/
|
|
197
|
+
function xAxisItem() {
|
|
198
|
+
const that = this
|
|
199
|
+
const axisData = isArray(this.xAxisData) && !isEmpty(this.xAxisData) ? this.xAxisData : []
|
|
200
|
+
return {
|
|
201
|
+
type: this.xAxisType,
|
|
202
|
+
data: axisData,
|
|
203
|
+
inverse: this.reverse,
|
|
204
|
+
splitLine: { lineStyle: { get color () { return colorOpacityTrans(that.xAxisSplitLineColor) }}}, // 标准化色值, 下同
|
|
205
|
+
axisLine: {
|
|
206
|
+
show: true,
|
|
207
|
+
lineStyle: { get color () { return colorOpacityTrans(that.xAxisLineColor) } }
|
|
208
|
+
},
|
|
209
|
+
axisLabel: {
|
|
210
|
+
width: this.xAxisLabelWidth,
|
|
211
|
+
...textStyle,
|
|
212
|
+
get color () { return colorOpacityTrans(that.xAxisLabelColor) },
|
|
213
|
+
fontSize: this.xAxisLabelFontSize,
|
|
214
|
+
formatter: this.xAxisLabelFormatter,
|
|
215
|
+
tooltip: { show: true },
|
|
216
|
+
showMinLabel: this.xAxisShowMinLabel,
|
|
217
|
+
showMaxLabel: this.xAxisShowMaxLabel,
|
|
218
|
+
},
|
|
219
|
+
nameTextStyle: {
|
|
220
|
+
get color () { return colorOpacityTrans(that.xAxisNameColor) },
|
|
221
|
+
fontSize: this.xAxisNameFontSize,
|
|
222
|
+
padding: [8, 0, 0, 20],
|
|
223
|
+
verticalAlign: 'top',
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Y 轴配置整合
|
|
230
|
+
* @return {object | Array<object>}
|
|
231
|
+
*/
|
|
232
|
+
export function yAxis() {
|
|
233
|
+
if (isArray(this.yAxisName) || isArray(this.yAxisValueMax)) {
|
|
234
|
+
// 检测到多个 Y 轴
|
|
235
|
+
const nameList = isArray(this.yAxisName) ? this.yAxisName : [this.yAxisName]
|
|
236
|
+
const minList = isArray(this.yAxisValueMin) ? this.yAxisValueMin : [this.yAxisValueMin]
|
|
237
|
+
const maxList = isArray(this.yAxisValueMax) ? this.yAxisValueMax : [this.yAxisValueMax]
|
|
238
|
+
|
|
239
|
+
const [newNameList, newMinList, newMaxList] = arrayRound([nameList, minList, maxList])
|
|
240
|
+
return newNameList.map((name, index) => ({
|
|
241
|
+
...yAxisItem.call(this),
|
|
242
|
+
name,
|
|
243
|
+
min: newMinList[index] || undefined,
|
|
244
|
+
max: newMaxList[index] || undefined
|
|
245
|
+
}))
|
|
246
|
+
} else {
|
|
247
|
+
// 单一 Y 轴
|
|
248
|
+
return {
|
|
249
|
+
...yAxisItem.call(this),
|
|
250
|
+
name: this.yAxisName,
|
|
251
|
+
min: this.yAxisValueMin || undefined,
|
|
252
|
+
max: this.yAxisValueMax || undefined
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 生成单个 Y 轴配置
|
|
258
|
+
* @returns {object}
|
|
259
|
+
*/
|
|
260
|
+
function yAxisItem() {
|
|
261
|
+
const that = this
|
|
262
|
+
return {
|
|
263
|
+
type: 'value',
|
|
264
|
+
alignTicks: true,
|
|
265
|
+
splitLine: { lineStyle: { get color () { return colorOpacityTrans(that.yAxisSplitLineColor) }}},
|
|
266
|
+
axisLine: {
|
|
267
|
+
show: true,
|
|
268
|
+
onZero: false,
|
|
269
|
+
lineStyle: { get color () { return colorOpacityTrans(that.yAxisLineColor) } }
|
|
270
|
+
},
|
|
271
|
+
axisLabel: {
|
|
272
|
+
get color () { return colorOpacityTrans(that.yAxisLabelColor) },
|
|
273
|
+
fontSize: this.yAxisLabelFontSize,
|
|
274
|
+
showMinLabel: this.yAxisShowMinLabel,
|
|
275
|
+
showMaxLabel: this.yAxisShowMaxLabel,
|
|
276
|
+
},
|
|
277
|
+
nameTextStyle: {
|
|
278
|
+
width: this.yAxisLabelWidth,
|
|
279
|
+
get color () { return colorOpacityTrans(that.yAxisNameColor) },
|
|
280
|
+
fontSize: this.yAxisNameFontSize
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 图表系列数据配置
|
|
287
|
+
*/
|
|
288
|
+
export function series() {
|
|
289
|
+
return this.seriesData.map((s, i) => {
|
|
290
|
+
let dataWithTransposive = []
|
|
291
|
+
if (this.fastRender) {
|
|
292
|
+
// 快速加载模式下, 不进行数据预处理
|
|
293
|
+
dataWithTransposive = s.data
|
|
294
|
+
} else {
|
|
295
|
+
// 数组倒置
|
|
296
|
+
/** @type {DotData[] | DotDataProp[]} */
|
|
297
|
+
const dataWithReverse = s.data ?? []
|
|
298
|
+
// 数组二维化
|
|
299
|
+
/** @type {DotData[] | DotDataProp[]} */
|
|
300
|
+
const dataWithArrayly = dataWithReverse.map((v, i) => isArray(v) ? v :
|
|
301
|
+
typeof v === 'object' ?
|
|
302
|
+
{ ...v, value: typeof v?.value === 'object' ?
|
|
303
|
+
v.value
|
|
304
|
+
: [labelDataBindHandler.call(this, i, this.xAxisData), v?.value] }
|
|
305
|
+
: [labelDataBindHandler.call(this, i, this.xAxisData), v]
|
|
306
|
+
)
|
|
307
|
+
// 数组转置
|
|
308
|
+
dataWithTransposive = this.transpose ? dataWithArrayly.map(v => [v[1], v[0]]) : dataWithArrayly
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 系列数据规整
|
|
312
|
+
s.type === BARTYPECODE && barExtend.call(this, s)
|
|
313
|
+
s.type === LINETYPECODE && lineExtend.call(this, s, i)
|
|
314
|
+
s.type === SCATTERTYPECODE && scatterExtend.call(this, s)
|
|
315
|
+
|
|
316
|
+
const markLine = s.markLine ? marklinkRender.call(this, s.markLine, i) : {}
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
symbolSize: this.symbolSize,
|
|
320
|
+
...s,
|
|
321
|
+
data: dataWithTransposive,
|
|
322
|
+
label: {
|
|
323
|
+
show: this.showValue,
|
|
324
|
+
position: this.valueLabelPosition
|
|
325
|
+
},
|
|
326
|
+
markLine
|
|
327
|
+
}
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 数据标签绑定处理
|
|
332
|
+
* @param {number} index - 数据索引
|
|
333
|
+
* @param {array} labelSet - 数据标签集合
|
|
334
|
+
* @returns {string | number} 数据标签
|
|
335
|
+
*/
|
|
336
|
+
function labelDataBindHandler(index, labelSet = []) {
|
|
337
|
+
if (this.dataBindWithLabel || this.xAxisType === 'category') {
|
|
338
|
+
if (isArray(labelSet) && !isEmpty(labelSet)) {
|
|
339
|
+
return labelSet[index]
|
|
340
|
+
} else {
|
|
341
|
+
return index
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
return index
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 柱状图配置
|
|
349
|
+
* @param {object} series 图表单系列数据
|
|
350
|
+
* @param {number} index 系列索引
|
|
351
|
+
*/
|
|
352
|
+
function barExtend(series, index) {
|
|
353
|
+
const that = this
|
|
354
|
+
merge(series, {
|
|
355
|
+
emphasis: { label: { show: that.showValue } }
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 折线图配置
|
|
360
|
+
* @param {object} series 图表单系列数据
|
|
361
|
+
* @param {number} index 系列索引
|
|
362
|
+
*/
|
|
363
|
+
function lineExtend(series, index) {
|
|
364
|
+
const that = this
|
|
365
|
+
const itemColor = series?.color || color.call(this)[index] || ''
|
|
366
|
+
const areaStyleProp = (isArray(series.data) && !isEmpty(series.data)) && series.downArea && itemColor ? {
|
|
367
|
+
areaStyle: {
|
|
368
|
+
color: {
|
|
369
|
+
colorStops: [
|
|
370
|
+
{ offset: 0, get color() { return colorOpacityTrans(itemColor) } },
|
|
371
|
+
{ offset: 1, get color() { return colorOpacityTrans('base-bg', 0) } }
|
|
372
|
+
],
|
|
373
|
+
x: 0, y: 0, x2: 0, y2: 1, type: 'linear', global: false
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} : {}
|
|
377
|
+
merge(series, {
|
|
378
|
+
// 根据主题切换节点 Icon
|
|
379
|
+
get symbol () { return that.theme === 'dark' ? 'circle' : 'emptyCircle' },
|
|
380
|
+
}, areaStyleProp)
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* 散点图配置
|
|
384
|
+
* @param {object} series 图表单系列数据
|
|
385
|
+
* @param {number} index 系列索引
|
|
386
|
+
*/
|
|
387
|
+
function scatterExtend(series, index) {
|
|
388
|
+
const that = this
|
|
389
|
+
merge(series, {
|
|
390
|
+
// 根据主题切换节点 Icon
|
|
391
|
+
get symbol () { return that.theme === 'dark' ? 'circle' : 'emptyCircle' }
|
|
392
|
+
})
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* 标记线配置
|
|
396
|
+
* @param {MarkLineItem} marklineItem - 元素元数据
|
|
397
|
+
* @param {number} itemIndex - 元素索引
|
|
398
|
+
* @returns {MarkLineItem}
|
|
399
|
+
*/
|
|
400
|
+
function marklinkRender(marklineItem, itemIndex) {
|
|
401
|
+
const that = this
|
|
402
|
+
if (isArray(marklineItem.data)) {
|
|
403
|
+
let prop = merge({}, marklineItem, {
|
|
404
|
+
lineStyle: { get color() { return color.call(that)[itemIndex] } },
|
|
405
|
+
label: { get color() { return color.call(that)[itemIndex] } },
|
|
406
|
+
symbol: 'none'
|
|
407
|
+
})
|
|
408
|
+
if (marklineItem.data.every(isNumber)) {
|
|
409
|
+
// 如果标记线数据全为数字, 视作坐标标记线
|
|
410
|
+
// 转置处理
|
|
411
|
+
if (this.transpose) {
|
|
412
|
+
prop.data = marklineItem.data.map(xAxis => ({ xAxis }))
|
|
413
|
+
} else {
|
|
414
|
+
prop.data = marklineItem.data.map(yAxis => ({ yAxis }))
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
// 否则使用原配置
|
|
418
|
+
prop.data = marklineItem.data
|
|
419
|
+
}
|
|
420
|
+
return prop
|
|
421
|
+
} else {
|
|
422
|
+
return {}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 图表色卡配置
|
|
428
|
+
* @returns {Array<string>}
|
|
429
|
+
*/
|
|
430
|
+
export function color() {
|
|
431
|
+
const colorCard = [...new Set([...this.colorMap, ...defaultColorCard])] // 去重, 合并默认色卡
|
|
432
|
+
return colorCard.map(t => colorOpacityTrans(t)) // 色卡名称转色值
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 生成数据缩放配置
|
|
437
|
+
* @returns {object}
|
|
438
|
+
*/
|
|
439
|
+
export function dataZoom() {
|
|
440
|
+
if (!this.isZoom) return null;
|
|
441
|
+
|
|
442
|
+
// 图例位置解析
|
|
443
|
+
const zoomBarPositionProp = () => {
|
|
444
|
+
const positionObj = { orient: ['top', 'bottom'].includes(this.zoomBarPosition) ? 'horizontal' : 'vertical' };
|
|
445
|
+
if (this.zoomBarPosition === 'top') positionObj.top = this.zoomBarGap;
|
|
446
|
+
if (this.zoomBarPosition === 'right') positionObj.right = this.zoomBarGap;
|
|
447
|
+
if (this.zoomBarPosition === 'bottom') positionObj.bottom = this.zoomBarGap;
|
|
448
|
+
if (this.zoomBarPosition === 'left') positionObj.left = this.zoomBarGap;
|
|
449
|
+
return positionObj;
|
|
450
|
+
}
|
|
451
|
+
const dataZoomBar = {
|
|
452
|
+
show: true,
|
|
453
|
+
type: 'slider',
|
|
454
|
+
height: this.zoomBarHeight,
|
|
455
|
+
...zoomBarPositionProp(),
|
|
456
|
+
borderColor: 'transparent',
|
|
457
|
+
get backgroundColor() { return colorOpacityTrans('fifth-blue', 0.8) },
|
|
458
|
+
get fillerColor () { return colorOpacityTrans('blue-1', 0.1) },
|
|
459
|
+
handleIcon: ZOOM_HANDLER_ICON,
|
|
460
|
+
icon: { zoom: ZOOM_ICON, back: 'image://' },
|
|
461
|
+
handleSize: '110%',
|
|
462
|
+
handleStyle: { get color() { return colorOpacityTrans('blue-5') }},
|
|
463
|
+
textStyle: { get color () { return colorOpacityTrans('td-text') }},
|
|
464
|
+
labelFormatter: this.zoomBarLabelFormatter || undefined
|
|
465
|
+
}
|
|
466
|
+
if (isArray(this.displayRange) && this.displayRange[0] && this.displayRange[1]) {
|
|
467
|
+
// 如果配置了初始展示范围
|
|
468
|
+
return {
|
|
469
|
+
...dataZoomBar,
|
|
470
|
+
startValue: this.displayRange[0],
|
|
471
|
+
endValue: this.displayRange[1]
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
return dataZoomBar
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 生成 Tooltip 配置
|
|
480
|
+
* @returns {object}
|
|
481
|
+
*/
|
|
482
|
+
export function tooltip() {
|
|
483
|
+
if (!this.hasTooltip) return undefined
|
|
484
|
+
|
|
485
|
+
return {
|
|
486
|
+
trigger: this.tooltipTrigger,
|
|
487
|
+
...(this.axisTooltip && {
|
|
488
|
+
axisPointer: {
|
|
489
|
+
type: TOOLTIP_AXIS_POINTER_TYPE,
|
|
490
|
+
label: { get backgroundColor () { return colorOpacityTrans('blue-4') } }
|
|
491
|
+
}
|
|
492
|
+
}),
|
|
493
|
+
formatter: this.tooltipFormatter ?? defaultTooltipFormatter.bind(this)
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* 默认 Tooltip 格式器
|
|
498
|
+
* @param {TooltipBatchItem[]} batch - 系列数据
|
|
499
|
+
*/
|
|
500
|
+
function defaultTooltipFormatter(batch) {
|
|
501
|
+
if (isArray(batch)) {
|
|
502
|
+
// 轴索引标签
|
|
503
|
+
const nameItem = `<div>${batch[0].axisValueLabel}</div>`
|
|
504
|
+
// 各系列数据数据描述
|
|
505
|
+
const itemRow = batch.map((prop, index) => {
|
|
506
|
+
const { marker, seriesName, value } = prop
|
|
507
|
+
if (!value || !isArray(value) || (isArray(value) && value.some(isEmpty)) || this.seriesData[index]?.onlyLabel) {
|
|
508
|
+
// 如果无数据或系列仅展示标签, Tooltip 不展示对应数据
|
|
509
|
+
return ''
|
|
510
|
+
} else {
|
|
511
|
+
// 否则拼装数据描述
|
|
512
|
+
let unit = this.tooltipWithUtil ? (this.yAxisUnit[index] ?? this.yAxisName[index] ?? '') : ''
|
|
513
|
+
const str = '<div style="width: 100%; min-width: 130px; display: flex; align-items: center; justify-content: flex-start">' +
|
|
514
|
+
`<div>${marker}</div>` + // 系列标记 Icon
|
|
515
|
+
`<div style="margin: 0 10px 0 5px">${seriesName}</div>` + // 系列名称
|
|
516
|
+
`<div style="margin-left: auto; font-weight: 700">${value[1]} ${unit}</div>` + // 数值
|
|
517
|
+
'</div>'
|
|
518
|
+
return str
|
|
519
|
+
}
|
|
520
|
+
})
|
|
521
|
+
return itemRow.filter(v => v).join('') ? `<div>${nameItem}${itemRow.filter(v => v).join('')}</div>` : ''
|
|
522
|
+
} else {
|
|
523
|
+
return ''
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* 生成图例配置
|
|
529
|
+
* @returns {object}
|
|
530
|
+
*/
|
|
531
|
+
export function legend() {
|
|
532
|
+
if (!this.displayLegend) return undefined;
|
|
533
|
+
|
|
534
|
+
// 图例列表
|
|
535
|
+
const legendList = isArray(this.seriesData) && !isEmpty(this.seriesData) ? this.seriesData.map(item => ({
|
|
536
|
+
name: item.name,
|
|
537
|
+
icon: item.legendIcon,
|
|
538
|
+
textStyle: { get color() { return colorOpacityTrans('sd-text') } },
|
|
539
|
+
itemStyle: seriesItemStyleRedner(item),
|
|
540
|
+
lineStyle: seriesLineStyleRender(item),
|
|
541
|
+
})) : []
|
|
542
|
+
// 图例位置
|
|
543
|
+
const legendPositionProp = () => {
|
|
544
|
+
const positionObj = {};
|
|
545
|
+
if (this.legendPosition.includes('top')) positionObj.top = this.legendBorderGap;
|
|
546
|
+
if (this.legendPosition.includes('right')) positionObj.right = this.legendBorderGap;
|
|
547
|
+
if (this.legendPosition.includes('bottom')) positionObj.bottom = this.legendBorderGap;
|
|
548
|
+
if (this.legendPosition.includes('left')) positionObj.left = this.legendBorderGap;
|
|
549
|
+
return positionObj;
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
show: true,
|
|
553
|
+
selectedMode: this.selectedMode,
|
|
554
|
+
...legendPositionProp(),
|
|
555
|
+
itemGap: this.legendItemGap,
|
|
556
|
+
itemWidth: this.legendItemWidth,
|
|
557
|
+
itemHeight: this.legendItemHeight,
|
|
558
|
+
textStyle: {
|
|
559
|
+
height: this.legendItemHeight,
|
|
560
|
+
padding: [2, 0, 0, 4],
|
|
561
|
+
lineHeight: this.legendItemHeight,
|
|
562
|
+
rich: { align: { verticalAlign: 'middle' } },
|
|
563
|
+
},
|
|
564
|
+
data: legendList,
|
|
565
|
+
pageButtonItemGap: this.legendPageButtonGap,
|
|
566
|
+
pageButtonGap: this.legendPageGap,
|
|
567
|
+
pageButtonPosition: this.legendPagePosition,
|
|
568
|
+
get pageIconColor() { return colorOpacityTrans('sd-text') },
|
|
569
|
+
get pageIconInactiveColor() { return colorOpacityTrans('td-text') },
|
|
570
|
+
pageTextStyle: { get color() { return colorOpacityTrans('primary-text') } },
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* 元素样式配置
|
|
575
|
+
* @param {SeriesItem} item - 元素元数据
|
|
576
|
+
* @returns {object | null} 元素样式
|
|
577
|
+
*/
|
|
578
|
+
function seriesItemStyleRedner(item) {
|
|
579
|
+
switch (item.type) {
|
|
580
|
+
case BARTYPECODE:
|
|
581
|
+
return {
|
|
582
|
+
borderWidth: 2
|
|
583
|
+
}
|
|
584
|
+
case LINETYPECODE:
|
|
585
|
+
if (isArray(item.markLine?.data)) {
|
|
586
|
+
return {
|
|
587
|
+
opacity: 0
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
return null
|
|
591
|
+
}
|
|
592
|
+
default:
|
|
593
|
+
return null
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* 元素线样式配置
|
|
598
|
+
* @param {SeriesItem} item - 元素元数据
|
|
599
|
+
* @returns {object | null} 元素线样式
|
|
600
|
+
*/
|
|
601
|
+
function seriesLineStyleRender(item) {
|
|
602
|
+
switch (item.type) {
|
|
603
|
+
case LINETYPECODE:
|
|
604
|
+
if (isArray(item.markLine?.data)) {
|
|
605
|
+
return {
|
|
606
|
+
width: 2,
|
|
607
|
+
type: 'solid',
|
|
608
|
+
}
|
|
609
|
+
} else {
|
|
610
|
+
return {
|
|
611
|
+
width: 2,
|
|
612
|
+
type: [3, 3],
|
|
613
|
+
dashOffset: [2, 5]
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
default:
|
|
617
|
+
return null
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* 生成图表布局配置
|
|
623
|
+
* @returns {object}
|
|
624
|
+
*/
|
|
625
|
+
export function grid() {
|
|
626
|
+
const gridProp = {
|
|
627
|
+
top: this.gridTop,
|
|
628
|
+
bottom: this.gridBottom,
|
|
629
|
+
left: this.gridLeft,
|
|
630
|
+
right: this.gridRight,
|
|
631
|
+
containLabel: this.gridContainLabel,
|
|
632
|
+
}
|
|
633
|
+
// 展示图例时, 图表为图例预留空间
|
|
634
|
+
if (this.displayLegend) {
|
|
635
|
+
if (['top', 'bottom'].includes(this.legendPosition)) {
|
|
636
|
+
gridProp[this.legendPosition] += this.legendBorderGap + this.legendItemHeight
|
|
637
|
+
} else if (['left', 'right'].includes(this.legendPosition)) {
|
|
638
|
+
gridProp[this.legendPosition] += this.legendBorderGap + this.legendItemWidth
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// 启用图表缩放时, 图表为缩放控件预留空间
|
|
642
|
+
if (this.isZoom) {
|
|
643
|
+
gridProp[this.zoomBarPosition] += this.zoomBarGap + this.zoomBarChartGap
|
|
644
|
+
}
|
|
645
|
+
return gridProp
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* 生成坐标系图表配置项
|
|
650
|
+
* @returns {object}
|
|
651
|
+
*/
|
|
652
|
+
export function options() {
|
|
653
|
+
const xAxisProp = xAxis.call(this)
|
|
654
|
+
const yAxisProp = yAxis.call(this)
|
|
655
|
+
|
|
656
|
+
const defaultOption = {
|
|
657
|
+
xAxis: this.transpose ? yAxisProp : xAxisProp,
|
|
658
|
+
yAxis: this.transpose ? xAxisProp : yAxisProp,
|
|
659
|
+
series: series.call(this),
|
|
660
|
+
darkMode: this.theme === 'dark',
|
|
661
|
+
color: color.call(this),
|
|
662
|
+
grid: grid.call(this),
|
|
663
|
+
legend: legend.call(this),
|
|
664
|
+
tooltip: tooltip.call(this),
|
|
665
|
+
dataZoom: dataZoom.call(this),
|
|
666
|
+
textStyle,
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// 如果配置了 beforeRender 函数, 执行一次渲染前操作
|
|
670
|
+
if (this.beforeRender && this.beforeRender instanceof Function) {
|
|
671
|
+
this.beforeRender(defaultOption)
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return defaultOption
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* 导出为 VueMixins 对象
|
|
679
|
+
*/
|
|
680
|
+
export default {
|
|
681
|
+
data: () => ({}),
|
|
682
|
+
computed: {
|
|
683
|
+
options() {
|
|
684
|
+
this.theme
|
|
685
|
+
return options.call(this)
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
watch: {
|
|
689
|
+
theme(theme) {
|
|
690
|
+
this.chartRender()
|
|
691
|
+
},
|
|
692
|
+
options: {
|
|
693
|
+
handler(opt) {
|
|
694
|
+
this.chartRender(opt)
|
|
695
|
+
},
|
|
696
|
+
immediate: true,
|
|
697
|
+
deep: true
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
}
|