|
| 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 | +[](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)  |
| 27 | +[]({{root}}{{fsdocs-source-basename}}.fsx)  |
| 28 | +[]({{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***) |
0 commit comments