fix apexchats datalabels

This commit is contained in:
jxxghp
2024-05-11 13:46:16 +08:00
parent 2c35d0f897
commit 706d7d6dc1
3 changed files with 31 additions and 2 deletions

View File

@@ -11,6 +11,36 @@ async function setTheme() {
globalTheme.name.value = themeValue === 'auto' ? autoTheme : themeValue
}
// ApexCharts 全局配置
declare global {
interface Window {
Apex: any
}
}
if (window.Apex) {
// 数据标签
window.Apex.dataLabels = {
formatter: function (_: number, { seriesIndex, w }: { seriesIndex: number; w: any }) {
// 如果有小数点,保留两位小数,否则保留整数
const data = w.config.series[seriesIndex]
return data.toFixed(data % 1 === 0 ? 0 : 1)
},
}
// 图例
window.Apex.legend = {
labels: {
useSeriesColors: true,
},
}
// 标题
window.Apex.title = {
style: {
color: 'rgba(var(--v-theme-on-surface), var(--v-high-emphasis-opacity))',
},
}
}
// 页面加载时,加载当前用户数据
onBeforeMount(async () => {
setTheme()

View File

@@ -15,8 +15,6 @@ interface RenderProps {
const elementProps = defineProps({
config: Object as PropType<RenderProps>,
})
console.log(elementProps.config)
</script>
<template>

View File

@@ -64,5 +64,6 @@ app
},
})
.use(PerfectScrollbarPlugin)
.use(VueApexCharts)
.mount('#app')
.$nextTick(() => removeEl('#loading-bg'))