| name | chart-baseline-generation |
| description | Generate Plotly.NET test baselines from real chart rendering so expected data or layout markup is derived from actual output instead of hand-written from memory. |
| compatibility | opencode |
| metadata | {"audience":"maintainers","workflow":"chart-tests"} |
Chart Baseline Generation
Use this skill when a Plotly.NET test needs an expected string derived from actual chart output.
Goal
Generate the real chart output first, inspect it, then copy only the stable part into the test as the expected value.
Do not hand-write large expected strings from memory.
Prerequisites
The script loads Plotly.NET assemblies from tests/ConsoleApps/CSharpConsole/bin/Debug/net10.0/.
Before running the script, verify that directory contains Plotly.NET.dll and Plotly.NET.CSharp.dll.
If it is empty or the DLLs are missing, build them first via the FAKE pipeline:
./build.cmd Build
Any of the Run*TestsFast targets also produce these assemblies as a side effect, so if you are about to run tests anyway you can skip the explicit build step.
If you edit sources in src/Plotly.NET or src/Plotly.NET.CSharp during the investigation, rebuild before re-running the script. dotnet fsi will happily use stale assemblies.
Workflow
- Ensure the dependency DLLs exist.
- Identify the chart fixture or chart-construction expression you want to validate.
- Prefer an existing fixture from
tests/Common/FSharpTestBase/TestCharts/.
- If there is no suitable fixture, put a temporary focused chart expression into
tools/chart-baseline-generation/generate-chart-markup.fsx.
- Use that script for both F# tests and C# tests.
- For C# wrapper baselines, call
Plotly.NET.CSharp.Chart... inside the F# script.
- Keep
UseDefaults = false on the chart to avoid noisy default template output.
- Generate output with the same renderer the test uses.
- Copy the smallest stable section into the test.
- Revert any temporary helper code in the script before finishing.
Canonical Harness
Always use tools/chart-baseline-generation/generate-chart-markup.fsx as the investigation harness.
Edit createChart() in that script, run it for the section you need, inspect the generated output, then revert the temporary chart expression when finished.
Commands
dotnet fsi tools/chart-baseline-generation/generate-chart-markup.fsx
dotnet fsi tools/chart-baseline-generation/generate-chart-markup.fsx -- data
dotnet fsi tools/chart-baseline-generation/generate-chart-markup.fsx -- layout
dotnet fsi tools/chart-baseline-generation/generate-chart-markup.fsx -- html
dotnet fsi tools/chart-baseline-generation/generate-chart-markup.fsx -- data --write-html temp/chart.html
Assertions
Prefer the smallest stable assertion that proves the behavior:
- full
var data = ...; block when validating trace serialization
- full
var layout = ...; block when validating layout generation
- a small but meaningful substring only when the full block is too brittle
Avoid asserting volatile values such as generated DOM ids.
Verification
Use the smallest matching FAKE target while iterating:
./build.cmd RunCSharpTestsFast
./build.cmd RunTestsCoreFast
./build.cmd RunTestsExtensionLibsFast
Run the broader suite before committing when the change scope warrants it.