@x-cmd/draw 0.2.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -166
- package/dist/lib.d.ts +27 -1
- package/dist/lib.js +39 -1
- package/dist/node/cli.js +109 -11
- package/dist/render/anno.d.ts +50 -0
- package/dist/render/anno.js +589 -0
- package/dist/render/arch.d.ts +106 -0
- package/dist/render/arch.js +1011 -0
- package/dist/render/archmap.d.ts +157 -0
- package/dist/render/archmap.js +683 -0
- package/dist/render/area.js +20 -14
- package/dist/render/bar-grouped.js +8 -5
- package/dist/render/bar-stacked.js +11 -7
- package/dist/render/bar.js +8 -3
- package/dist/render/butterfly.d.ts +3 -0
- package/dist/render/butterfly.js +355 -0
- package/dist/render/calendar.d.ts +6 -0
- package/dist/render/calendar.js +448 -0
- package/dist/render/combo.js +16 -8
- package/dist/render/compass.d.ts +6 -0
- package/dist/render/compass.js +77 -0
- package/dist/render/dispatch.js +26 -1
- package/dist/render/echarts-ssr.d.ts +51 -0
- package/dist/render/echarts-ssr.js +511 -0
- package/dist/render/gantt.d.ts +46 -0
- package/dist/render/gantt.js +415 -0
- package/dist/render/gantt2.d.ts +24 -0
- package/dist/render/gantt2.js +198 -0
- package/dist/render/hbar.js +8 -4
- package/dist/render/icons.d.ts +3 -0
- package/dist/render/icons.js +78 -0
- package/dist/render/kinds.d.ts +11 -0
- package/dist/render/kinds.js +176 -0
- package/dist/render/ladder.d.ts +21 -0
- package/dist/render/ladder.js +230 -0
- package/dist/render/layout.d.ts +46 -0
- package/dist/render/layout.js +57 -0
- package/dist/render/line-multi.js +7 -5
- package/dist/render/line.js +9 -5
- package/dist/render/maps.d.ts +46 -0
- package/dist/render/maps.js +237 -0
- package/dist/render/measure.d.ts +0 -1
- package/dist/render/measure.js +0 -1
- package/dist/render/mermaid.d.ts +30 -0
- package/dist/render/mermaid.js +277 -0
- package/dist/render/mindmap.d.ts +10 -0
- package/dist/render/mindmap.js +388 -0
- package/dist/render/orgicon.d.ts +12 -0
- package/dist/render/orgicon.js +31 -0
- package/dist/render/pie.js +1 -1
- package/dist/render/png.d.ts +21 -0
- package/dist/render/png.js +109 -0
- package/dist/render/quadrant.d.ts +6 -0
- package/dist/render/quadrant.js +201 -0
- package/dist/render/query.d.ts +2 -0
- package/dist/render/query.js +108 -1
- package/dist/render/route.d.ts +86 -0
- package/dist/render/route.js +1077 -0
- package/dist/render/scatter.js +87 -12
- package/dist/render/seq.d.ts +41 -0
- package/dist/render/seq.js +248 -0
- package/dist/render/svg.d.ts +34 -2
- package/dist/render/svg.js +159 -20
- package/dist/render/table.d.ts +30 -0
- package/dist/render/table.js +134 -0
- package/dist/render/tokei.d.ts +18 -0
- package/dist/render/tokei.js +230 -0
- package/dist/render/uc.d.ts +58 -0
- package/dist/render/uc.js +319 -0
- package/dist/render/units.d.ts +32 -0
- package/dist/render/units.js +84 -0
- package/dist/render/vendor/au.js +10 -0
- package/dist/render/vendor/br.js +10 -0
- package/dist/render/vendor/china.js +11 -0
- package/dist/render/vendor/de.js +10 -0
- package/dist/render/vendor/eu.js +10 -0
- package/dist/render/vendor/japan.js +10 -0
- package/dist/render/vendor/kr.js +10 -0
- package/dist/render/vendor/mermaid-flow-parser.js +1164 -0
- package/dist/render/vendor/mermaid-gantt-parser.js +810 -0
- package/dist/render/vendor/us-states.js +11 -0
- package/dist/render/vendor/world-geo.d.ts +22 -0
- package/dist/render/vendor/world-geo.js +9 -0
- package/dist/render/vendor/world.d.ts +13 -0
- package/dist/render/vendor/world.js +12 -0
- package/dist/specs/base.d.ts +16 -0
- package/dist/specs/base.js +34 -1
- package/dist/specs/butterfly.d.ts +46 -0
- package/dist/specs/butterfly.js +241 -0
- package/dist/specs/calendar.d.ts +90 -0
- package/dist/specs/calendar.js +296 -0
- package/dist/specs/compass.d.ts +27 -0
- package/dist/specs/compass.js +111 -0
- package/dist/specs/index.d.ts +5 -0
- package/dist/specs/index.js +5 -0
- package/dist/specs/ladder.d.ts +43 -0
- package/dist/specs/ladder.js +261 -0
- package/dist/specs/quadrant.d.ts +41 -0
- package/dist/specs/quadrant.js +200 -0
- package/dist/specs/scatter.d.ts +14 -8
- package/dist/specs/scatter.js +54 -5
- package/dist/specs/table.d.ts +24 -0
- package/dist/specs/table.js +154 -0
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/styles/butterfly.d.ts +2 -0
- package/dist/styles/butterfly.js +74 -0
- package/dist/styles/calendar.d.ts +2 -0
- package/dist/styles/calendar.js +51 -0
- package/dist/styles/compass.d.ts +2 -0
- package/dist/styles/compass.js +19 -0
- package/dist/styles/fonts-banner.d.ts +5 -0
- package/dist/styles/fonts-banner.js +9 -0
- package/dist/styles/fonts-cjk.d.ts +2 -0
- package/dist/styles/fonts-cjk.js +6 -0
- package/dist/styles/fonts-ttf.d.ts +2 -0
- package/dist/styles/fonts-ttf.js +6 -0
- package/dist/styles/index.js +13 -0
- package/dist/styles/ladder.d.ts +3 -0
- package/dist/styles/ladder.js +66 -0
- package/dist/styles/quadrant.d.ts +2 -0
- package/dist/styles/quadrant.js +19 -0
- package/dist/styles/table.d.ts +2 -0
- package/dist/styles/table.js +12 -0
- package/dist/styles/types.d.ts +1 -0
- package/dist/styles/types.js +1 -0
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +3 -4
- package/dist/types/dagre.d.ts +39 -0
- package/dist/types/dagre.js +3 -0
- package/package.json +28 -3
package/README.md
CHANGED
|
@@ -5,244 +5,158 @@
|
|
|
5
5
|
[](https://jsr.io/@x-cmd/draw/score)
|
|
6
6
|
[](https://securityscorecards.dev/viewer/?uri=github.com/x-cmd/draw)
|
|
7
7
|
|
|
8
|
-
SVG chart generation for the AI era. One endpoint — `/draw?type=...` — with the data in the URL, machine-readable `<metadata>` embedded in every output, and SVG rendered directly by TypeScript. The style system mirrors a designer spec (13 SVGs), with multiple style variants per chart type.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
All the data lives in the URL — open it in a browser, drop it into an `<img>`, paste it into your repo README: the SVG renders right away.
|
|
9
|
+
X-CMD Draw is an open-source SVG chart generator: put your data and styling in a URL to create bar charts, line charts, Sankey diagrams, system architecture diagrams, mind maps, and more.
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
Embed charts directly in READMEs, issues, PRs, blog posts, and web pages without exporting or uploading image files. Links and SVGs retain machine-readable data and parameters: readers see the chart, while AI agents can read, modify, and regenerate it without image recognition.
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
https://x-cmd.com/draw?type=sankey&t=pipeline&labels=feat,fix,docs,chore,merged,closed,rejected,0-1y,1-2y,2y+&links=feat>merged:38;feat>closed:12;feat>rejected:8;fix>merged:33;fix>closed:6;fix>rejected:2;docs>merged:16;docs>closed:4;chore>merged:5;chore>closed:6;chore>rejected:6;merged>0-1y:52;merged>1-2y:28;merged>2y+:12;closed>0-1y:14;closed>1-2y:9;closed>2y+:5;rejected>0-1y:9;rejected>1-2y:5;rejected>2y+:2&title=Pull%20requests%20lifecycle&unit=prs
|
|
18
|
-
```
|
|
13
|
+
## Sneak peek
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
From performance analysis to architecture design, and from maps to schedules, the complete chart definition lives in the link. Click an image to inspect the data, adjust the styling, and regenerate it. [Explore more chart examples ↗](https://x-cmd.com/draw)
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
| | |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| **Downloads and growth**<br>[](https://www.x-cmd.com/draw/explore?type=combo&title=Downloads+and+growth&labels=Jan%2CFeb%2CMar%2CApr%2CMay%2CJun%2CJul%2CAug%2CSep%2COct%2CNov%2CDec&series=downloads%3A900%2C1200%2C1050%2C1600%2C1400%2C1800%2C2100%2C1950%2C2200%2C2500%2C2300%2C2700&line=growth%3A5%2C8%2C6%2C12%2C10%2C15%2C18%2C16%2C20%2C23%2C21%2C26) | **Compression algorithm comparison**<br>[%22%2C%22min%22%3A0%2C%22max%22%3A800%2C%22nameLocation%22%3A%22middle%22%2C%22nameGap%22%3A32%2C%22nameTextStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22axisLabel%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22splitLine%22%3A%7B%22lineStyle%22%3A%7B%22color%22%3A%22%231e293b%22%7D%7D%7D%2C%22yAxis%22%3A%7B%22name%22%3A%22Ratio%20(smaller%20output%20%E2%86%91)%22%2C%22min%22%3A1.9%2C%22max%22%3A3%2C%22nameLocation%22%3A%22middle%22%2C%22nameGap%22%3A45%2C%22nameTextStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22axisLabel%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22splitLine%22%3A%7B%22lineStyle%22%3A%7B%22color%22%3A%22%231e293b%22%7D%7D%7D%2C%22series%22%3A%5B%7B%22type%22%3A%22scatter%22%2C%22data%22%3A%5B%7B%22name%22%3A%22zstd%20-1%22%2C%22value%22%3A%5B510%2C2.896%5D%2C%22symbolSize%22%3A28%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zstd%20--fast%3D1%22%2C%22value%22%3A%5B545%2C2.439%5D%2C%22symbolSize%22%3A30%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zstd%20--fast%3D4%22%2C%22value%22%3A%5B665%2C2.146%5D%2C%22symbolSize%22%3A31%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22brotli%20-1%22%2C%22value%22%3A%5B290%2C2.883%5D%2C%22symbolSize%22%3A21%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23a78bfa%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zlib%20-1%22%2C%22value%22%3A%5B105%2C2.743%5D%2C%22symbolSize%22%3A20%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23f87171%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22lz4%22%2C%22value%22%3A%5B675%2C2.101%5D%2C%22symbolSize%22%3A38%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23fbbf24%22%7D%2C%22label%22%3A%7B%22position%22%3A%22right%22%7D%7D%2C%7B%22name%22%3A%22lzo1x%22%2C%22value%22%3A%5B650%2C2.106%5D%2C%22symbolSize%22%3A24%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22left%22%7D%7D%2C%7B%22name%22%3A%22snappy%22%2C%22value%22%3A%5B520%2C2.089%5D%2C%22symbolSize%22%3A28%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22bottom%22%7D%7D%2C%7B%22name%22%3A%22quicklz%22%2C%22value%22%3A%5B520%2C2.238%5D%2C%22symbolSize%22%3A23%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22lzf%22%2C%22value%22%3A%5B410%2C2.077%5D%2C%22symbolSize%22%3A24%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22bottom%22%7D%7D%5D%2C%22itemStyle%22%3A%7B%22opacity%22%3A0.85%2C%22borderColor%22%3A%22%23fff%22%2C%22borderWidth%22%3A1%7D%2C%22label%22%3A%7B%22show%22%3Atrue%2C%22formatter%22%3A%22%7Bb%7D%22%2C%22color%22%3A%22%23e2e8f0%22%2C%22fontSize%22%3A12%7D%7D%5D%7D&w=960&h=540)](https://www.x-cmd.com/draw/explore/echarts?d=%7B%22backgroundColor%22%3A%22%230f172a%22%2C%22title%22%3A%7B%22text%22%3A%22Compression%3A%20speed%20vs%20ratio%22%2C%22subtext%22%3A%22Silesia%20%C2%B7%20i7-9700K%20%C2%B7%20lzbench%20%C2%B7%20bubble%20size%20%3D%20decompression%20speed%22%2C%22left%22%3A%22center%22%2C%22textStyle%22%3A%7B%22color%22%3A%22%23f8fafc%22%7D%2C%22subtextStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%7D%2C%22grid%22%3A%7B%22left%22%3A70%2C%22right%22%3A40%2C%22top%22%3A80%2C%22bottom%22%3A60%7D%2C%22xAxis%22%3A%7B%22name%22%3A%22Compression%20speed%20MB%2Fs%20(faster%20%E2%86%92)%22%2C%22min%22%3A0%2C%22max%22%3A800%2C%22nameLocation%22%3A%22middle%22%2C%22nameGap%22%3A32%2C%22nameTextStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22axisLabel%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22splitLine%22%3A%7B%22lineStyle%22%3A%7B%22color%22%3A%22%231e293b%22%7D%7D%7D%2C%22yAxis%22%3A%7B%22name%22%3A%22Ratio%20(smaller%20output%20%E2%86%91)%22%2C%22min%22%3A1.9%2C%22max%22%3A3%2C%22nameLocation%22%3A%22middle%22%2C%22nameGap%22%3A45%2C%22nameTextStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22axisLabel%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22splitLine%22%3A%7B%22lineStyle%22%3A%7B%22color%22%3A%22%231e293b%22%7D%7D%7D%2C%22series%22%3A%5B%7B%22type%22%3A%22scatter%22%2C%22data%22%3A%5B%7B%22name%22%3A%22zstd%20-1%22%2C%22value%22%3A%5B510%2C2.896%5D%2C%22symbolSize%22%3A28%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zstd%20--fast%3D1%22%2C%22value%22%3A%5B545%2C2.439%5D%2C%22symbolSize%22%3A30%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zstd%20--fast%3D4%22%2C%22value%22%3A%5B665%2C2.146%5D%2C%22symbolSize%22%3A31%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2322d3ee%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22brotli%20-1%22%2C%22value%22%3A%5B290%2C2.883%5D%2C%22symbolSize%22%3A21%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23a78bfa%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22zlib%20-1%22%2C%22value%22%3A%5B105%2C2.743%5D%2C%22symbolSize%22%3A20%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23f87171%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22lz4%22%2C%22value%22%3A%5B675%2C2.101%5D%2C%22symbolSize%22%3A38%2C%22itemStyle%22%3A%7B%22color%22%3A%22%23fbbf24%22%7D%2C%22label%22%3A%7B%22position%22%3A%22right%22%7D%7D%2C%7B%22name%22%3A%22lzo1x%22%2C%22value%22%3A%5B650%2C2.106%5D%2C%22symbolSize%22%3A24%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22left%22%7D%7D%2C%7B%22name%22%3A%22snappy%22%2C%22value%22%3A%5B520%2C2.089%5D%2C%22symbolSize%22%3A28%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22bottom%22%7D%7D%2C%7B%22name%22%3A%22quicklz%22%2C%22value%22%3A%5B520%2C2.238%5D%2C%22symbolSize%22%3A23%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22top%22%7D%7D%2C%7B%22name%22%3A%22lzf%22%2C%22value%22%3A%5B410%2C2.077%5D%2C%22symbolSize%22%3A24%2C%22itemStyle%22%3A%7B%22color%22%3A%22%2394a3b8%22%7D%2C%22label%22%3A%7B%22position%22%3A%22bottom%22%7D%7D%5D%2C%22itemStyle%22%3A%7B%22opacity%22%3A0.85%2C%22borderColor%22%3A%22%23fff%22%2C%22borderWidth%22%3A1%7D%2C%22label%22%3A%7B%22show%22%3Atrue%2C%22formatter%22%3A%22%7Bb%7D%22%2C%22color%22%3A%22%23e2e8f0%22%2C%22fontSize%22%3A12%7D%7D%5D%7D) |
|
|
20
|
+
| [](https://www.x-cmd.com/draw/explore/arch2?title=OpenCode+Project+Architecture&t=shadcn&n=tui%3Bfe%3BTerminal+UI%3BCommand-line+interface%3Br0c0&n=web%3Bfe%3BWeb+UI%3BBrowser+access%3Br0c1&n=desktop%3Bfe%3BDesktop+App%3BElectron+client%3Br0c2&n=sdk%3Bbe%3BJavaScript+SDK%3BProgrammatic+access%3Br1c0&n=server%3Bsvc%3BOpenCode+Core+Service%3BCLI+and+HTTP+server%3Br1c1&n=session%3Bsvc%3BSessions+%26+Messages%3BContext+management%3Br2c0&n=agent%3Bsvc%3BAgent+System%3BBuild+and+Plan+subagents%3Br2c1&n=provider%3Bsvc%3BModel+Providers%3BModel+requests+and+responses%3Br2c2&n=tools%3Bsvc%3BTool+System%3BFile+I%2FO%2C+Bash+and+search%3Br3c0&n=mcp%3Bsvc%3BMCP+Services%3BExternal+tool+integrations%3Br3c1&n=plugin%3Bsvc%3BPlugins+%26+Extensions%3BEvent+hooks+and+custom+capabilities%3Br3c2&n=storage%3Bdb%3BLocal+Storage%3BSQLite+session+data%3Br4c1&e=tui%3Bserver%3BTerminal+request&e=web%3Bserver%3BHTTP+API&e=desktop%3Bserver%3BClient+request&e=sdk%3Bserver%3BAPI+call&e=server%3Bsession%3BManage+sessions&e=server%3Bagent%3BCoordinate+agents&e=agent%3Bprovider%3BModel+request&e=agent%3Btools%3BInvoke+tools&e=tools%3Bmcp%3BExternal+tool+sources&e=server%3Bplugin%3BLoad+plugins&e=session%3Bstorage%3BRead%2Fwrite+sessions&e=agent%3Bsession%3BMessage+context&b=Client+Interfaces%3B+tui+web+desktop+sdk&b=Core+Runtime%3B+server+session+agent+provider&b=Extensions+%26+Execution%3B+tools+mcp+plugin&b=Data+Persistence%3B+storage) | [](https://www.x-cmd.com/draw/explore/echarts?d=%7B%22title%22%3A%7B%22text%22%3A%22US%20states%20%C2%B7%20GDP%20per%20capita%202024%20%C2%B7%20thousand%20USD%22%7D%2C%22visualMap%22%3A%7B%22min%22%3A50%2C%22max%22%3A120%2C%22orient%22%3A%22horizontal%22%2C%22left%22%3A%22center%22%2C%22bottom%22%3A8%2C%22text%22%3A%5B%22high%22%2C%22low%22%5D%2C%22itemWidth%22%3A12%2C%22itemHeight%22%3A200%2C%22inRange%22%3A%7B%22color%22%3A%5B%22%23eff6ff%22%2C%22%23bfdbfe%22%2C%22%2393c5fd%22%2C%22%2360a5fa%22%5D%7D%7D%2C%22series%22%3A%5B%7B%22type%22%3A%22map%22%2C%22map%22%3A%22USA%22%2C%22label%22%3A%7B%22show%22%3Atrue%2C%22fontSize%22%3A9%2C%22formatter%22%3A%22%7Bb%7D%5Cn%7Bc%7D%22%2C%22color%22%3A%22%230f172a%22%7D%2C%22labelLayout%22%3A%7B%22hideOverlap%22%3Atrue%7D%2C%22itemStyle%22%3A%7B%22areaColor%22%3A%22%23f1f5f9%22%2C%22borderColor%22%3A%22%23ffffff%22%2C%22borderWidth%22%3A0.6%7D%2C%22data%22%3A%5B%7B%22name%22%3A%22New%20York%22%2C%22value%22%3A117%7D%2C%7B%22name%22%3A%22Massachusetts%22%2C%22value%22%3A109%7D%2C%7B%22name%22%3A%22Washington%22%2C%22value%22%3A108%7D%2C%7B%22name%22%3A%22Delaware%22%2C%22value%22%3A105%7D%2C%7B%22name%22%3A%22California%22%2C%22value%22%3A103%7D%2C%7B%22name%22%3A%22North%20Dakota%22%2C%22value%22%3A101%7D%2C%7B%22name%22%3A%22Connecticut%22%2C%22value%22%3A97%7D%2C%7B%22name%22%3A%22Alaska%22%2C%22value%22%3A97%7D%2C%7B%22name%22%3A%22Nebraska%22%2C%22value%22%3A94%7D%2C%7B%22name%22%3A%22Colorado%22%2C%22value%22%3A94%7D%2C%7B%22name%22%3A%22Illinois%22%2C%22value%22%3A90%7D%2C%7B%22name%22%3A%22New%20Jersey%22%2C%22value%22%3A89%7D%2C%7B%22name%22%3A%22Texas%22%2C%22value%22%3A89%7D%2C%7B%22name%22%3A%22Wyoming%22%2C%22value%22%3A88%7D%2C%7B%22name%22%3A%22Minnesota%22%2C%22value%22%3A88%7D%2C%7B%22name%22%3A%22Maryland%22%2C%22value%22%3A87%7D%2C%7B%22name%22%3A%22Virginia%22%2C%22value%22%3A86%7D%2C%7B%22name%22%3A%22Utah%22%2C%22value%22%3A85%7D%2C%7B%22name%22%3A%22New%20Hampshire%22%2C%22value%22%3A85%7D%2C%7B%22name%22%3A%22South%20Dakota%22%2C%22value%22%3A83%7D%2C%7B%22name%22%3A%22Nevada%22%2C%22value%22%3A82%7D%2C%7B%22name%22%3A%22Iowa%22%2C%22value%22%3A82%7D%2C%7B%22name%22%3A%22Hawaii%22%2C%22value%22%3A81%7D%2C%7B%22name%22%3A%22Georgia%22%2C%22value%22%3A79%7D%2C%7B%22name%22%3A%22Ohio%22%2C%22value%22%3A78%7D%2C%7B%22name%22%3A%22Tennessee%22%2C%22value%22%3A78%7D%2C%7B%22name%22%3A%22Kansas%22%2C%22value%22%3A78%7D%2C%7B%22name%22%3A%22Oregon%22%2C%22value%22%3A77%7D%2C%7B%22name%22%3A%22Pennsylvania%22%2C%22value%22%3A77%7D%2C%7B%22name%22%3A%22North%20Carolina%22%2C%22value%22%3A76%7D%2C%7B%22name%22%3A%22Wisconsin%22%2C%22value%22%3A76%7D%2C%7B%22name%22%3A%22Arizona%22%2C%22value%22%3A75%7D%2C%7B%22name%22%3A%22Indiana%22%2C%22value%22%3A75%7D%2C%7B%22name%22%3A%22Florida%22%2C%22value%22%3A74%7D%2C%7B%22name%22%3A%22Rhode%20Island%22%2C%22value%22%3A72%7D%2C%7B%22name%22%3A%22Missouri%22%2C%22value%22%3A72%7D%2C%7B%22name%22%3A%22Louisiana%22%2C%22value%22%3A72%7D%2C%7B%22name%22%3A%22Vermont%22%2C%22value%22%3A71%7D%2C%7B%22name%22%3A%22Maine%22%2C%22value%22%3A71%7D%2C%7B%22name%22%3A%22Michigan%22%2C%22value%22%3A69%7D%2C%7B%22name%22%3A%22New%20Mexico%22%2C%22value%22%3A69%7D%2C%7B%22name%22%3A%22Montana%22%2C%22value%22%3A69%7D%2C%7B%22name%22%3A%22South%20Carolina%22%2C%22value%22%3A65%7D%2C%7B%22name%22%3A%22Idaho%22%2C%22value%22%3A64%7D%2C%7B%22name%22%3A%22Oklahoma%22%2C%22value%22%3A64%7D%2C%7B%22name%22%3A%22Kentucky%22%2C%22value%22%3A64%7D%2C%7B%22name%22%3A%22Alabama%22%2C%22value%22%3A63%7D%2C%7B%22name%22%3A%22Arkansas%22%2C%22value%22%3A61%7D%2C%7B%22name%22%3A%22West%20Virginia%22%2C%22value%22%3A60%7D%2C%7B%22name%22%3A%22Mississippi%22%2C%22value%22%3A54%7D%5D%7D%5D%7D&w=960&h=540) |
|
|
21
|
+
| [](https://www.x-cmd.com/draw/explore/mindmap?style=radial&title=LLM+Technology+Landscape&n=LLM%2FPretraining%2FData%2FCleaning+%26+Deduplication&n=LLM%2FPretraining%2FData%2FSynthetic+Data&n=LLM%2FPretraining%2FTraining%2FMoE+Architecture&n=LLM%2FAlignment%2FSFT&n=LLM%2FAlignment%2FRLHF&n=LLM%2FAlignment%2FDPO&n=LLM%2FInference%2FSampling%2Ftemperature&n=LLM%2FInference%2FSampling%2Ftop-p&n=LLM%2FInference%2FAcceleration%2FKV+Cache&n=LLM%2FInference%2FAcceleration%2FSpeculative+Decoding&n=LLM%2FInference%2FAcceleration%2FQuantization&n=LLM%2FInference%2FDeployment%2FvLLM&n=LLM%2FRAG%2FVector+Database&n=LLM%2FRAG%2FEmbedding+Models&n=LLM%2FRAG%2FReranking&n=LLM%2FAgent%2FTool+Calling&n=LLM%2FAgent%2FTask+Planning&n=LLM%2FAgent%2FMulti-Agent+Systems&n=LLM%2FAgent%2FMCP+Protocol&n=LLM%2FFine-tuning%2FLoRA&n=LLM%2FFine-tuning%2FFull-Parameter+Fine-Tuning&n=LLM%2FFine-tuning%2FKnowledge+Distillation&n=LLM%2FEvaluation%2FMMLU&n=LLM%2FEvaluation%2FHumanEval&n=LLM%2FEvaluation%2FLLM-as-a-Judge&n=LLM%2FMultimodal%2FVision+Encoders&n=LLM%2FMultimodal%2FSpeech&n=LLM%2FMultimodal%2FVideo) | [](https://www.x-cmd.com/draw/explore/chem?smiles=CC%28%3DO%29Oc1ccccc1C%28%3DO%29O) |
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
https://x-cmd.com/draw?type=hbar&labels=deno,node,bun&values=7238,6553,4972&title=Runtime%20throughput&unit=ops%2Fs
|
|
26
|
-
```
|
|
23
|
+
## Quick start
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
### 1. Teach your agent to use draw
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
Give the following prompt to an agent that can read web pages. The hosted draw service requires no account registration or API key:
|
|
31
28
|
|
|
32
29
|
```text
|
|
33
|
-
https://x-cmd
|
|
30
|
+
Read and follow https://raw.githubusercontent.com/x-cmd/draw/main/SKILL.md. From now on, whenever you write a README, issue, pull request, blog post, or chat message and need a chart, use x-cmd Draw to generate a link and embed it with image syntax instead of attaching image files.
|
|
34
31
|
```
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
### 2. Describe what you need
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
Tell the agent what data to use, what relationship to express, and where the chart will go:
|
|
39
36
|
|
|
40
37
|
```text
|
|
41
|
-
|
|
38
|
+
Add an architecture diagram to the README, showing the request path from the CLI through the API to the database.
|
|
42
39
|
```
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
For regular use, install [`SKILL.md`](SKILL.md) in an agent that supports local skills. For Claude Code, save it as `~/.claude/skills/draw/SKILL.md`; after this one-time setup, you can describe your request directly.
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
## Features
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
- **🔗 A URL is a chart**: Data and styling remain readable, comparable, version-controlled text, and the link embeds directly in Markdown and web pages.
|
|
46
|
+
- **🤖 Readable by people and AI**: SVG handles presentation while machine-readable data and parameters support modification and regeneration—no need to infer data from an image.
|
|
47
|
+
- **📊 Broad visualization support**: Create data charts, flowcharts, architecture diagrams, mind maps, maps, and schedules, or use ECharts for more complex data relationships.
|
|
48
|
+
- **🖱️ Interactive editing**: Open an example in the interactive editor to inspect data, adjust parameters and styles, and copy the updated chart link.
|
|
49
|
+
- **🚀 Open and self-hostable**: Built with TypeScript and licensed under Apache-2.0, with a hosted service, CLI, npm / JSR libraries, and Cloudflare Workers deployment.
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
## Not using an agent? Choose your workflow
|
|
53
52
|
|
|
54
|
-
###
|
|
53
|
+
### Make a quick chart: use a URL
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
Ideal for documentation, sharing, and ad-hoc visualization. Open the [demo and interactive editor](https://x-cmd.com/draw), adjust the data and styling, then copy the link—or edit the URL parameters directly:
|
|
56
|
+
|
|
57
|
+
```md
|
|
58
|
+

|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
Your readers see a chart; you keep text that is easy to modify and review.
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
### Generate charts in bulk or integrate them: use the CLI or a library
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
Ideal for updating charts in CI, generating reports in bulk, working offline, and integrating charts into applications. The CLI, libraries, and hosted service share the same parameters:
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
```sh
|
|
68
|
+
npx @x-cmd/draw --type pie --labels A,B --values 3,2 --out pie.svg
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To generate SVG synchronously in code, install the library and call `draw`:
|
|
67
72
|
|
|
68
73
|
```sh
|
|
69
74
|
npm install @x-cmd/draw
|
|
70
75
|
```
|
|
71
76
|
```ts
|
|
72
77
|
import { draw } from '@x-cmd/draw';
|
|
78
|
+
|
|
73
79
|
const { svg } = draw({ type: 'pie', labels: 'A,B', values: '3,2', t: 'evil', scheme: 'dark' });
|
|
74
|
-
// also accepts a query string: draw('?type=bar&labels=Mon,Tue&values=3,5')
|
|
75
|
-
// array values = repeated params (when labels contain commas):
|
|
76
|
-
draw({ type: 'bar', labels: ['Q1, 2024', 'Q2'], values: [1, 2] })
|
|
77
80
|
```
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
Deno users can run `deno add jsr:@x-cmd/draw` and import from `jsr:@x-cmd/draw`. The rendering core accesses neither the network nor the filesystem, making it suitable for restricted environments.
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
draw --type pie --labels "TypeScript,Python,Go" --values "4821,2312,980" --out pie.svg
|
|
83
|
-
draw --type hbar --labels a,b,c --values 3,2,1 --theme xcmd # long flags (--theme/--width/--height)
|
|
84
|
-
draw "?type=hbar&labels=a,b,c&values=3,2,1&t=xcmd" # bare query string, same params as the URL
|
|
85
|
-
```
|
|
84
|
+
### Control the endpoint and data boundary: run your own service
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
Ideal for a shared team endpoint, internal networks, or avoiding dependence on a public service:
|
|
88
87
|
|
|
89
88
|
```sh
|
|
90
89
|
git clone https://github.com/x-cmd/draw && cd draw && npm install
|
|
91
|
-
npm run serve
|
|
92
|
-
|
|
93
|
-
bash scripts/setup.sh # one-shot deploy to your own Cloudflare account
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Environment variables (Node server): `PORT` (default 8787) · `BASE_PATH` · `DATA_REPO`/`DATA_BRANCH`/`GITHUB_TOKEN` (set these to enable POST short links; unset degrades gracefully, exactly like self-deployed workers).
|
|
97
|
-
|
|
98
|
-
**Deno** (native TS; the render core is pure — no network, no files — so the zero-permission sandbox is the security boundary):
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
import { draw } from "jsr:@x-cmd/draw"; // JSR (Deno's native registry)
|
|
102
|
-
// or npm: import { draw } from "npm:@x-cmd/draw";
|
|
103
|
-
const { svg } = draw({ type: "pie", labels: "A,B", values: "3,2" });
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
```sh
|
|
107
|
-
deno add jsr:@x-cmd/draw
|
|
108
|
-
# run straight from source inside the repo (no build):
|
|
109
|
-
deno task cli --type pie --labels A,B --values 3,2 --out pie.svg # only needs --allow-write
|
|
110
|
-
deno task serve # local server (same as npm run serve)
|
|
111
|
-
# proof of zero permissions: deno eval defaults to no grants — importing and rendering just works
|
|
90
|
+
npm run serve # Local service: http://localhost:8787/draw
|
|
91
|
+
bash scripts/setup.sh # One-command deployment to your Cloudflare account
|
|
112
92
|
```
|
|
113
93
|
|
|
114
|
-
|
|
94
|
+
Configure `DATA_REPO`, `DATA_BRANCH`, and `GITHUB_TOKEN` to enable permanent short links; regular GET rendering works without them. See the [self-hosting guide](docs/1-overview/05-self-hosting/en.md).
|
|
115
95
|
|
|
116
|
-
|
|
96
|
+
## Documentation and API
|
|
117
97
|
|
|
118
|
-
|
|
119
|
-
|---|---|---|
|
|
120
|
-
| `pie` | donut; `donut=0` for a solid pie<br><br>**<u>≤100 categories (>9 auto-merge into Other)</u>** | <a href="https://x-cmd.com/draw?type=pie&labels=TS,Py,Go,Rust&values=4821,2312,980,645&title=Stars%20by%20language"><img src="https://x-cmd.com/draw?type=pie&labels=TS,Py,Go,Rust&values=4821,2312,980,645&title=Stars%20by%20language" width="360" alt="pie example"></a> |
|
|
121
|
-
| `bar` | grouped columns; multi-series with `stack=1` for stacked<br><br>**<u>≤30 groups</u>** | <a href="https://x-cmd.com/draw?type=bar&labels=Mon,Tue,Wed&series=dev:12,18,9&series=ci:8,11,6"><img src="https://x-cmd.com/draw?type=bar&labels=Mon,Tue,Wed&series=dev:12,18,9&series=ci:8,11,6" width="360" alt="bar example"></a> |
|
|
122
|
-
| `hbar` | horizontal bars (rankings; labels left, values right)<br><br>**<u>≤30 bars, single series (some styles take two)</u>** | <a href="https://x-cmd.com/draw?type=hbar&labels=cli,core,docs,ui&values=42,31,18,9&title=Commits%20by%20area"><img src="https://x-cmd.com/draw?type=hbar&labels=cli,core,docs,ui&values=42,31,18,9&title=Commits%20by%20area" width="360" alt="hbar example"></a> |
|
|
123
|
-
| `line` | smooth line + gradient area / multi-line<br><br>**<u>≤60 points</u>** | <a href="https://x-cmd.com/draw?type=line&labels=Jan,Feb,Mar,Apr,May,Jun&values=12,19,15,25,22,30&title=Stars"><img src="https://x-cmd.com/draw?type=line&labels=Jan,Feb,Mar,Apr,May,Jun&values=12,19,15,25,22,30&title=Stars" width="360" alt="line example"></a> |
|
|
124
|
-
| `area` | area / multi-series area (gradient fill)<br><br>**<u>≤60 points</u>** | <a href="https://x-cmd.com/draw?type=area&labels=Q1,Q2,Q3,Q4&values=8,14,23,37&title=Downloads"><img src="https://x-cmd.com/draw?type=area&labels=Q1,Q2,Q3,Q4&values=8,14,23,37&title=Downloads" width="360" alt="area example"></a> |
|
|
125
|
-
| `radar` | radar chart<br><br>**<u>3–12 axes</u>** | <a href="https://x-cmd.com/draw?type=radar&t=evil&labels=perf,docs,tests,dx&series=v1:7,5,8,6&series=v2:8,8,9,8"><img src="https://x-cmd.com/draw?type=radar&t=evil&labels=perf,docs,tests,dx&series=v1:7,5,8,6&series=v2:8,8,9,8" width="360" alt="radar example"></a> |
|
|
126
|
-
| `gauge` | gauge (240° arc + center value)<br><br>**<u>`value`+`max` (default 100), value ≤ max; multi-ring ≤8</u>** | <a href="https://x-cmd.com/draw?type=gauge&title=CI%20pass%20rate&value=87&max=100"><img src="https://x-cmd.com/draw?type=gauge&title=CI%20pass%20rate&value=87&max=100" width="360" alt="gauge example"></a> |
|
|
127
|
-
| `scatter` | scatter (two numeric axes, negatives supported; no value labels by default)<br><br>**<u>`x=&y=`, ≤200 points</u>** | <a href="https://x-cmd.com/draw?type=scatter&x=1,2,3,4,5&y=4,5,3,6,5&title=Latency"><img src="https://x-cmd.com/draw?type=scatter&x=1,2,3,4,5&y=4,5,3,6,5&title=Latency" width="360" alt="scatter example"></a> |
|
|
128
|
-
| `combo` | bars (`series=`) + line (`line=`) in one chart; `stack=1` to stack the bars<br><br>**<u>≤30 groups, ≤6 series total</u>** | <a href="https://x-cmd.com/draw?type=combo&labels=Mon,Tue,Wed,Thu,Fri&series=dl:120,180,150,210,240&line=growth:3.1,3.4,3.2,3.8,4.1&title=Downloads"><img src="https://x-cmd.com/draw?type=combo&labels=Mon,Tue,Wed,Thu,Fri&series=dl:120,180,150,210,240&line=growth:3.1,3.4,3.2,3.8,4.1&title=Downloads" width="360" alt="combo example"></a> |
|
|
129
|
-
| `sankey` | flow diagram with weighted bands<br><br>**<u>`labels=`+`links=A>B:30`, ≤24 nodes/60 links</u>** | <a href="https://x-cmd.com/draw?type=sankey&labels=Visitors,Stars,Forks,PRs,Merged&links=Visitors>Stars:84;Stars>Forks:17;Forks>PRs:9;PRs>Merged:7&title=Contributor%20funnel"><img src="https://x-cmd.com/draw?type=sankey&labels=Visitors,Stars,Forks,PRs,Merged&links=Visitors>Stars:84;Stars>Forks:17;Forks>PRs:9;PRs>Merged:7&title=Contributor%20funnel" width="360" alt="sankey example"></a> |
|
|
130
|
-
| `qr` | QR code<br><br>**<u>`d`=text (≤1000 chars), `fg`/`bg` colors, `title`/`unit` captions</u>** | <a href="https://x-cmd.com/draw?type=qr&d=https://github.com/x-cmd/draw&title=scan%20me"><img src="https://x-cmd.com/draw?type=qr&d=https://github.com/x-cmd/draw&title=scan%20me" width="360" alt="qr example"></a> |
|
|
98
|
+
Complete chart references, parameters, and examples are organized by topic:
|
|
131
99
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
100
|
+
| Topic | Documentation |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| Browse all chart types and scenarios | [Documentation index](docs/README.md) · [Reference charts](docs/9-showcases/12-reference-examples/en.md) · [Cloud architecture examples](docs/9-showcases/14-cloud-architecture/en.md) |
|
|
103
|
+
| Common parameters and URL encoding | [Parameters](docs/1-overview/07-params/en.md) |
|
|
104
|
+
| JSON data | [Data formats and API](docs/1-overview/04-data-and-api/en.md) |
|
|
105
|
+
| Create short links or configure their storage | [Self-hosting and short-link configuration](docs/1-overview/05-self-hosting/en.md) |
|
|
106
|
+
| Architecture, sequence, ERD, and other structural diagrams | [Diagram URL grammar](docs/1-overview/06-diagram-urls/en.md) |
|
|
107
|
+
| Run locally or deploy to Cloudflare | [Self-hosting guide](docs/1-overview/05-self-hosting/en.md) |
|
|
108
|
+
| Generate charts with an AI agent | [Agent skill](SKILL.md) |
|
|
135
109
|
|
|
136
|
-
|
|
110
|
+
<details>
|
|
111
|
+
<summary>Inside draw: generated project diagrams</summary>
|
|
137
112
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- `v` pin a version; `w`/`h` size (200–1600 / 140–1200; qr is 120–1000 / 140–1000)
|
|
141
|
-
- `num` value labels: `all` / `peak` (highest only) / `none`. Defaults follow the style; applies to pie/bar/hbar/line/area/scatter/combo (radar/gauge/sankey/qr ignore it)
|
|
142
|
-
- `subtitle` editorial subtitle (only rendered by area's editorial style `t=opendata`), `source` data-source footnote (area only, any `t`); other types parse but ignore these
|
|
113
|
+
<!-- BEGIN draw-diagrams -->
|
|
114
|
+
<!-- 由 scripts/diagrams.mjs 生成:node scripts/diagrams.mjs(改完用 --check 对一遍) -->
|
|
143
115
|
|
|
144
|
-
|
|
116
|
+
### Inside draw — the code structure
|
|
145
117
|
|
|
146
|
-
|
|
118
|
+
One edge worker, one render core, four directories that matter: `specs/` parses, `styles/` skins, `render/` draws, `store.ts` keeps the short links.
|
|
147
119
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
| `pie` | `opendata` (default, all labels outside), `evil` (rounded ring + inner values), `evil-mono` (solid pie + leader lines), `market-mono` (grayscale + ring total), `progress` (dotted progress ring), `revenue` (gradient wedges + dashed inner ring) |
|
|
151
|
-
| `bar` | `evil` (default, grouped), `base` (card), `grid` (table bars) |
|
|
152
|
-
| `hbar` | `base` (default), `opendata` (supports `ref=`/`reflabel=` reference line), `xcmd` (pixel bars, %), `xcmd-issue` (two-series butterfly), `rank` (two-series solid + hatching) |
|
|
153
|
-
| `line` | `shadcn` (default), `evil`, `evil-glow` (glow), `evil-mono`, `opendata` (line-end labels) |
|
|
154
|
-
| `area` | `evil` (default, two-series dashed areas), `star` (hand-drawn), `opendata` (dense gradient + editorial title), `pixel`, `polka` |
|
|
155
|
-
| `radar` | `base` (default), `evil` (multi-series), `xcmd` |
|
|
156
|
-
| `sankey` | `base` (default), `fund`, `pipeline` |
|
|
157
|
-
| `gauge` | `base` (default), `gradient`, `reliability` (zoned ring gauge) |
|
|
158
|
-
| `scatter` / `combo` / `qr` | `base` (combo also has `evil`) |
|
|
159
|
-
|
|
160
|
-
## Two ways to pass data
|
|
161
|
-
|
|
162
|
-
**Flat params** (URL stays readable — recommended):
|
|
163
|
-
|
|
164
|
-
```
|
|
165
|
-
/draw?type=pie&title=Stars by language&unit=stars&labels=TypeScript,Python,Go,Rust&values=4821,2312,980,645
|
|
166
|
-
/draw?type=bar&title=Weekly downloads&labels=Mon,Tue&values=1200,1800
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
When labels contain commas, use repeated params: `labels=Q1, 2024&labels=Q2&values=1&values=2`
|
|
170
|
-
|
|
171
|
-
**Multi-series comparison** (type=bar grouped/stacked, type=line, type=area, ≤6 series):
|
|
172
|
-
|
|
173
|
-
```
|
|
174
|
-
/draw?type=area&labels=Mon,Tue,Wed&series=Desktop:120,180,150&series=Mobile:80,90,85
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**JSON form** (complex data): `?d=` + URL-encoded JSON:
|
|
178
|
-
|
|
179
|
-
```json
|
|
180
|
-
{"title":"Stars by language","unit":"stars","data":[{"label":"TypeScript","value":4821},{"label":"Python","value":2312}]}
|
|
120
|
+
```text
|
|
121
|
+
https://x-cmd.com/draw/arch2?n=entry;fe;Worker%20entry;src/index.ts;r0c0&n=node;svc;Node%20server%20%2B%20CLI;src/node/;r0c1&n=handler;be;handler.ts;routing%20%2B%20responses;r1c0&n=demo;fe;demo/;gallery%20%2B%20landing;r1c1&n=specs;be;specs/;parse%20%2B%20validate;r2c0&n=store;db;store.ts;short%20links%20in%20a%20Git%20repo;r2c1&n=render;be;render/;draw%20the%20SVG;r3c0&n=styles;be;styles/;skins%20%2B%20families;r3c1&e=entry;handler&e=node;handler&e=handler;specs&e=handler;store&e=handler;demo&e=handler;render&e=render;styles&b=Edge%20worker;handler%20specs%20store%20render%20styles&title=Inside%20draw
|
|
181
122
|
```
|
|
182
123
|
|
|
183
|
-
|
|
124
|
+

|
|
184
125
|
|
|
185
|
-
|
|
126
|
+
### One request, step by step
|
|
186
127
|
|
|
187
|
-
|
|
128
|
+
The URL is parsed, a skin is picked, the SVG is drawn, and it comes back with `<metadata>` inside — one path for every chart type.
|
|
188
129
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Combo: `/draw?type=combo&labels=Mon,Tue&series=dl:120,180&line=growth:5,8` (dual y-axes kick in automatically when bars and lines differ by >5×)
|
|
192
|
-
|
|
193
|
-
## Short links (data stored in a GitHub repo; content-addressed, never expires)
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
POST /draw?type=pie body = chart spec JSON
|
|
197
|
-
POST /draw?type=bar&t=evil body = CSV (text/csv, header row)
|
|
198
|
-
→ 201 {"hash":"a3f9c2d4e5f60718","url":"https://x-cmd.com/draw/c/a3f9c2d4e5f60718"}
|
|
199
|
-
|
|
200
|
-
GET /draw/c/<hash> → SVG, cached immutable forever
|
|
130
|
+
```text
|
|
131
|
+
https://x-cmd.com/draw/seq?n=app;fe;Your%20app;;r0c0&n=worker;be;Worker;;r0c1&n=specs;be;specs/;parse%20%2B%20validate;r0c2&n=render;be;render/;draw%20the%20SVG;r0c3&e=app;worker;GET%20/draw%3Ftype=pie&e=worker;specs;parse%20the%20spec&e=specs;worker;spec;dash&e=worker;render;draw&e=render;worker;SVG;dash&e=worker;app;200%20%2B%20%3Cmetadata%3E;dash&title=One%20request
|
|
201
132
|
```
|
|
202
133
|
|
|
203
|
-
-
|
|
204
|
-
- Multi-series is supported for bar/line/area/radar, plus hbar (only `t=xcmd-issue`/`t=rank`, exactly 2 series); other types reject multi-series bodies with 400. POST is rate-limited to 30/min/IP
|
|
205
|
-
- Server-side config: `DATA_REPO` (public repo, `owner/name`, in wrangler.jsonc) and `GITHUB_TOKEN` (secret; fine-grained PAT with **Contents: write** on that repo only — reads go through raw, tokenless). Data files live at `charts/<hash>.json`
|
|
206
|
-
- Visibility: the data repo is public and browsable — **do not create short links with sensitive data** (private storage is planned, as a paid feature)
|
|
207
|
-
- Compared to quickchart: their short links expire (6 months / days); ours never do
|
|
134
|
+

|
|
208
135
|
|
|
209
|
-
|
|
136
|
+
### What draw is for
|
|
210
137
|
|
|
211
|
-
|
|
212
|
-
- `?v=1`: pins a version, `Cache-Control: max-age=86400` (1 day; rendering still evolves with deploys — not frozen forever). `v` accepts 1..current; out of range → 400
|
|
213
|
-
- `immutable` is reserved for short links `/c/<hash>` (content-addressed, truly unchanging; `v` is ignored there)
|
|
138
|
+
Four kinds of callers: your code, an AI agent, your README, and whoever runs their own copy.
|
|
214
139
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
Every SVG embeds `<metadata>` (escaped JSON): `{generator, template, version, spec}` — data and params round-trip directly. All text is real `<text>` elements.
|
|
218
|
-
|
|
219
|
-
## One-shot self-deploy
|
|
220
|
-
|
|
221
|
-
Deploy your own draw to your Cloudflare account (free tier works; you just need a CF account):
|
|
222
|
-
|
|
223
|
-
```sh
|
|
224
|
-
curl -fsSL https://raw.githubusercontent.com/x-cmd/draw/main/scripts/setup.sh | bash
|
|
140
|
+
```text
|
|
141
|
+
https://x-cmd.com/draw/uc?n=caller;actor;Your%20app%20or%20CI&n=agent;actor;AI%20agent&n=writer;actor;README%20or%20docs&n=ops;actor;Self-host%20operator&n=uc1;uc;Render%20a%20chart;GET%20/draw%3Ftype=...&n=uc2;uc;Store%20a%20short%20link;POST%20/draw&n=uc3;uc;Embed%20the%20SVG;markdown%20%2B%20img&n=uc4;uc;Run%20it%20yourself;npm%20%2B%20wrangler&e=caller;uc1&e=caller;uc2&e=agent;uc1&e=writer;uc3&e=ops;uc4&b=draw;uc1%20uc2%20uc3%20uc4&title=What%20draw%20is%20for
|
|
225
142
|
```
|
|
226
143
|
|
|
227
|
-
|
|
144
|
+

|
|
145
|
+
<!-- END draw-diagrams -->
|
|
228
146
|
|
|
229
|
-
|
|
230
|
-
- Already cloned the repo? Run `npm run setup` inside it (skips the clone)
|
|
231
|
-
- Path prefix auto-adapts: both the workers.dev root and a `/draw` sub-route work with zero code changes; or pin it explicitly with the `BASE_PATH` var
|
|
232
|
-
- Custom domain: dashboard → Workers → Settings → Domains & Routes, add a route (any path prefix)
|
|
233
|
-
- On Windows, run under WSL or Git Bash
|
|
147
|
+
</details>
|
|
234
148
|
|
|
235
149
|
## Development
|
|
236
150
|
|
|
237
151
|
```sh
|
|
238
152
|
npm install
|
|
239
|
-
npm run dev # wrangler dev
|
|
240
|
-
npm test #
|
|
153
|
+
npm run dev # Start wrangler dev locally
|
|
154
|
+
npm test # Vitest
|
|
241
155
|
npm run check # tsc --noEmit × 3 (worker / node / build)
|
|
242
|
-
npm run build #
|
|
156
|
+
npm run build # Build dist/ (npm library + CLI)
|
|
243
157
|
npm run deploy # wrangler deploy
|
|
244
158
|
```
|
|
245
159
|
|
|
246
160
|
## License
|
|
247
161
|
|
|
248
|
-
Code is [Apache-2.0](LICENSE). Bundled fonts
|
|
162
|
+
Code is licensed under [Apache-2.0](LICENSE). Bundled fonts retain their own licenses: Inter (OFL, see [`inter-OFL.txt`](src/styles/inter-OFL.txt)) and Handlee (OFL, see [`handlee-OFL.txt`](src/styles/handlee-OFL.txt)).
|
package/dist/lib.d.ts
CHANGED
|
@@ -15,14 +15,40 @@ export { renderGauge } from './render/gauge.js';
|
|
|
15
15
|
export { renderScatter } from './render/scatter.js';
|
|
16
16
|
export { renderCombo } from './render/combo.js';
|
|
17
17
|
export { renderQR } from './render/qr.js';
|
|
18
|
+
export { parseAnnos, injectAnnos, annoLayer, type Anno } from './render/anno.js';
|
|
19
|
+
export { footerUnit, headerMeta, tipUnit, tipHeight, type FooterItem, type TipRow } from './render/units.js';
|
|
18
20
|
export { renderSankey } from './render/sankey.js';
|
|
21
|
+
export { renderQuadrant } from './render/quadrant.js';
|
|
22
|
+
export { renderCompass } from './render/compass.js';
|
|
23
|
+
export { renderButterfly } from './render/butterfly.js';
|
|
24
|
+
export { renderCalendar } from './render/calendar.js';
|
|
25
|
+
export { renderTable, tableToGrid, type TableGrid } from './render/table.js';
|
|
26
|
+
export { parseTableSpec, tableSpecFromParams } from './specs/table.js';
|
|
19
27
|
export { renderStored } from './render/dispatch.js';
|
|
20
|
-
export { esc, fmtFull, fmtNum, textW } from './render/svg.js';
|
|
28
|
+
export { esc, fmtFull, fmtNum, textW, EDIT_TAG_STRIP_SRC, roundedPath } from './render/svg.js';
|
|
29
|
+
export { loadMapGeoJson, loadUsStatesGeoJson, loadWorldSphericalGeoJson, WORLD_WRAP_COPIES, worldWrapGeo, worldWrapLayout, worldWrapNeeded, } from './render/maps.js';
|
|
21
30
|
export { parseColor, requireQRText, QR_DEFAULTS } from './render/qr.js';
|
|
22
31
|
export { assertDims } from './render/radar.js';
|
|
23
32
|
export type { RenderOpts } from './render/svg.js';
|
|
24
33
|
import { type DrawResult } from './render/query.js';
|
|
25
34
|
export { renderFromUrl, renderStoredFromUrl } from './render/query.js';
|
|
35
|
+
export { renderEchartsFromUrl, renderEchartsOption, mapLayout, headLayout, HEAD_RULES } from './render/echarts-ssr.js';
|
|
36
|
+
export { renderArchmapFromUrl, parseNodes, parseEdges, parseBoundaries } from './render/archmap.js';
|
|
37
|
+
export { iconOf, ICONS } from './render/icons.js';
|
|
38
|
+
export type { ArchNode, ArchEdge, ArchBoundary, NodeType, EdgeVariant, Box, Side, Placed } from './render/archmap.js';
|
|
39
|
+
export { renderArchFromUrl, renderArchCore, renderCloudFromUrl, CLOUD_TYPES } from './render/arch.js';
|
|
40
|
+
export { gridLayout, labelGaps, type LayoutEngine, type LayoutCtx, type LayoutResult, } from './render/layout.js';
|
|
41
|
+
export { routeEdges, routeOrthogonal, portAt, portOffset, segsCross, segsOverlap, segsMeet, PORT_GAP, type RoutingEngine, type RoutingCtx, type RoutingWeights, type Drawn, } from './render/route.js';
|
|
42
|
+
export { renderMermaidFromUrl, parseFlow } from './render/mermaid.js';
|
|
43
|
+
export { parseGantt, renderGantt, renderGanttFromUrl } from './render/gantt.js';
|
|
44
|
+
export { parseTokei, renderTokeiFromUrl } from './render/tokei.js';
|
|
45
|
+
export { renderGantt2FromUrl, renderGantt2Core } from './render/gantt2.js';
|
|
46
|
+
export { renderKindFromUrl, KIND_NAMES } from './render/kinds.js';
|
|
47
|
+
export { ARCH_TYPES, type HouseTypes } from './render/arch.js';
|
|
48
|
+
export { renderSeqFromUrl, renderSeqCore } from './render/seq.js';
|
|
49
|
+
export { renderUcFromUrl, renderUcCore } from './render/uc.js';
|
|
50
|
+
export { renderMindmapFromUrl } from './render/mindmap.js';
|
|
51
|
+
export { svgToPng, bakeFlatSvg, injectResvgWasm } from './render/png.js';
|
|
26
52
|
export type { DrawResult } from './render/query.js';
|
|
27
53
|
export { CHART_TEMPLATES, fingerprint, canonicalJson, type ChartTemplate, type StoredChart, } from './store.js';
|
|
28
54
|
/**
|
package/dist/lib.js
CHANGED
|
@@ -20,14 +20,52 @@ export { renderGauge } from './render/gauge.js';
|
|
|
20
20
|
export { renderScatter } from './render/scatter.js';
|
|
21
21
|
export { renderCombo } from './render/combo.js';
|
|
22
22
|
export { renderQR } from './render/qr.js';
|
|
23
|
+
export { parseAnnos, injectAnnos, annoLayer } from './render/anno.js';
|
|
24
|
+
export { footerUnit, headerMeta, tipUnit, tipHeight } from './render/units.js';
|
|
23
25
|
export { renderSankey } from './render/sankey.js';
|
|
26
|
+
export { renderQuadrant } from './render/quadrant.js';
|
|
27
|
+
export { renderCompass } from './render/compass.js';
|
|
28
|
+
export { renderButterfly } from './render/butterfly.js';
|
|
29
|
+
export { renderCalendar } from './render/calendar.js';
|
|
30
|
+
export { renderTable, tableToGrid } from './render/table.js';
|
|
31
|
+
export { parseTableSpec, tableSpecFromParams } from './specs/table.js';
|
|
24
32
|
export { renderStored } from './render/dispatch.js';
|
|
25
33
|
// Small helpers that page builders (and the x-cmd-hosted worker) reuse:
|
|
26
|
-
export { esc, fmtFull, fmtNum, textW } from './render/svg.js';
|
|
34
|
+
export { esc, fmtFull, fmtNum, textW, EDIT_TAG_STRIP_SRC, roundedPath } from './render/svg.js';
|
|
35
|
+
// US 各州 GeoJSON(浏览器端 echarts 注册地图要用:运行时那份不带地图数据)
|
|
36
|
+
export { loadMapGeoJson, loadUsStatesGeoJson, loadWorldSphericalGeoJson, WORLD_WRAP_COPIES, worldWrapGeo, worldWrapLayout, worldWrapNeeded, } from './render/maps.js';
|
|
27
37
|
export { parseColor, requireQRText, QR_DEFAULTS } from './render/qr.js';
|
|
28
38
|
export { assertDims } from './render/radar.js';
|
|
29
39
|
import { renderFromUrl } from './render/query.js';
|
|
30
40
|
export { renderFromUrl, renderStoredFromUrl } from './render/query.js';
|
|
41
|
+
// echarts 覆盖层:异步(SSR 引擎按需加载),与 GET /draw/echarts 同参同输出
|
|
42
|
+
export { renderEchartsFromUrl, renderEchartsOption, mapLayout, headLayout, HEAD_RULES } from './render/echarts-ssr.js';
|
|
43
|
+
// archmap 拓扑图:同步,与 GET /draw/archmap 同参同输出(draw({type:'archmap', n:[...]}) 亦可)
|
|
44
|
+
export { renderArchmapFromUrl, parseNodes, parseEdges, parseBoundaries } from './render/archmap.js';
|
|
45
|
+
// 图标库(站上自己画图时要用:三维场景里把图标摆在块上面)
|
|
46
|
+
export { iconOf, ICONS } from './render/icons.js';
|
|
47
|
+
export { renderArchFromUrl, renderArchCore, renderCloudFromUrl, CLOUD_TYPES } from './render/arch.js';
|
|
48
|
+
// 摆位引擎的挂载点:库只管把「怎么画」做好,「怎么摆」可以换 ——
|
|
49
|
+
// 自带一个通用的实现,站上装的是更好的那个(引擎的选择不是 URL 的一部分)
|
|
50
|
+
export { gridLayout, labelGaps, } from './render/layout.js';
|
|
51
|
+
// 布线的挂载点:线怎么走(选面、排端口、走哪条通道)可以换 ——
|
|
52
|
+
// 库只管把「怎么画」做好,「怎么走」可以换(引擎的选择不是 URL 的一部分)
|
|
53
|
+
export { routeEdges, routeOrthogonal, portAt, portOffset, segsCross, segsOverlap, segsMeet, PORT_GAP, } from './render/route.js';
|
|
54
|
+
// mermaid 语法糖 → archmap 渲染(/draw/mermaid?m=<flowchart 源码>)
|
|
55
|
+
export { renderMermaidFromUrl, parseFlow } from './render/mermaid.js';
|
|
56
|
+
export { parseGantt, renderGantt, renderGanttFromUrl } from './render/gantt.js';
|
|
57
|
+
export { parseTokei, renderTokeiFromUrl } from './render/tokei.js';
|
|
58
|
+
export { renderGantt2FromUrl, renderGantt2Core } from './render/gantt2.js';
|
|
59
|
+
export { renderKindFromUrl, KIND_NAMES } from './render/kinds.js';
|
|
60
|
+
export { ARCH_TYPES } from './render/arch.js';
|
|
61
|
+
export { renderSeqFromUrl, renderSeqCore } from './render/seq.js';
|
|
62
|
+
export { renderUcFromUrl, renderUcCore } from './render/uc.js';
|
|
63
|
+
// mindmap 树形导图:同步,与 GET /draw/mindmap 同参同输出
|
|
64
|
+
export { renderMindmapFromUrl } from './render/mindmap.js';
|
|
65
|
+
// PNG 导出(x-cmd-hub/draw#24):任意渲染产出的 SVG → 平面化(烘焙) → resvg-wasm 光栅化;
|
|
66
|
+
// 异步且 lazy 加载 wasm,库用户不调 png 则零成本;Workers 入口需静态 import wasm 后
|
|
67
|
+
// 经 injectResvgWasm 注入(Node/Deno 走 node_modules 文件读取,无需注入)
|
|
68
|
+
export { svgToPng, bakeFlatSvg, injectResvgWasm } from './render/png.js';
|
|
31
69
|
export { CHART_TEMPLATES, fingerprint, canonicalJson, } from './store.js';
|
|
32
70
|
// 对象/查询串/URLSearchParams → DrawResult(同步)。
|
|
33
71
|
// 对象值支持数组(重复参数,labels 含逗号时用):
|