Skip to content

Commit 21ab915

Browse files
committed
Update bar docs, add single/multi docs
1 parent e3aa25b commit 21ab915

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

Plotly.NET.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F
4646
docs\00_3_chart-config.fsx = docs\00_3_chart-config.fsx
4747
docs\00_4_templates.fsx = docs\00_4_templates.fsx
4848
docs\00_5_defaults.fsx = docs\00_5_defaults.fsx
49+
docs\00_6_multi-arguments.fsx = docs\00_6_multi-arguments.fsx
4950
docs\01_0_axis-styling.fsx = docs\01_0_axis-styling.fsx
5051
docs\01_1_errorbars.fsx = docs\01_1_errorbars.fsx
5152
docs\01_2_multiple-charts.fsx = docs\01_2_multiple-charts.fsx

docs/00_6_multi-arguments.fsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
(**
2+
---
3+
title: single and sulti arguments
4+
category: General
5+
categoryindex: 1
6+
index: 7
7+
---
8+
*)
9+
10+
(*** hide ***)
11+
12+
(*** condition: prepare ***)
13+
#r "nuget: Newtonsoft.JSON, 12.0.3"
14+
#r "nuget: DynamicObj"
15+
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
16+
17+
(*** condition: ipynb ***)
18+
#if IPYNB
19+
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
20+
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
21+
#endif // IPYNB
22+
23+
(**
24+
# Single and sulti arguments
25+
26+
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb) 
27+
[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx) 
28+
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
29+
30+
Plotly.js has many properties that can be either a single value or a collection of values.
31+
32+
In Plotly.NET, this is modelled by 2 arguments in the constructors:
33+
34+
- The "single value version" (e.g. `Opacity`) that sets one value in the target property
35+
- The "multi value version" (e.g. `MultiOpacity`) that sets a collection of values in the target property
36+
37+
**Multi-arguments always have precedent over single arguments, meaning setting both will always set the multi version**
38+
39+
Here is an example for bar charts:
40+
41+
*)
42+
open Plotly.NET
43+
44+
let bar =
45+
Chart.Bar(
46+
[
47+
"first", 1
48+
"second", 2
49+
"third", 3
50+
],
51+
MultiMarkerPatternShape = [ // individual pattern shape for each bar
52+
StyleParam.PatternShape.DiagonalAscending
53+
StyleParam.PatternShape.Dots
54+
StyleParam.PatternShape.HorizontalLines
55+
],
56+
Opacity = 0.75, // opacity for the whole trace
57+
MultiText = [ // individual text associated with each bar
58+
"first bar"
59+
"second bar"
60+
"third bar"
61+
],
62+
TextPosition = StyleParam.TextPosition.Outside // Textposition for every text item associated with this trace
63+
)
64+
65+
(*** condition: ipynb ***)
66+
#if IPYNB
67+
bar
68+
#endif // IPYNB
69+
70+
(***hide***)
71+
bar |> GenericChart.toChartHTML
72+
(***include-it-raw***)

docs/02_1_bar-and-column-charts.fsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ bar |> GenericChart.toChartHTML
7575
(**
7676
7777
## Stacked bar chart or column charts
78+
7879
The following example shows how to create a stacked bar chart by combining bar charts created by combining multiple `Chart.StackedBar` charts:
7980
81+
Basically those charts are just normal bar/column charts with the Layout property `BarMode` set to `Stack`. You can do this yourself by changing the Chart layout.
82+
8083
### Stacked bar Charts
8184
*)
8285

0 commit comments

Comments
 (0)