GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Plotly.NET/src/Plotly.NET.ImageExport at dev · plotly/Plotly.NET

Expand file tree

/

Plotly.NET.ImageExport

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

Plotly.NET.ImageExport

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
AsyncHelper.fs
AsyncHelper.fs
 
 
ChartExtensions.fs
ChartExtensions.fs
 
 
ExportEngine.fs
ExportEngine.fs
 
 
GenericChartExtensions.fs
GenericChartExtensions.fs
 
 
IGenericChartRenderer.fs
IGenericChartRenderer.fs
 
 
Playground.fsx
Playground.fsx
 
 
Plotly.NET.ImageExport.fsproj
Plotly.NET.ImageExport.fsproj
 
 
PuppeteerSharpRenderer.fs
PuppeteerSharpRenderer.fs
 
 
README.md
README.md
 
 
RELEASE_NOTES.md
RELEASE_NOTES.md
 
 

README.md

Outline

Plotly.NET.ImageExport

Render Plotly.NET charts as PNG, JPEG, or SVG images using a headless browser powered by PuppeteerSharp.

Install

dotnet add package Plotly.NET.ImageExport --version 7.0.0

Version 7 targets .NET Standard 2.0 and depends on Plotly.NET 6.x, which NuGet installs automatically. Use a compatible .NET application runtime and an operating system that can run the browser described below.

Export a chart

This F# script writes chart.png in the current directory:

#r "nuget: Plotly.NET.ImageExport, 7.0.0"

open Plotly.NET
open Plotly.NET.ImageExport

let chart =
    Chart.Line([ (1., 2.); (2., 4.); (3., 3.) ])
    |> Chart.withDisplayOptions(
        DisplayOptions.init(PlotlyJSReference = PlotlyJSReference.Full)
    )

chart |> Chart.savePNG("chart", Width = 800, Height = 450)

Pass a path without an extension; the save functions append .png, .jpg, or .svg. The output directory must already exist and be writable. The example embeds plotly.js so the browser does not need to fetch it from a CDN.

Output formats

Format Save to a file Return an image string
PNG Chart.savePNG Chart.toBase64PNGString — PNG data URI
JPEG Chart.saveJPG Chart.toBase64JPGString — JPEG data URI
SVG Chart.saveSVG Chart.toSVGString — SVG markup

These functions accept Width, Height, and Scale options, defaulting to 600, 600, and 1.0. Corresponding Async functions, such as Chart.savePNGAsync, return tasks that you can await.

Browser requirements

The default renderer uses PuppeteerSharp 24.40.0 to download a compatible Chrome browser when needed and launch it for each export. Browser setup requires network access and a writable browser download/cache location. The host must permit browser processes and provide the required operating-system libraries; see the PuppeteerSharp prerequisites.

To use a preinstalled compatible Chrome/Chromium executable and skip the automatic download, set PuppeteerSharpRendererOptions.localBrowserExecutablePath to Some "/absolute/path/to/chrome" before exporting. Launch and navigation settings are available through PuppeteerSharpRendererOptions.launchOptions and PuppeteerSharpRendererOptions.navigationOptions.

Charts that reference external images, fonts, map resources, or a plotly.js CDN may still need network access during rendering.

See the image export guide for more examples and the release notes for version changes.

Licensed under the MIT License.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.