Attributes to alter the view of the bars.
myBarsSerie : Plot.Element (Interaction YourMsg)
myBarsSerie =
bars
[ Bars.maxBarWidthPer 85
, Bars.stackByY
, Bars.label
[ Label.formatFromList [ "A", "B", "C" ] ]
]
[ [ Bars.fill "blue", Bars.opacity 0.5 ]
, [ Bars.fill "red" ]
]
(Bars.toBarData
{ yValues = .revenueByYear
, xValue = Just .quarter
}
[ { quarter = 1, revenueByYear = [ 10000, 30000, 20000 ] }
, { quarter = 2, revenueByYear = [ 20000, 10000, 40000 ] }
, { quarter = 3, revenueByYear = [ 40000, 20000, 10000 ] }
, { quarter = 4, revenueByYear = [ 40000, 50000, 20000 ] }
]
)Set a fixed max width (in pixels) on your bars.
Set a relative max width (in percentage) your bars.
By default your bars are stacked by x. If you want to stack them y, add this attribute.
The info your label format option will be passed.
Alter the view of your label.
myBarSeries : Plot.Element msg
myBarSeries =
bars
[ Bars.label
[ Label.classes [ "label-class" ]
, Label.displace ( 12, 0 )
]
]
barStyles
dataThese are the attributes which can be passed in the list of bar styles in the second argument of your series.
myBarsSerie : Plot.Element msg
myBarsSerie =
bars
[]
[ [ Bars.fill "blue", Bars.opacity 0.5 ]
, [ Bars.fill "red" ]
]
dataSet the fill color.
Set the opacity.
Add your own attributes. For events, see this example
The data format the bars element requires.
The functions necessary to transform your data into the format the plot requires.
If you provide the xValue with Nothing, the bars xValues will just be the index
of the bar in the list.
This function can be used to transform your own data format into something the plot can understand.
Bars.toBarData
{ yValues = .revenueByYear
, xValue = Just .quarter
}
[ { quarter = 1, revenueByYear = [ 10000, 30000, 20000 ] }
, { quarter = 2, revenueByYear = [ 20000, 10000, 40000 ] }
, { quarter = 3, revenueByYear = [ 40000, 20000, 10000 ] }
, { quarter = 4, revenueByYear = [ 40000, 50000, 20000 ] }
]