Skip to content

How to specify the color of lines and bars in XYChart? #5207

Answered by Piratepie
jeanplevesque asked this question in Q&A
Discussion options

You must be logged in to vote

Using the Chart Theme Variables you can set a color palette with plotColorPalette.
These colors will be applied to the lines and bars defined in the xyChart. So the first color in your palette will correspond with the first bar/line etc.

Here's a short example

---
config:
    themeVariables:
        xyChart:
            plotColorPalette: "#000000, #0000FF, #00FF00, #FF0000"
---
         %% plotColorPalette: "black, blue, green, red"
xychart-beta
    title "Different colors in xyChart"
    x-axis "numbersX" ["Group A", "Group B", "Group C", "Group D"]
    y-axis "numbersY" 0 --> 40
    %% black
    bar [20,30,25,30]
    %% blue
    bar [10,20,20,20]
    %% green
    bar [5,10,5,5]
    %% r…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jeanplevesque
Comment options

Answer selected by jeanplevesque
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants