feat: 新的图表主题色生成方法

This commit is contained in:
pipipi-pikachu 2021-02-24 12:49:53 +08:00
parent d3e0a6533e
commit b8484870c5
2 changed files with 5 additions and 11 deletions

View File

@ -101,21 +101,14 @@ export default defineComponent({
onMounted(renderChart)
//
//
const updateTheme = () => {
if (!chartRef.value) return
const hsla = tinycolor(props.themeColor).toHsl()
const colors = tinycolor(props.themeColor).analogous(10)
for (let i = 0; i < 10; i++) {
let h = hsla.h + i * 36
if (h > 360) h = h - 360
const _hsla = {
...hsla,
h,
}
chartRef.value.style.setProperty(`--theme-color-${i + 1}`, tinycolor(_hsla).toRgbString())
const color = colors[i].toRgbString()
chartRef.value.style.setProperty(`--theme-color-${i + 1}`, color)
}
}

View File

@ -89,5 +89,6 @@ export default defineComponent({
.element-content {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>