Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bar的问题 #12

Open
Math819-GZQ opened this issue Oct 6, 2020 · 1 comment
Open

bar的问题 #12

Math819-GZQ opened this issue Oct 6, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Math819-GZQ
Copy link

请问如何使bar中的条形图自动填充上颜色,而不是点击时才有颜色
How to make bar graph in bar automatically fill with color instead of color when clicking

@Koooooo-7
Copy link
Member

目前依赖的绘图库不支持这个,可能你需要在生成的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颜色数组使其和你设置的保持一致。

@Koooooo-7 Koooooo-7 added the enhancement New feature or request label Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants