This section is WIP.
Plotly.NET is a .NET wrapper for creation of plotly charts written in F#. This means that, under the hood, all functionality creates JSON objects that can be rendered by plotly.
The central type that gets created by all Chart constructors is
GenericChart, which itself represents either a single chart or a multi chart (as a Discriminate Union type). It looks like this:
type GenericChart = | Chart of Trace * Layout * Config * DisplayOptions | MultiChart of Trace list * Layout * Config * DisplayOptions
As you can see, a
GenericChart consists of four top level objects -
Trace (multiple of those in the case of a MultiChart) ,
Traceis in principle the representation of a dataset on a chart, including for example the data itself, color and shape of the visualization, etc.
Layoutis everything of the chart that is not dataset specifivc - e.g. the shape and style of axes, the chart title, etc.
Configis an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top
DisplayOptionsis an object that contains meta information about how the html document that contains the chart.
Plotly.NET has multiple abstraction layers to work with
GenericCharts. The prime directive for all functions provided by this library is the construction of valid plotly JSON objects.
For this purpose,
Config (and many other internal objects) are inheriting from
an extension of
DynamicObject which makes it possible to set arbitraryly named and typed properties of these objects via the
So if you want to set any kind of property on one of these objects you can do it in a very declarative way like this:
let myTrace = Trace("scatter") // create a scatter trace myTrace?x <- [0;1;2] // set the x property (the x dimension of the data) myTrace?y <- [0;1;2] // set the y property (the y dimension of the data) GenericChart.ofTraceObject myTrace // create a generic chart (layout and config are empty objects) |> Chart.Show
lets have a look at the trace object that will be created. The relevant section of the html generated with Chart.Show is the following: