In [ ]:
#r "nuget: Plotly.NET, 2.0.0"
#r "nuget: Plotly.NET.Interactive, 2.0.0"

Chart config


Config is an object that configures high level properties of the chart like making all chart elements editable or the tool bar on top

Image button options

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.

In [3]:
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.withConfig svgConfig
In [ ]:
Out[ ]:

Static plots

To create a static plot that has no hoverable elements, use StaticPlot=true on the Config:

In [5]:
let staticConfig = Config.init(StaticPlot=true)

let staticPlot =
    |> Chart.withConfig staticConfig
In [ ]:
Out[ ]:

Editable charts

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

In [7]:
let editableConfig = 
        Editable = true,
        Edits = Edits.init(
            LegendPosition  = true,
            AxisTitleText   = true,
            LegendText      = true

let editablePlot =
    |> Chart.withConfig editableConfig
In [ ]:
Out[ ]:

Responsive charts

To create a chart that is reponsive to its container size, use Responsive=true on the Config:

(try resizing the window)

In [9]:
let responsiveConfig = Config.init(Responsive=true)

let responsivePlot =
    |> Chart.withConfig responsiveConfig
In [ ]:
Out[ ]: