bar的问题
Math819-GZQ opened this issue · comments
星空 commented
请问如何使bar中的条形图自动填充上颜色,而不是点击时才有颜色
How to make bar graph in bar automatically fill with color instead of color when clicking
Koy Zhuang commented
目前依赖的绘图库不支持这个,可能你需要在生成的html里面自己手动加一点东西。
// 填充的颜色,这是默认的颜色列表。
const color = ['#dd4528', '#28a3dd', '#f3db52', '#ed84b5', '#4ab74e', '#9179c0', '#8e6d5a', '#f19839', '#949494']
document.querySelectorAll(".xkcd-chart-bar").forEach((it, idx) => {
it.setAttribute("fill", color[idx])
it.addEventListener("mouseout", () => {
document.querySelectorAll(".xkcd-chart-bar").forEach((it, idx) => {
it.setAttribute("fill", color[idx])
})
})
})
当你设置了colors: Optional[Iterable] = None label 颜色数组
时,替换上面的color颜色数组使其和你设置的保持一致。