Skip to content

Looking for help for building bar chart #131

Answered by gampleman
wadouk asked this question in Q&A
Discussion options

You must be logged in to vote

You're using a BandScale which is designed to do the opposite: to keep the overall space constant and divide the space equally between bands (with optional padding and spacing).

If you don't want that behavior, than the alternative is to not use a scale at all, just pick a width and use multiplication, i.e. something like this:

barHeight = 40

view bars = 
    svg [ viewBox 0 0 w (barHeight * List.length bars + somePadding) ] 
        [ ...
        , List.indexedMap (\index bar -> rect [ y (index * barHeight), ...] ) bars
        ]

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by gampleman
Comment options

You must be logged in to vote
3 replies
@gampleman
Comment options

@wadouk
Comment options

@wadouk
Comment options

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