|
5 | 5 | (** |
6 | 6 | # FSharp.Plotly: Pie and Doughnut Charts |
7 | 7 |
|
8 | | -*Summary:* This example shows how to create pie and doughnut charts in F#. |
| 8 | +*Summary:* This example shows how to create bar and a column charts in F#. |
9 | 9 |
|
10 | | -A pie or a doughnut chart can be created using the `Chart.Pie` and `Chart.Doughnut` functions. |
11 | | -When creating pie or doughnut charts, it is usually desirable to provide both labels and |
12 | | -values. |
| 10 | +A bar chart or bar graph is a chart that presents grouped data with rectangular bars with |
| 11 | +lengths proportional to the values that they represent. The bars can be plotted vertically |
| 12 | +or horizontally. A vertical bar chart is called a column bar chart. |
13 | 13 | *) |
14 | 14 |
|
15 | 15 | open FSharp.Plotly |
16 | 16 |
|
17 | | -let yValues = [20; 14; 23;] |
18 | | -let xValues = ["Product A"; "Product B"; "Product C";] |
19 | | -let labels = ["27% market share"; "24% market share"; "19% market share";] |
20 | | - |
21 | | -(*** define-output:pie1 ***) |
22 | | -Chart.Bar(xValues,yValues,Labels=labels,Opacity=0.3,Marker=Options.Marker(Color="rgba(222,45,38,0.8)")) |
23 | | -|> Chart.withSize(500.,500.) |
24 | | -(*** include-it:pie1 ***) |
25 | | -|> Chart.Show |
| 17 | +let values = [20; 14; 23;] |
| 18 | +let keys = ["Product A"; "Product B"; "Product C";] |
| 19 | +let labels = ["27% market share"; "24% market share"; "19% market share";] |
| 20 | + |
| 21 | +(*** define-output:bar1 ***) |
| 22 | +Chart.Column(keys,values,Labels=labels,Opacity=0.3,Marker=Options.Marker(Color="rgba(222,45,38,0.8)")) |
| 23 | +(*** include-it:bar1 ***) |
| 24 | + |
| 25 | +(*** define-output:bar2 ***) |
| 26 | +Chart.Bar(keys,values) |
| 27 | +(*** include-it:bar2 ***) |
| 28 | + |
| 29 | + |
| 30 | +(** |
| 31 | +
|
| 32 | +## Stacked bar chart or column charts |
| 33 | +The following example shows how to create a stacked bar chart by combining bar charts created by `Chart.StackedBar` |
| 34 | +*) |
| 35 | + |
26 | 36 |
|
| 37 | +(*** define-output:bar3 ***) |
| 38 | +[ |
| 39 | + Chart.StackedBar(keys,values,Name="old"); |
| 40 | + Chart.StackedBar(keys,[8; 21; 13;],Name="new") |
| 41 | +] |
| 42 | +|> Chart.Combine |
| 43 | +(*** include-it:bar3 ***) |
0 commit comments