@kevairy/template 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +14 -0
- package/package.json +37 -0
- package/template/.env +22 -0
- package/template/.env.development +13 -0
- package/template/.env.production +10 -0
- package/template/.prettierignore +3 -0
- package/template/.prettierrc +20 -0
- package/template/.stylelintignore +9 -0
- package/template/.stylelintrc.cjs +84 -0
- package/template/LICENSE +21 -0
- package/template/README.md +22 -0
- package/template/_gitignore +19 -0
- package/template/eslint-auto-import.json +324 -0
- package/template/eslint.config.mjs +83 -0
- package/template/index.html +25 -0
- package/template/package.json +79 -0
- package/template/playwright.config.ts +25 -0
- package/template/public/favicon.ico +0 -0
- package/template/src/App.vue +39 -0
- package/template/src/adapters/auth/index.ts +9 -0
- package/template/src/adapters/auth/mock.ts +10 -0
- package/template/src/adapters/auth/types.ts +11 -0
- package/template/src/adapters/navigation/index.ts +13 -0
- package/template/src/adapters/navigation/types.ts +6 -0
- package/template/src/api/auth.ts +23 -0
- package/template/src/assets/images/avatar/avatar.webp +0 -0
- package/template/src/assets/images/avatar/avatar1.webp +0 -0
- package/template/src/assets/images/avatar/avatar10.webp +0 -0
- package/template/src/assets/images/avatar/avatar2.webp +0 -0
- package/template/src/assets/images/avatar/avatar3.webp +0 -0
- package/template/src/assets/images/avatar/avatar4.webp +0 -0
- package/template/src/assets/images/avatar/avatar5.webp +0 -0
- package/template/src/assets/images/avatar/avatar6.webp +0 -0
- package/template/src/assets/images/avatar/avatar7.webp +0 -0
- package/template/src/assets/images/avatar/avatar8.webp +0 -0
- package/template/src/assets/images/avatar/avatar9.webp +0 -0
- package/template/src/assets/images/ceremony/hb.png +0 -0
- package/template/src/assets/images/ceremony/sd.png +0 -0
- package/template/src/assets/images/ceremony/xc.png +0 -0
- package/template/src/assets/images/ceremony/yd.png +0 -0
- package/template/src/assets/images/common/logo.webp +0 -0
- package/template/src/assets/images/draw/draw1.png +0 -0
- package/template/src/assets/images/favicon.ico +0 -0
- package/template/src/assets/images/lock/bg_dark.webp +0 -0
- package/template/src/assets/images/lock/bg_light.webp +0 -0
- package/template/src/assets/images/login/kylin-hero-source.png +0 -0
- package/template/src/assets/images/login/lf_icon2.webp +0 -0
- package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
- package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
- package/template/src/assets/images/settings/menu_styles/design.png +0 -0
- package/template/src/assets/images/settings/menu_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
- package/template/src/assets/images/settings/theme_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/system.png +0 -0
- package/template/src/assets/images/svg/403.svg +1 -0
- package/template/src/assets/images/svg/404.svg +1 -0
- package/template/src/assets/images/svg/500.svg +5 -0
- package/template/src/assets/images/svg/login_icon.svg +1 -0
- package/template/src/assets/images/user/avatar.webp +0 -0
- package/template/src/assets/images/user/bg.webp +0 -0
- package/template/src/assets/styles/core/app.scss +227 -0
- package/template/src/assets/styles/core/dark.scss +93 -0
- package/template/src/assets/styles/core/el-dark.scss +2 -0
- package/template/src/assets/styles/core/el-light.scss +34 -0
- package/template/src/assets/styles/core/el-ui.scss +519 -0
- package/template/src/assets/styles/core/md.scss +1036 -0
- package/template/src/assets/styles/core/mixin.scss +157 -0
- package/template/src/assets/styles/core/reset.scss +41 -0
- package/template/src/assets/styles/core/router-transition.scss +104 -0
- package/template/src/assets/styles/core/tailwind.css +219 -0
- package/template/src/assets/styles/core/theme-animation.scss +63 -0
- package/template/src/assets/styles/core/theme-change.scss +11 -0
- package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
- package/template/src/assets/styles/index.scss +23 -0
- package/template/src/assets/svg/loading.ts +32 -0
- package/template/src/bootstrap/initializeApp.ts +30 -0
- package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
- package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
- package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
- package/template/src/components/core/base/art-logo/index.vue +34 -0
- package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
- package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
- package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
- package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
- package/template/src/components/core/cards/art-image-card/index.vue +89 -0
- package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
- package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
- package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
- package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
- package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
- package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
- package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
- package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
- package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
- package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
- package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
- package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
- package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
- package/template/src/components/core/forms/art-button-more/index.vue +71 -0
- package/template/src/components/core/forms/art-button-table/index.vue +59 -0
- package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
- package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
- package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
- package/template/src/components/core/forms/art-form/index.vue +507 -0
- package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
- package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
- package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
- package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
- package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
- package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
- package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
- package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
- package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
- package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
- package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
- package/template/src/components/core/layouts/art-notification/index.vue +456 -0
- package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
- package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
- package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
- package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
- package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
- package/template/src/components/core/media/art-video-player/index.vue +111 -0
- package/template/src/components/core/others/art-menu-right/index.vue +415 -0
- package/template/src/components/core/others/art-watermark/index.vue +64 -0
- package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
- package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
- package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
- package/template/src/components/core/theme/theme-svg/index.vue +100 -0
- package/template/src/components/core/views/exception/ArtException.vue +55 -0
- package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
- package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
- package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
- package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
- package/template/src/config/assets/images.ts +61 -0
- package/template/src/config/index.ts +170 -0
- package/template/src/config/modules/component.ts +98 -0
- package/template/src/config/modules/fastEnter.ts +16 -0
- package/template/src/config/modules/festival.ts +51 -0
- package/template/src/config/modules/headerBar.ts +64 -0
- package/template/src/config/setting.ts +109 -0
- package/template/src/directives/core/auth.ts +66 -0
- package/template/src/directives/core/highlight-loader.ts +37 -0
- package/template/src/directives/core/highlight.ts +253 -0
- package/template/src/directives/core/ripple.ts +116 -0
- package/template/src/directives/core/roles.ts +87 -0
- package/template/src/directives/index.ts +14 -0
- package/template/src/enums/appEnum.ts +81 -0
- package/template/src/enums/formEnum.ts +17 -0
- package/template/src/env.d.ts +32 -0
- package/template/src/hooks/core/useAppMode.ts +45 -0
- package/template/src/hooks/core/useAuth.ts +74 -0
- package/template/src/hooks/core/useCeremony.ts +184 -0
- package/template/src/hooks/core/useChart.ts +745 -0
- package/template/src/hooks/core/useCommon.ts +87 -0
- package/template/src/hooks/core/useFastEnter.ts +55 -0
- package/template/src/hooks/core/useHeaderBar.ts +201 -0
- package/template/src/hooks/core/useLayoutHeight.ts +148 -0
- package/template/src/hooks/core/useTableColumns.ts +313 -0
- package/template/src/hooks/core/useTheme.ts +174 -0
- package/template/src/hooks/index.ts +29 -0
- package/template/src/locales/index.ts +123 -0
- package/template/src/locales/langs/en.json +283 -0
- package/template/src/locales/langs/zh.json +283 -0
- package/template/src/main.ts +29 -0
- package/template/src/mock/auth.ts +46 -0
- package/template/src/plugins/echarts.ts +76 -0
- package/template/src/plugins/index.ts +6 -0
- package/template/src/router/core/ComponentLoader.ts +82 -0
- package/template/src/router/core/IframeRouteManager.ts +78 -0
- package/template/src/router/core/MenuProcessor.ts +280 -0
- package/template/src/router/core/RoutePermissionValidator.ts +161 -0
- package/template/src/router/core/RouteRegistry.ts +90 -0
- package/template/src/router/core/RouteTransformer.ts +132 -0
- package/template/src/router/core/RouteValidator.ts +187 -0
- package/template/src/router/core/index.ts +14 -0
- package/template/src/router/guards/afterEach.ts +34 -0
- package/template/src/router/guards/beforeEach.ts +442 -0
- package/template/src/router/index.ts +24 -0
- package/template/src/router/modules/dashboard.ts +23 -0
- package/template/src/router/modules/examples.ts +109 -0
- package/template/src/router/modules/exception.ts +46 -0
- package/template/src/router/modules/index.ts +12 -0
- package/template/src/router/modules/result.ts +32 -0
- package/template/src/router/routes/asyncRoutes.ts +9 -0
- package/template/src/router/routes/staticRoutes.ts +60 -0
- package/template/src/router/routesAlias.ts +8 -0
- package/template/src/services/auth.ts +15 -0
- package/template/src/store/index.ts +52 -0
- package/template/src/store/modules/menu.ts +109 -0
- package/template/src/store/modules/setting.ts +450 -0
- package/template/src/store/modules/user.ts +218 -0
- package/template/src/store/modules/worktab.ts +568 -0
- package/template/src/types/api/api.d.ts +86 -0
- package/template/src/types/common/index.ts +95 -0
- package/template/src/types/common/response.ts +32 -0
- package/template/src/types/component/chart.ts +324 -0
- package/template/src/types/component/index.ts +86 -0
- package/template/src/types/config/index.ts +253 -0
- package/template/src/types/directive/directive.d.ts +15 -0
- package/template/src/types/import/auto-imports.d.ts +319 -0
- package/template/src/types/import/components.d.ts +126 -0
- package/template/src/types/index.ts +22 -0
- package/template/src/types/router/index.ts +80 -0
- package/template/src/types/store/index.ts +157 -0
- package/template/src/utils/form/index.ts +9 -0
- package/template/src/utils/form/validator.ts +316 -0
- package/template/src/utils/http/contract.ts +39 -0
- package/template/src/utils/http/error.ts +182 -0
- package/template/src/utils/http/index.ts +226 -0
- package/template/src/utils/http/status.ts +18 -0
- package/template/src/utils/index.ts +31 -0
- package/template/src/utils/navigation/index.ts +10 -0
- package/template/src/utils/navigation/jump.ts +68 -0
- package/template/src/utils/navigation/route.ts +85 -0
- package/template/src/utils/navigation/worktab.ts +67 -0
- package/template/src/utils/router.ts +63 -0
- package/template/src/utils/socket/index.ts +423 -0
- package/template/src/utils/storage/index.ts +7 -0
- package/template/src/utils/storage/storage-config.ts +127 -0
- package/template/src/utils/storage/storage-key-manager.ts +97 -0
- package/template/src/utils/storage/storage.ts +250 -0
- package/template/src/utils/sys/console.ts +9 -0
- package/template/src/utils/sys/error-handle.ts +143 -0
- package/template/src/utils/sys/index.ts +2 -0
- package/template/src/utils/sys/mittBus.ts +61 -0
- package/template/src/utils/ui/animation.ts +80 -0
- package/template/src/utils/ui/colors.ts +273 -0
- package/template/src/utils/ui/emojo.ts +24 -0
- package/template/src/utils/ui/iconify-loader.ts +31 -0
- package/template/src/utils/ui/index.ts +11 -0
- package/template/src/utils/ui/loading.ts +158 -0
- package/template/src/utils/ui/tabs.ts +60 -0
- package/template/src/views/auth/forget-password/index.vue +62 -0
- package/template/src/views/auth/login/index.vue +166 -0
- package/template/src/views/auth/login/style.css +38 -0
- package/template/src/views/auth/register/index.vue +240 -0
- package/template/src/views/dashboard/console/index.vue +173 -0
- package/template/src/views/examples/analytics/index.vue +389 -0
- package/template/src/views/examples/complex-form/index.vue +395 -0
- package/template/src/views/examples/crud-workspace/index.vue +412 -0
- package/template/src/views/examples/navigation/detail/index.vue +151 -0
- package/template/src/views/examples/navigation/state/index.vue +226 -0
- package/template/src/views/examples/overview/index.vue +309 -0
- package/template/src/views/examples/permissions/index.vue +303 -0
- package/template/src/views/examples/search-table/index.vue +182 -0
- package/template/src/views/examples/search-table/search.config.ts +81 -0
- package/template/src/views/examples/search-table/service.ts +116 -0
- package/template/src/views/examples/search-table/table.config.ts +37 -0
- package/template/src/views/exception/403/index.vue +16 -0
- package/template/src/views/exception/404/index.vue +16 -0
- package/template/src/views/exception/500/index.vue +16 -0
- package/template/src/views/index/index.vue +29 -0
- package/template/src/views/index/style.scss +93 -0
- package/template/src/views/outside/Iframe.vue +42 -0
- package/template/src/views/result/fail/index.vue +28 -0
- package/template/src/views/result/success/index.vue +21 -0
- package/template/tests/e2e/auth.spec.ts +14 -0
- package/template/tests/e2e/search-table.spec.ts +154 -0
- package/template/tests/unit/adapters/auth.spec.ts +38 -0
- package/template/tests/unit/config/app-config.spec.ts +17 -0
- package/template/tests/unit/directives/highlight.spec.ts +20 -0
- package/template/tests/unit/http/contract.spec.ts +47 -0
- package/template/tests/unit/mock/search-table.spec.ts +62 -0
- package/template/tests/unit/router/examples.spec.ts +52 -0
- package/template/tsconfig.json +28 -0
- package/template/vite.config.ts +181 -0
- package/template/vitest.config.ts +27 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!-- 时间轴列表卡片 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="art-card p-5">
|
|
4
|
+
<div class="pb-3.5">
|
|
5
|
+
<p class="text-lg font-medium">{{ title }}</p>
|
|
6
|
+
<p class="text-sm text-g-600">{{ subtitle }}</p>
|
|
7
|
+
</div>
|
|
8
|
+
<ElScrollbar :style="{ height: maxHeight }">
|
|
9
|
+
<ElTimeline class="!pl-0.5">
|
|
10
|
+
<ElTimelineItem
|
|
11
|
+
v-for="item in list"
|
|
12
|
+
:key="item.time"
|
|
13
|
+
:timestamp="item.time"
|
|
14
|
+
:placement="TIMELINE_PLACEMENT"
|
|
15
|
+
:color="item.status"
|
|
16
|
+
:center="true"
|
|
17
|
+
>
|
|
18
|
+
<div class="flex-c gap-3">
|
|
19
|
+
<div class="flex-c gap-2">
|
|
20
|
+
<span class="text-sm">{{ item.content }}</span>
|
|
21
|
+
<span v-if="item.code" class="text-sm text-theme"> #{{ item.code }} </span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</ElTimelineItem>
|
|
25
|
+
</ElTimeline>
|
|
26
|
+
</ElScrollbar>
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
defineOptions({ name: 'ArtTimelineListCard' })
|
|
32
|
+
|
|
33
|
+
// 常量配置
|
|
34
|
+
const ITEM_HEIGHT = 65
|
|
35
|
+
const TIMELINE_PLACEMENT = 'top'
|
|
36
|
+
const DEFAULT_MAX_COUNT = 5
|
|
37
|
+
|
|
38
|
+
interface TimelineItem {
|
|
39
|
+
/** 时间 */
|
|
40
|
+
time: string
|
|
41
|
+
/** 状态颜色 */
|
|
42
|
+
status: string
|
|
43
|
+
/** 内容 */
|
|
44
|
+
content: string
|
|
45
|
+
/** 代码标识 */
|
|
46
|
+
code?: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface Props {
|
|
50
|
+
/** 时间轴列表数据 */
|
|
51
|
+
list: TimelineItem[]
|
|
52
|
+
/** 标题 */
|
|
53
|
+
title: string
|
|
54
|
+
/** 副标题 */
|
|
55
|
+
subtitle?: string
|
|
56
|
+
/** 最大显示数量 */
|
|
57
|
+
maxCount?: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Props 定义和验证
|
|
61
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
62
|
+
title: '',
|
|
63
|
+
subtitle: '',
|
|
64
|
+
maxCount: DEFAULT_MAX_COUNT
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// 计算最大高度
|
|
68
|
+
const maxHeight = computed(() => `${ITEM_HEIGHT * props.maxCount}px`)
|
|
69
|
+
</script>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<!-- 柱状图 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div ref="chartRef" :style="{ height: props.height }" v-loading="props.loading"> </div>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
|
|
8
|
+
import { getCssVar } from '@/utils/ui'
|
|
9
|
+
import { graphic, type EChartsOption } from '@/plugins/echarts'
|
|
10
|
+
import type { BarChartProps, BarDataItem } from '@/types/component/chart'
|
|
11
|
+
|
|
12
|
+
defineOptions({ name: 'ArtBarChart' })
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<BarChartProps>(), {
|
|
15
|
+
// 基础配置
|
|
16
|
+
height: useChartOps().chartHeight,
|
|
17
|
+
loading: false,
|
|
18
|
+
isEmpty: false,
|
|
19
|
+
colors: () => useChartOps().colors,
|
|
20
|
+
borderRadius: 4,
|
|
21
|
+
|
|
22
|
+
// 数据配置
|
|
23
|
+
data: () => [0, 0, 0, 0, 0, 0, 0],
|
|
24
|
+
xAxisData: () => [],
|
|
25
|
+
barWidth: '40%',
|
|
26
|
+
stack: false,
|
|
27
|
+
|
|
28
|
+
// 轴线显示配置
|
|
29
|
+
showAxisLabel: true,
|
|
30
|
+
showAxisLine: true,
|
|
31
|
+
showSplitLine: true,
|
|
32
|
+
|
|
33
|
+
// 交互配置
|
|
34
|
+
showTooltip: true,
|
|
35
|
+
showLegend: false,
|
|
36
|
+
legendPosition: 'bottom'
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// 判断是否为多数据
|
|
40
|
+
const isMultipleData = computed(() => {
|
|
41
|
+
return (
|
|
42
|
+
Array.isArray(props.data) &&
|
|
43
|
+
props.data.length > 0 &&
|
|
44
|
+
typeof props.data[0] === 'object' &&
|
|
45
|
+
'name' in props.data[0]
|
|
46
|
+
)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 获取颜色配置
|
|
50
|
+
const getColor = (customColor?: string, index?: number) => {
|
|
51
|
+
if (customColor) return customColor
|
|
52
|
+
|
|
53
|
+
if (index !== undefined) {
|
|
54
|
+
return props.colors![index % props.colors!.length]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 默认渐变色
|
|
58
|
+
return new graphic.LinearGradient(0, 0, 0, 1, [
|
|
59
|
+
{
|
|
60
|
+
offset: 0,
|
|
61
|
+
color: getCssVar('--el-color-primary-light-4')
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
offset: 1,
|
|
65
|
+
color: getCssVar('--el-color-primary')
|
|
66
|
+
}
|
|
67
|
+
])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 创建渐变色
|
|
71
|
+
const createGradientColor = (color: string) => {
|
|
72
|
+
return new graphic.LinearGradient(0, 0, 0, 1, [
|
|
73
|
+
{
|
|
74
|
+
offset: 0,
|
|
75
|
+
color: color
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
offset: 1,
|
|
79
|
+
color: color
|
|
80
|
+
}
|
|
81
|
+
])
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 获取基础样式配置
|
|
85
|
+
const getBaseItemStyle = (
|
|
86
|
+
color: string | InstanceType<typeof graphic.LinearGradient> | undefined
|
|
87
|
+
) => ({
|
|
88
|
+
borderRadius: props.borderRadius,
|
|
89
|
+
color: typeof color === 'string' ? createGradientColor(color) : color
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// 创建系列配置
|
|
93
|
+
const createSeriesItem = (config: {
|
|
94
|
+
name?: string
|
|
95
|
+
data: number[]
|
|
96
|
+
color?: string | InstanceType<typeof graphic.LinearGradient>
|
|
97
|
+
barWidth?: string | number
|
|
98
|
+
stack?: string
|
|
99
|
+
}) => {
|
|
100
|
+
const animationConfig = getAnimationConfig()
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
name: config.name,
|
|
104
|
+
data: config.data,
|
|
105
|
+
type: 'bar' as const,
|
|
106
|
+
stack: config.stack,
|
|
107
|
+
itemStyle: getBaseItemStyle(config.color),
|
|
108
|
+
barWidth: config.barWidth || props.barWidth,
|
|
109
|
+
...animationConfig
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 使用新的图表组件抽象
|
|
114
|
+
const {
|
|
115
|
+
chartRef,
|
|
116
|
+
getAxisLineStyle,
|
|
117
|
+
getAxisLabelStyle,
|
|
118
|
+
getAxisTickStyle,
|
|
119
|
+
getSplitLineStyle,
|
|
120
|
+
getAnimationConfig,
|
|
121
|
+
getTooltipStyle,
|
|
122
|
+
getLegendStyle,
|
|
123
|
+
getGridWithLegend
|
|
124
|
+
} = useChartComponent({
|
|
125
|
+
props,
|
|
126
|
+
checkEmpty: () => {
|
|
127
|
+
// 检查单数据情况
|
|
128
|
+
if (Array.isArray(props.data) && typeof props.data[0] === 'number') {
|
|
129
|
+
const singleData = props.data as number[]
|
|
130
|
+
return !singleData.length || singleData.every((val) => val === 0)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 检查多数据情况
|
|
134
|
+
if (Array.isArray(props.data) && typeof props.data[0] === 'object') {
|
|
135
|
+
const multiData = props.data as BarDataItem[]
|
|
136
|
+
return (
|
|
137
|
+
!multiData.length ||
|
|
138
|
+
multiData.every((item) => !item.data?.length || item.data.every((val) => val === 0))
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return true
|
|
143
|
+
},
|
|
144
|
+
watchSources: [() => props.data, () => props.xAxisData, () => props.colors],
|
|
145
|
+
generateOptions: (): EChartsOption => {
|
|
146
|
+
const options: EChartsOption = {
|
|
147
|
+
grid: getGridWithLegend(props.showLegend && isMultipleData.value, props.legendPosition, {
|
|
148
|
+
top: 15,
|
|
149
|
+
right: 0,
|
|
150
|
+
left: 0
|
|
151
|
+
}),
|
|
152
|
+
tooltip: props.showTooltip ? getTooltipStyle() : undefined,
|
|
153
|
+
xAxis: {
|
|
154
|
+
type: 'category',
|
|
155
|
+
data: props.xAxisData,
|
|
156
|
+
axisTick: getAxisTickStyle(),
|
|
157
|
+
axisLine: getAxisLineStyle(props.showAxisLine),
|
|
158
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel)
|
|
159
|
+
},
|
|
160
|
+
yAxis: {
|
|
161
|
+
type: 'value',
|
|
162
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel),
|
|
163
|
+
axisLine: getAxisLineStyle(props.showAxisLine),
|
|
164
|
+
splitLine: getSplitLineStyle(props.showSplitLine)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 添加图例配置
|
|
169
|
+
if (props.showLegend && isMultipleData.value) {
|
|
170
|
+
options.legend = getLegendStyle(props.legendPosition)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 生成系列数据
|
|
174
|
+
if (isMultipleData.value) {
|
|
175
|
+
const multiData = props.data as BarDataItem[]
|
|
176
|
+
options.series = multiData.map((item, index) => {
|
|
177
|
+
const computedColor = getColor(props.colors[index], index)
|
|
178
|
+
|
|
179
|
+
return createSeriesItem({
|
|
180
|
+
name: item.name,
|
|
181
|
+
data: item.data,
|
|
182
|
+
color: computedColor,
|
|
183
|
+
barWidth: item.barWidth,
|
|
184
|
+
stack: props.stack ? item.stack || 'total' : undefined
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
} else {
|
|
188
|
+
// 单数据情况
|
|
189
|
+
const singleData = props.data as number[]
|
|
190
|
+
const computedColor = getColor()
|
|
191
|
+
|
|
192
|
+
options.series = [
|
|
193
|
+
createSeriesItem({
|
|
194
|
+
data: singleData,
|
|
195
|
+
color: computedColor
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return options
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
</script>
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<!-- 双向堆叠柱状图 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div ref="chartRef" :style="{ height: props.height }" v-loading="props.loading"> </div>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script setup lang="ts">
|
|
7
|
+
import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
|
|
8
|
+
import type { EChartsOption, BarSeriesOption } from '@/plugins/echarts'
|
|
9
|
+
import type { BidirectionalBarChartProps } from '@/types/component/chart'
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'ArtDualBarCompareChart' })
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<BidirectionalBarChartProps>(), {
|
|
14
|
+
// 基础配置
|
|
15
|
+
height: useChartOps().chartHeight,
|
|
16
|
+
loading: false,
|
|
17
|
+
isEmpty: false,
|
|
18
|
+
colors: () => useChartOps().colors,
|
|
19
|
+
|
|
20
|
+
// 数据配置
|
|
21
|
+
positiveData: () => [],
|
|
22
|
+
negativeData: () => [],
|
|
23
|
+
xAxisData: () => [],
|
|
24
|
+
positiveName: '正向数据',
|
|
25
|
+
negativeName: '负向数据',
|
|
26
|
+
barWidth: 16,
|
|
27
|
+
yAxisMin: -100,
|
|
28
|
+
yAxisMax: 100,
|
|
29
|
+
|
|
30
|
+
// 样式配置
|
|
31
|
+
showDataLabel: false,
|
|
32
|
+
positiveBorderRadius: () => [10, 10, 0, 0],
|
|
33
|
+
negativeBorderRadius: () => [0, 0, 10, 10],
|
|
34
|
+
|
|
35
|
+
// 轴线显示配置
|
|
36
|
+
showAxisLabel: true,
|
|
37
|
+
showAxisLine: false,
|
|
38
|
+
showSplitLine: false,
|
|
39
|
+
|
|
40
|
+
// 交互配置
|
|
41
|
+
showTooltip: true,
|
|
42
|
+
showLegend: false,
|
|
43
|
+
legendPosition: 'bottom'
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// 创建系列配置的辅助函数
|
|
47
|
+
const createSeriesConfig = (config: {
|
|
48
|
+
name: string
|
|
49
|
+
data: number[]
|
|
50
|
+
borderRadius: number | number[]
|
|
51
|
+
labelPosition: 'top' | 'bottom'
|
|
52
|
+
colorIndex: number
|
|
53
|
+
formatter?: (params: unknown) => string
|
|
54
|
+
}): BarSeriesOption => {
|
|
55
|
+
const { fontColor } = useChartOps()
|
|
56
|
+
const animationConfig = getAnimationConfig()
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
name: config.name,
|
|
60
|
+
type: 'bar',
|
|
61
|
+
stack: 'total',
|
|
62
|
+
barWidth: props.barWidth,
|
|
63
|
+
barGap: '-100%',
|
|
64
|
+
data: config.data,
|
|
65
|
+
itemStyle: {
|
|
66
|
+
borderRadius: config.borderRadius,
|
|
67
|
+
color: props.colors[config.colorIndex]
|
|
68
|
+
},
|
|
69
|
+
label: {
|
|
70
|
+
show: props.showDataLabel,
|
|
71
|
+
position: config.labelPosition,
|
|
72
|
+
formatter:
|
|
73
|
+
config.formatter ||
|
|
74
|
+
((params: unknown) => String((params as Record<string, unknown>).value)),
|
|
75
|
+
color: fontColor,
|
|
76
|
+
fontSize: 12
|
|
77
|
+
},
|
|
78
|
+
...animationConfig
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 使用图表组件抽象
|
|
83
|
+
const {
|
|
84
|
+
chartRef,
|
|
85
|
+
getAxisLineStyle,
|
|
86
|
+
getAxisLabelStyle,
|
|
87
|
+
getAxisTickStyle,
|
|
88
|
+
getSplitLineStyle,
|
|
89
|
+
getAnimationConfig,
|
|
90
|
+
getTooltipStyle,
|
|
91
|
+
getLegendStyle,
|
|
92
|
+
getGridWithLegend
|
|
93
|
+
} = useChartComponent({
|
|
94
|
+
props,
|
|
95
|
+
checkEmpty: () => {
|
|
96
|
+
return (
|
|
97
|
+
props.isEmpty ||
|
|
98
|
+
!props.positiveData.length ||
|
|
99
|
+
!props.negativeData.length ||
|
|
100
|
+
(props.positiveData.every((val) => val === 0) &&
|
|
101
|
+
props.negativeData.every((val) => val === 0))
|
|
102
|
+
)
|
|
103
|
+
},
|
|
104
|
+
watchSources: [
|
|
105
|
+
() => props.positiveData,
|
|
106
|
+
() => props.negativeData,
|
|
107
|
+
() => props.xAxisData,
|
|
108
|
+
() => props.colors
|
|
109
|
+
],
|
|
110
|
+
generateOptions: (): EChartsOption => {
|
|
111
|
+
// 处理负向数据,确保为负值
|
|
112
|
+
const processedNegativeData = props.negativeData.map((val) => (val > 0 ? -val : val))
|
|
113
|
+
|
|
114
|
+
// 优化的Grid配置
|
|
115
|
+
const gridConfig = {
|
|
116
|
+
top: props.showLegend ? 50 : 20,
|
|
117
|
+
right: 0,
|
|
118
|
+
left: 0,
|
|
119
|
+
bottom: 0, // 增加底部间距
|
|
120
|
+
containLabel: true
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const options: EChartsOption = {
|
|
124
|
+
backgroundColor: 'transparent',
|
|
125
|
+
animation: true,
|
|
126
|
+
animationDuration: 1000,
|
|
127
|
+
animationEasing: 'cubicOut',
|
|
128
|
+
grid: getGridWithLegend(props.showLegend, props.legendPosition, gridConfig),
|
|
129
|
+
|
|
130
|
+
// 优化的提示框配置
|
|
131
|
+
tooltip: props.showTooltip
|
|
132
|
+
? {
|
|
133
|
+
...getTooltipStyle(),
|
|
134
|
+
trigger: 'axis',
|
|
135
|
+
axisPointer: {
|
|
136
|
+
type: 'none' // 去除指示线
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
: undefined,
|
|
140
|
+
|
|
141
|
+
// 图例配置
|
|
142
|
+
legend: props.showLegend
|
|
143
|
+
? {
|
|
144
|
+
...getLegendStyle(props.legendPosition),
|
|
145
|
+
data: [props.negativeName, props.positiveName]
|
|
146
|
+
}
|
|
147
|
+
: undefined,
|
|
148
|
+
|
|
149
|
+
// X轴配置
|
|
150
|
+
xAxis: {
|
|
151
|
+
type: 'category',
|
|
152
|
+
data: props.xAxisData,
|
|
153
|
+
axisTick: getAxisTickStyle(),
|
|
154
|
+
axisLine: getAxisLineStyle(props.showAxisLine),
|
|
155
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel),
|
|
156
|
+
boundaryGap: true
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// Y轴配置
|
|
160
|
+
yAxis: {
|
|
161
|
+
type: 'value',
|
|
162
|
+
min: props.yAxisMin,
|
|
163
|
+
max: props.yAxisMax,
|
|
164
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel),
|
|
165
|
+
axisLine: getAxisLineStyle(props.showAxisLine),
|
|
166
|
+
splitLine: getSplitLineStyle(props.showSplitLine)
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
// 系列配置
|
|
170
|
+
series: [
|
|
171
|
+
// 负向数据系列
|
|
172
|
+
createSeriesConfig({
|
|
173
|
+
name: props.negativeName,
|
|
174
|
+
data: processedNegativeData,
|
|
175
|
+
borderRadius: props.negativeBorderRadius,
|
|
176
|
+
labelPosition: 'bottom',
|
|
177
|
+
colorIndex: 1,
|
|
178
|
+
formatter: (params: unknown) =>
|
|
179
|
+
String(Math.abs((params as Record<string, unknown>).value as number))
|
|
180
|
+
}),
|
|
181
|
+
// 正向数据系列
|
|
182
|
+
createSeriesConfig({
|
|
183
|
+
name: props.positiveName,
|
|
184
|
+
data: props.positiveData,
|
|
185
|
+
borderRadius: props.positiveBorderRadius,
|
|
186
|
+
labelPosition: 'top',
|
|
187
|
+
colorIndex: 0
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return options
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
</script>
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<!-- 水平柱状图 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div
|
|
4
|
+
ref="chartRef"
|
|
5
|
+
class="relative w-full"
|
|
6
|
+
:style="{ height: props.height }"
|
|
7
|
+
v-loading="props.loading"
|
|
8
|
+
></div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { useChartOps, useChartComponent } from '@/hooks/core/useChart'
|
|
13
|
+
import { getCssVar } from '@/utils/ui'
|
|
14
|
+
import { graphic, type EChartsOption } from '@/plugins/echarts'
|
|
15
|
+
import type { BarChartProps, BarDataItem } from '@/types/component/chart'
|
|
16
|
+
|
|
17
|
+
defineOptions({ name: 'ArtHBarChart' })
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<BarChartProps>(), {
|
|
20
|
+
// 基础配置
|
|
21
|
+
height: useChartOps().chartHeight,
|
|
22
|
+
loading: false,
|
|
23
|
+
isEmpty: false,
|
|
24
|
+
colors: () => useChartOps().colors,
|
|
25
|
+
|
|
26
|
+
// 数据配置
|
|
27
|
+
data: () => [0, 0, 0, 0, 0, 0, 0],
|
|
28
|
+
xAxisData: () => [],
|
|
29
|
+
barWidth: '36%',
|
|
30
|
+
stack: false,
|
|
31
|
+
|
|
32
|
+
// 轴线显示配置
|
|
33
|
+
showAxisLabel: true,
|
|
34
|
+
showAxisLine: true,
|
|
35
|
+
showSplitLine: true,
|
|
36
|
+
|
|
37
|
+
// 交互配置
|
|
38
|
+
showTooltip: true,
|
|
39
|
+
showLegend: false,
|
|
40
|
+
legendPosition: 'bottom'
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// 判断是否为多数据
|
|
44
|
+
const isMultipleData = computed(() => {
|
|
45
|
+
return (
|
|
46
|
+
Array.isArray(props.data) &&
|
|
47
|
+
props.data.length > 0 &&
|
|
48
|
+
typeof props.data[0] === 'object' &&
|
|
49
|
+
'name' in props.data[0]
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// 获取颜色配置
|
|
54
|
+
const getColor = (customColor?: string, index?: number) => {
|
|
55
|
+
if (customColor) return customColor
|
|
56
|
+
|
|
57
|
+
if (index !== undefined) {
|
|
58
|
+
return props.colors![index % props.colors!.length]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 默认渐变色
|
|
62
|
+
return new graphic.LinearGradient(0, 0, 1, 0, [
|
|
63
|
+
{
|
|
64
|
+
offset: 0,
|
|
65
|
+
color: getCssVar('--el-color-primary')
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
offset: 1,
|
|
69
|
+
color: getCssVar('--el-color-primary-light-4')
|
|
70
|
+
}
|
|
71
|
+
])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 创建渐变色
|
|
75
|
+
const createGradientColor = (color: string) => {
|
|
76
|
+
return new graphic.LinearGradient(0, 0, 1, 0, [
|
|
77
|
+
{
|
|
78
|
+
offset: 0,
|
|
79
|
+
color: color
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
offset: 1,
|
|
83
|
+
color: color
|
|
84
|
+
}
|
|
85
|
+
])
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 获取基础样式配置
|
|
89
|
+
const getBaseItemStyle = (
|
|
90
|
+
color: string | InstanceType<typeof graphic.LinearGradient> | undefined
|
|
91
|
+
) => ({
|
|
92
|
+
borderRadius: 4,
|
|
93
|
+
color: typeof color === 'string' ? createGradientColor(color) : color
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// 创建系列配置
|
|
97
|
+
const createSeriesItem = (config: {
|
|
98
|
+
name?: string
|
|
99
|
+
data: number[]
|
|
100
|
+
color?: string | InstanceType<typeof graphic.LinearGradient>
|
|
101
|
+
barWidth?: string | number
|
|
102
|
+
stack?: string
|
|
103
|
+
}) => {
|
|
104
|
+
const animationConfig = getAnimationConfig()
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
name: config.name,
|
|
108
|
+
data: config.data,
|
|
109
|
+
type: 'bar' as const,
|
|
110
|
+
stack: config.stack,
|
|
111
|
+
itemStyle: getBaseItemStyle(config.color),
|
|
112
|
+
barWidth: config.barWidth || props.barWidth,
|
|
113
|
+
...animationConfig
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 使用新的图表组件抽象
|
|
118
|
+
const {
|
|
119
|
+
chartRef,
|
|
120
|
+
getAxisLineStyle,
|
|
121
|
+
getAxisLabelStyle,
|
|
122
|
+
getAxisTickStyle,
|
|
123
|
+
getSplitLineStyle,
|
|
124
|
+
getAnimationConfig,
|
|
125
|
+
getTooltipStyle,
|
|
126
|
+
getLegendStyle,
|
|
127
|
+
getGridWithLegend
|
|
128
|
+
} = useChartComponent({
|
|
129
|
+
props,
|
|
130
|
+
checkEmpty: () => {
|
|
131
|
+
// 检查单数据情况
|
|
132
|
+
if (Array.isArray(props.data) && typeof props.data[0] === 'number') {
|
|
133
|
+
const singleData = props.data as number[]
|
|
134
|
+
return !singleData.length || singleData.every((val) => val === 0)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 检查多数据情况
|
|
138
|
+
if (Array.isArray(props.data) && typeof props.data[0] === 'object') {
|
|
139
|
+
const multiData = props.data as BarDataItem[]
|
|
140
|
+
return (
|
|
141
|
+
!multiData.length ||
|
|
142
|
+
multiData.every((item) => !item.data?.length || item.data.every((val) => val === 0))
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return true
|
|
147
|
+
},
|
|
148
|
+
watchSources: [() => props.data, () => props.xAxisData, () => props.colors],
|
|
149
|
+
generateOptions: (): EChartsOption => {
|
|
150
|
+
const options: EChartsOption = {
|
|
151
|
+
grid: getGridWithLegend(props.showLegend && isMultipleData.value, props.legendPosition, {
|
|
152
|
+
top: 15,
|
|
153
|
+
right: 0,
|
|
154
|
+
left: 0
|
|
155
|
+
}),
|
|
156
|
+
tooltip: props.showTooltip ? getTooltipStyle() : undefined,
|
|
157
|
+
xAxis: {
|
|
158
|
+
type: 'value',
|
|
159
|
+
axisTick: getAxisTickStyle(),
|
|
160
|
+
axisLine: getAxisLineStyle(props.showAxisLine),
|
|
161
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel),
|
|
162
|
+
splitLine: getSplitLineStyle(props.showSplitLine)
|
|
163
|
+
},
|
|
164
|
+
yAxis: {
|
|
165
|
+
type: 'category',
|
|
166
|
+
data: props.xAxisData,
|
|
167
|
+
axisTick: getAxisTickStyle(),
|
|
168
|
+
axisLabel: getAxisLabelStyle(props.showAxisLabel),
|
|
169
|
+
axisLine: getAxisLineStyle(props.showAxisLine)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 添加图例配置
|
|
174
|
+
if (props.showLegend && isMultipleData.value) {
|
|
175
|
+
options.legend = getLegendStyle(props.legendPosition)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 生成系列数据
|
|
179
|
+
if (isMultipleData.value) {
|
|
180
|
+
const multiData = props.data as BarDataItem[]
|
|
181
|
+
options.series = multiData.map((item, index) => {
|
|
182
|
+
const computedColor = getColor(props.colors[index], index)
|
|
183
|
+
|
|
184
|
+
return createSeriesItem({
|
|
185
|
+
name: item.name,
|
|
186
|
+
data: item.data,
|
|
187
|
+
color: computedColor,
|
|
188
|
+
barWidth: item.barWidth,
|
|
189
|
+
stack: props.stack ? item.stack || 'total' : undefined
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
} else {
|
|
193
|
+
// 单数据情况
|
|
194
|
+
const singleData = props.data as number[]
|
|
195
|
+
const computedColor = getColor()
|
|
196
|
+
|
|
197
|
+
options.series = [
|
|
198
|
+
createSeriesItem({
|
|
199
|
+
data: singleData,
|
|
200
|
+
color: computedColor
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return options
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
</script>
|