feat(mermaid): add radar chart support - #151
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThe pull request adds a new ChangesRadar chart support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Diagram
participant Writer
Caller->>Diagram: NewDiagram and configure radar chart
Caller->>Diagram: Build
Diagram->>Writer: Write Mermaid radar output
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment has been minimized.
This comment has been minimized.
| return d.scale("max", value) | ||
| } | ||
|
|
||
| // Min sets the centre of the chart, the value an axis is empty at. |
There was a problem hiding this comment.
[misspell] reported by reviewdog 🐶
"centre" is a misspelling of "center"
c290a6b to
3b1debb
Compare
This comment has been minimized.
This comment has been minimized.
A radar chart is a set of axes and a set of curves, where each curve gives one value per axis in the order the axes were declared. Axis takes as many labels as you give it and Curve takes the values, so a chart reads as the two lists it is. mermaid wants an identifier in front of every label, and nothing in a radar chart refers to one, so the package numbers them and the caller passes only labels. The identifiers keep counting across calls, because a chart with two axes named a1 is a chart with one axis. A label is quoted, with a double quote and a backslash escaped; a trailing backslash would otherwise swallow the closing quote. Everything else, colons and hashes included, is text once inside the quotes, which was verified by rendering. Values are written in plain decimal notation, since mermaid parses the token as a number and Go's exponent form is not one to it, and NaN and the infinities are refused. "beta" is kept out of the API. mermaid still spells the keyword that way, and the package should not have to change its name when mermaid settles it.
The render harness landed after this branch started. radar quotes every label, so its entry holds every character in the probe set; a line break is the only thing left out, since one label is one line.
3b1debb to
471d828
Compare
Code Metrics Report
Details | | main (4f3d26b) | #151 (086784d) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 96.1% | 96.2% | +0.0% |
| Files | 61 | 63 | +2 |
| Lines | 2805 | 2893 | +88 |
+ | Covered | 2697 | 2784 | +87 |
| Test Execution Time | 9s | 9s | 0s |Code coverage of files in pull request scope (0.0% → 98.8%)
Reported by octocov |
Closes #129
What
mermaid/radarbuilds mermaid radar charts. A radar chart is a set of axes and a set of curves, where each curve gives one value per axis in the order the axes were declared, so the builder is those two lists:Identifiers are generated
mermaid requires an identifier in front of every label: a bare
axis "Math"is a parse error, which I confirmed by rendering. Nothing in a radar chart refers to those identifiers, so the package numbers them and the caller passes only labels. They keep counting across calls, because a chart with two axes nameda1is a chart with one axis, and a test pins that.Escaping
A label is quoted, with a double quote and a backslash escaped. The backslash matters on its own: a label ending in one would otherwise swallow the closing quote. Everything else — colons, hashes, semicolons, parentheses — is text once inside the quotes, which I verified by rendering a label holding all of them.
Values use
strconv.FormatFloat(v, 'f', -1, 64), because mermaid parses the token as a number and Go's exponent form above 1e21 is not one to it. NaN and both infinities are refused; negative values are not, since a radar axis can start below zero andMinexists for exactly that."beta" stays out of the API
mermaid still spells the keyword
radar-beta. The package isradarand the keyword is an implementation detail.The pinned renderer already supports it
The issue asked me to check whether the mermaid-cli version in CI renders
radar-betaand to bump it if not. It does, so no workflow change was needed.Tests
go test ./mermaid/radar/reports 98.9% of statements.Maxand inMin.internal/buildertest, a golden chart, and an output-verified godoc example.Rendering
doc/radar/main.gogenerates a committed sample, drawn by the render job. Verified locally, both the sample and the edge case labels above.Scope
Additive only. Nothing outside
mermaid/radar/,doc/radar/, andREADME.mdchanged.Summary by CodeRabbit
New Features
Documentation
Tests