#r "nuget: Plotly.NET, 4.0.0"
#r "nuget: Plotly.NET.Interactive, 4.0.0"
Config
is an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top
Options for chart export can be set in the config at ToImageButtonOptions
:
Three file formats for chart exports are supported (SVG, PNG, JPEG) and can be set as Format
.
A predefined name for the downloaded chart can be set at Filename
.
The dimensions of the downloaded chart are set at Width
and Height
.
The Scale
defines the size of the exported svg.
The settings do not apply for the html document containing the chart but for charts that are exported by clicking the camera icon in the menu bar.
open Plotly.NET
open Plotly.NET.ConfigObjects
let svgConfig =
Config.init (
ToImageButtonOptions =
ToImageButtonOptions.init (
Format = StyleParam.ImageFormat.JPEG,
Filename = "mySvgChart",
Width = 900.,
Height = 600.,
Scale = 10.
)
)
let svgButtonChart = Chart.Point(xy = [ (1., 2.) ]) |> Chart.withConfig svgConfig
svgButtonChart
To create a static plot that has no hoverable elements, use StaticPlot=true
on the Config:
let staticConfig = Config.init (StaticPlot = true)
let staticPlot = Chart.Point(xy = [ (1., 2.) ]) |> Chart.withConfig staticConfig
staticPlot
You can define fields that can be edited on the chart by setting Editable = true
on the config, optionally explicitly setting the editable parts via EditableAnnotations
let editableConfig =
Config.init (Editable = true, Edits = Edits.init (LegendPosition = true, AxisTitleText = true, LegendText = true))
let editablePlot = Chart.Point(xy = [ (1., 2.) ]) |> Chart.withConfig editableConfig
editablePlot
To create a chart that is reponsive to its container size, use Responsive=true
on the Config:
(try resizing the window)
let responsiveConfig = Config.init (Responsive = true)
let responsivePlot =
Chart.Point(xy = [ (1., 2.) ]) |> Chart.withConfig responsiveConfig
responsivePlot