From 6775634701ec89c1e46d673be9b364ab8065c689 Mon Sep 17 00:00:00 2001 From: Simen Kirkvik Date: Thu, 23 Jul 2026 14:37:19 +0200 Subject: [PATCH] Initial commit --- .envrc | 1 + Plotly.Net.Test.fsproj | 17 +++++++++++++++++ Program.fs | 34 ++++++++++++++++++++++++++++++++++ shell.nix | 13 +++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 .envrc create mode 100644 Plotly.Net.Test.fsproj create mode 100644 Program.fs create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/Plotly.Net.Test.fsproj b/Plotly.Net.Test.fsproj new file mode 100644 index 0000000..f103158 --- /dev/null +++ b/Plotly.Net.Test.fsproj @@ -0,0 +1,17 @@ + + + + Exe + net10.0 + + + + + + + + + + + + diff --git a/Program.fs b/Program.fs new file mode 100644 index 0000000..ed8a1e6 --- /dev/null +++ b/Program.fs @@ -0,0 +1,34 @@ +open Plotly.NET +open Plotly.NET.ImageExport + +[] +let main argv = + let chromePathEnvOpt = + System.Environment.GetEnvironmentVariable("GOOGLE_CHROME") + |> Option.ofObj + + let chromePathOpt: string option = + if argv.Length >= 1 then + Some (argv[0]) + else + chromePathEnvOpt + + match chromePathOpt with + | Some chromePath -> + PuppeteerSharpRendererOptions.localBrowserExecutablePath <- Some chromePath + + let chart = + Chart.Point ( + x = [ 0 .. 10 ], + y = [ 0 .. 10 ] + ) + |> Chart.withTitle "Hello world!" + + try + do chart |> Chart.savePNG("test") + with e -> + eprintfn "Error saving PNG: %s" e.Message + | None -> + eprintfn "Usage: or define GOOLE_CHROME with path to binary" + + 0 diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..3df0e29 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +with import {}; +let + sdk = dotnetCorePackages.sdk_10_0; +in +mkShell { + packages = [ + sdk + ]; + + DOTNET_ROOT = "${sdk}/share/dotnet"; + + GOOGLE_CHROME = lib.getExe google-chrome; +}