-
Notifications
You must be signed in to change notification settings - Fork 1
Bars
Bars plot is one of the plot types that can be added to the chart.
To create a bars plot you need two series: BarCenters: float seq
and BarHeights: float seq
that respectively define the position and height of each bar.
let bars = createBars BarCenters BarHeights
Actually the bars plot is a record of type FSharpIDD.Plots.Bars.Plot
You can also create it by explicitly filling up all record fields:
{
/// Specifies how to annotate Bars plot in a legend
Name: string
/// Series of bar centers horizontal coordinates. Length of the series equals the number of bars
BarCenters: DataSeries
/// Series of bar heights. Length of the series equals the number of bars
BarHeights: DataSeries
/// The width in plot coordinates of one bar in a bars plot
BarWidth: float
/// The colour with which a bar will be filled
FillColour: Colour.Colour
/// The colour of a bar border
BorderColour: Colour.Colour
/// Shadow mode: with or without shadow, shadow colour
Shadow: Shadow
}
The bars plot has five appearance options that can be configured:
- Name (as it's seen in a legend)
- Bar width (in plot coordinates)
- Fill colour of bars
- Border colour of bars
- Shadow presence and its colour
You can use the following functions of the module FSharpIDD.Plots.Bars
to define the options respectively:
setName: name:string -> bars:Plot -> Plot
setBarWidth: barwidth:Float -> bars:Plot -> Plot
setFillColour: fillColour:Colour.Colour -> bars:Plot -> Plot
setBorderColour: borderColour:Colour.Colour -> bars:Plot -> Plot
setShadow: shadow:Bars.Shadow -> bars:Plot -> Plot
let bars1 =
createBars BarCenters BarHeights
|> setName "Bars 1"
|> setBarWidth 0.5
|> setFillColour Colour.LightGrey
|> setBorderColour Colour.Orange
|> setShadow (Shadow.WithShadow Colour.Turquoise)
There is also an option to set several appearance characteristics with a single setOptions: options:Options -> bars:Plot -> Plot
call.
The convenience of the method is that you can define several (but not necessarily all) options during Options
value creation.
let barsOptions = Options(Name = "BarsPlot", BarWidth = 0.3)
let barsPlot =
createBars BarCenters BarHeights
|> setOptions barsOptions