diff --git a/docs/src/content/components/Text.md b/docs/src/content/components/Text.md index 89855677a..8077a1008 100644 --- a/docs/src/content/components/Text.md +++ b/docs/src/content/components/Text.md @@ -11,14 +11,26 @@ related: [] :example{ name="playground" } -## Along path +### Truncate text of axis labels + +Sometimes your axis labels overwhelm the available space. You can use `truncate` to limit the text to a maximum length. + +:example{ name="truncate-axis-labels" } + +### Word wrap with text of axis labels + +You can use explicit newlines (`\n`) in the text value to force a word wrap. This works regardless of the layer you are using. + +:::note +Note you can change the rendering layer with the toggle at the top of the page. +::: + +:example{ name="word-wrap-axis-labels" } + +### Along path `Text` can be used with `Arc`'s `children` snippet and `getArcTextProps` to write along the `inner`, `outer`, or `middle` of the arc path. The text will smartly orientate based on the direction (clockwise / counter-clockwise) and location (top, bottom, left, right) of the arc :example{ component="Arc" name="label-direction" } - - diff --git a/docs/src/examples/catalog/Axis.json b/docs/src/examples/catalog/Axis.json index 6b31d4b08..12c859cf1 100644 --- a/docs/src/examples/catalog/Axis.json +++ b/docs/src/examples/catalog/Axis.json @@ -4030,5 +4030,5 @@ "line": "" } ], - "updatedAt": "2026-01-13T17:22:23.271Z" + "updatedAt": "2026-01-25T21:44:17.452Z" } \ No newline at end of file diff --git a/docs/src/examples/catalog/BarChart.json b/docs/src/examples/catalog/BarChart.json index 4a5e7b940..8b744dc79 100644 --- a/docs/src/examples/catalog/BarChart.json +++ b/docs/src/examples/catalog/BarChart.json @@ -1778,7 +1778,21 @@ "path": "/example/Chart/compound-separate-scales-with-stacked-charts-with-inverted-range-top-down", "lineNumber": 31, "line": "" }, + { + "example": "basic", + "component": "Path", + "path": "/example/Path/basic", + "lineNumber": 5, + "line": "" + }, { "example": "circles", "component": "Pattern", @@ -2809,7 +2816,7 @@ "example": "playground", "component": "Text", "path": "/example/Text/playground", - "lineNumber": 45, + "lineNumber": 44, "line": "" }, { @@ -3044,5 +3051,5 @@ "line": "" } ], - "updatedAt": "2026-01-25T18:09:21.455Z" + "updatedAt": "2026-01-25T21:44:17.657Z" } \ No newline at end of file diff --git a/docs/src/examples/catalog/Circle.json b/docs/src/examples/catalog/Circle.json index 966471e63..5fb9f8ae6 100644 --- a/docs/src/examples/catalog/Circle.json +++ b/docs/src/examples/catalog/Circle.json @@ -603,7 +603,7 @@ "example": "playground", "component": "Text", "path": "/example/Text/playground", - "lineNumber": 49, + "lineNumber": 48, "line": "" }, { @@ -621,5 +621,5 @@ "line": "" } ], - "updatedAt": "2026-01-13T17:22:23.474Z" + "updatedAt": "2026-01-25T20:58:11.921Z" } \ No newline at end of file diff --git a/docs/src/examples/catalog/Layer.json b/docs/src/examples/catalog/Layer.json index 6bef9e4b7..39b912f98 100644 --- a/docs/src/examples/catalog/Layer.json +++ b/docs/src/examples/catalog/Layer.json @@ -2094,6 +2094,13 @@ "lineNumber": 87, "line": "" }, + { + "example": "basic", + "component": "Path", + "path": "/example/Path/basic", + "lineNumber": 6, + "line": "" + }, { "example": "circles", "component": "Pattern", @@ -2854,7 +2861,7 @@ "example": "playground", "component": "Text", "path": "/example/Text/playground", - "lineNumber": 46, + "lineNumber": 45, "line": "" }, { @@ -3096,5 +3103,5 @@ "line": "" } ], - "updatedAt": "2026-01-25T18:09:22.016Z" + "updatedAt": "2026-01-25T21:44:18.232Z" } \ No newline at end of file diff --git a/docs/src/examples/catalog/Path.json b/docs/src/examples/catalog/Path.json index 5d6f010fc..73f4001f7 100644 --- a/docs/src/examples/catalog/Path.json +++ b/docs/src/examples/catalog/Path.json @@ -1,6 +1,36 @@ { "component": "Path", - "examples": [], - "usage": [], - "updatedAt": "2025-12-29T21:36:45.113Z" + "examples": [ + { + "name": "basic", + "path": "/example/Path/basic", + "components": [ + { + "component": "Chart", + "lineNumber": 5, + "line": "" + }, + { + "component": "Layer", + "lineNumber": 6, + "line": "" + }, + { + "component": "Path", + "lineNumber": 7, + "line": "" + } + ] + } + ], + "usage": [ + { + "example": "basic", + "component": "Path", + "path": "/example/Path/basic", + "lineNumber": 7, + "line": "" + } + ], + "updatedAt": "2026-01-25T20:58:12.648Z" } \ No newline at end of file diff --git a/docs/src/examples/catalog/Text.json b/docs/src/examples/catalog/Text.json index 127ac898f..b53621f16 100644 --- a/docs/src/examples/catalog/Text.json +++ b/docs/src/examples/catalog/Text.json @@ -7,26 +7,48 @@ "components": [ { "component": "Chart", - "lineNumber": 45, + "lineNumber": 44, "line": "" }, { "component": "Layer", - "lineNumber": 46, + "lineNumber": 45, "line": "" }, { "component": "Text", - "lineNumber": 47, - "line": "" + "lineNumber": 46, + "line": "" }, { "component": "Circle", - "lineNumber": 49, + "lineNumber": 48, "line": "" } ] }, + { + "name": "truncate-axis-labels", + "path": "/example/Text/truncate-axis-labels", + "components": [ + { + "component": "BarChart", + "lineNumber": 34, + "line": "" + "lineNumber": 46, + "line": "" }, { "example": "word-wrap-with-explicit-newline", @@ -639,5 +661,5 @@ "line": " + import { BarChart, defaultChartPadding } from 'layerchart'; + import TextTruncateControls from '$lib/components/controls/TextTruncateControls.svelte'; + import { schemeTableau10 } from 'd3-scale-chromatic'; + + const data = [ + { + date: new Date('2026-01-22T05:00:00.000Z'), + value: 47, + baseline: 100, + label: 'This is 1st really long text' + }, + { + date: new Date('2026-01-23T05:00:00.000Z'), + value: 27, + baseline: 20, + label: 'This is 2nd really long text' + }, + { + date: new Date('2026-01-24T05:00:00.000Z'), + value: 82, + baseline: 26, + label: 'This is 3rd really long text' + } + ]; + + let position = $state<'start' | 'middle' | 'end'>('end'); + + export { data }; + + + + + diff --git a/docs/src/examples/components/Text/word-wrap-axis-labels.svelte b/docs/src/examples/components/Text/word-wrap-axis-labels.svelte new file mode 100644 index 000000000..277981b67 --- /dev/null +++ b/docs/src/examples/components/Text/word-wrap-axis-labels.svelte @@ -0,0 +1,38 @@ + + + diff --git a/docs/src/lib/components/controls/TextTruncateControls.svelte b/docs/src/lib/components/controls/TextTruncateControls.svelte new file mode 100644 index 000000000..b78a222ea --- /dev/null +++ b/docs/src/lib/components/controls/TextTruncateControls.svelte @@ -0,0 +1,17 @@ + + + + + start + middle + end + + diff --git a/docs/static/screenshots/Path/basic-dark-240w.webp b/docs/static/screenshots/Path/basic-dark-240w.webp new file mode 100644 index 000000000..36689eed6 Binary files /dev/null and b/docs/static/screenshots/Path/basic-dark-240w.webp differ diff --git a/docs/static/screenshots/Path/basic-dark-400w.webp b/docs/static/screenshots/Path/basic-dark-400w.webp new file mode 100644 index 000000000..4c2a9ed0e Binary files /dev/null and b/docs/static/screenshots/Path/basic-dark-400w.webp differ diff --git a/docs/static/screenshots/Path/basic-dark-800w.webp b/docs/static/screenshots/Path/basic-dark-800w.webp new file mode 100644 index 000000000..a395e3fce Binary files /dev/null and b/docs/static/screenshots/Path/basic-dark-800w.webp differ diff --git a/docs/static/screenshots/Path/basic-light-240w.webp b/docs/static/screenshots/Path/basic-light-240w.webp new file mode 100644 index 000000000..ec182fa71 Binary files /dev/null and b/docs/static/screenshots/Path/basic-light-240w.webp differ diff --git a/docs/static/screenshots/Path/basic-light-400w.webp b/docs/static/screenshots/Path/basic-light-400w.webp new file mode 100644 index 000000000..a0aceb6b7 Binary files /dev/null and b/docs/static/screenshots/Path/basic-light-400w.webp differ diff --git a/docs/static/screenshots/Path/basic-light-800w.webp b/docs/static/screenshots/Path/basic-light-800w.webp new file mode 100644 index 000000000..9d8b3aec9 Binary files /dev/null and b/docs/static/screenshots/Path/basic-light-800w.webp differ diff --git a/docs/static/screenshots/Text/playground-dark-240w.webp b/docs/static/screenshots/Text/playground-dark-240w.webp index 549b6dd25..205dec978 100644 Binary files a/docs/static/screenshots/Text/playground-dark-240w.webp and b/docs/static/screenshots/Text/playground-dark-240w.webp differ diff --git a/docs/static/screenshots/Text/playground-dark-400w.webp b/docs/static/screenshots/Text/playground-dark-400w.webp index 736b4c594..1e47191cf 100644 Binary files a/docs/static/screenshots/Text/playground-dark-400w.webp and b/docs/static/screenshots/Text/playground-dark-400w.webp differ diff --git a/docs/static/screenshots/Text/playground-dark-800w.webp b/docs/static/screenshots/Text/playground-dark-800w.webp index 2e4990a48..93fa7f2ba 100644 Binary files a/docs/static/screenshots/Text/playground-dark-800w.webp and b/docs/static/screenshots/Text/playground-dark-800w.webp differ diff --git a/docs/static/screenshots/Text/playground-light-240w.webp b/docs/static/screenshots/Text/playground-light-240w.webp index 0f512bac4..23c823ef8 100644 Binary files a/docs/static/screenshots/Text/playground-light-240w.webp and b/docs/static/screenshots/Text/playground-light-240w.webp differ diff --git a/docs/static/screenshots/Text/playground-light-400w.webp b/docs/static/screenshots/Text/playground-light-400w.webp index fb0bd3a02..e2da0b2f7 100644 Binary files a/docs/static/screenshots/Text/playground-light-400w.webp and b/docs/static/screenshots/Text/playground-light-400w.webp differ diff --git a/docs/static/screenshots/Text/playground-light-800w.webp b/docs/static/screenshots/Text/playground-light-800w.webp index b4db7a993..7aedec69d 100644 Binary files a/docs/static/screenshots/Text/playground-light-800w.webp and b/docs/static/screenshots/Text/playground-light-800w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-dark-240w.webp b/docs/static/screenshots/Text/truncate-axis-labels-dark-240w.webp new file mode 100644 index 000000000..1d0dbdec8 Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-dark-240w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-dark-400w.webp b/docs/static/screenshots/Text/truncate-axis-labels-dark-400w.webp new file mode 100644 index 000000000..1f07d1d8c Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-dark-400w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-dark-800w.webp b/docs/static/screenshots/Text/truncate-axis-labels-dark-800w.webp new file mode 100644 index 000000000..931b7be88 Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-dark-800w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-light-240w.webp b/docs/static/screenshots/Text/truncate-axis-labels-light-240w.webp new file mode 100644 index 000000000..c3e76e400 Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-light-240w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-light-400w.webp b/docs/static/screenshots/Text/truncate-axis-labels-light-400w.webp new file mode 100644 index 000000000..6f3944e54 Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-light-400w.webp differ diff --git a/docs/static/screenshots/Text/truncate-axis-labels-light-800w.webp b/docs/static/screenshots/Text/truncate-axis-labels-light-800w.webp new file mode 100644 index 000000000..5a31af714 Binary files /dev/null and b/docs/static/screenshots/Text/truncate-axis-labels-light-800w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-dark-240w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-240w.webp new file mode 100644 index 000000000..683d6ec2c Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-240w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-dark-400w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-400w.webp new file mode 100644 index 000000000..8e04aeeee Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-400w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-dark-800w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-800w.webp new file mode 100644 index 000000000..b1357dda6 Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-dark-800w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-light-240w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-light-240w.webp new file mode 100644 index 000000000..f0ad8cbdd Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-light-240w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-light-400w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-light-400w.webp new file mode 100644 index 000000000..f9d0aaa6f Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-light-400w.webp differ diff --git a/docs/static/screenshots/Text/word-wrap-axis-labels-light-800w.webp b/docs/static/screenshots/Text/word-wrap-axis-labels-light-800w.webp new file mode 100644 index 000000000..4ef9091e3 Binary files /dev/null and b/docs/static/screenshots/Text/word-wrap-axis-labels-light-800w.webp differ diff --git a/docs/static/screenshots/index.json b/docs/static/screenshots/index.json index fd2c61754..e315496f2 100644 --- a/docs/static/screenshots/index.json +++ b/docs/static/screenshots/index.json @@ -1,7 +1,7 @@ { - "generatedAt": "2026-01-25T18:09:20.616Z", - "totalComponents": 58, - "totalExamples": 705, + "generatedAt": "2026-01-25T22:34:25.883Z", + "totalComponents": 59, + "totalExamples": 708, "components": [ { "component": "AnnotationLine", @@ -2743,6 +2743,16 @@ } ] }, + { + "component": "Path", + "examples": [ + { + "name": "basic", + "path": "/example/Path/basic", + "checksum": "fe973b72c451728ad5b7e295a74156e0" + } + ] + }, { "component": "Pattern", "examples": [ @@ -3604,7 +3614,17 @@ { "name": "playground", "path": "/example/Text/playground", - "checksum": "ba696d636f46d4a4a26898ae7fc3ff30" + "checksum": "b406e9b6f5f2017daa94c1d94b44be90" + }, + { + "name": "truncate-axis-labels", + "path": "/example/Text/truncate-axis-labels", + "checksum": "f3af19adb3e43b73eddca8a14dc2e716" + }, + { + "name": "word-wrap-axis-labels", + "path": "/example/Text/word-wrap-axis-labels", + "checksum": "b31905e3276c19111dc43bf40ecc7ef5" }, { "name": "word-wrap-with-explicit-newline",