diff --git a/docs/src/lib/components/Code.svelte b/docs/src/lib/components/Code.svelte index 181e7b63e..98af9c8d9 100644 --- a/docs/src/lib/components/Code.svelte +++ b/docs/src/lib/components/Code.svelte @@ -1,5 +1,6 @@ + + + + + + + ``` + :: + + ::tab{label="Vanilla CSS"} + Here the color is set via HTML style attribute. + ```svelte live {8} + + + + + + + + ``` + :: + + ::tab{label="CSS Variables"} + Here the color is set via a class using CSS variables. + ```svelte live {8} + + + + + + + + ``` + :: + + + + ::tab{label="SVG style attributes"} + Here the color is set via [SVG Attributes]("https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute") such as `stroke`, `fill`, `strokeWidth`. + ```svelte live {8} + + + + + + + + ``` + + :: + +::: + +#### Nested components / elements + +Along with `class` and `style` props for direct component styling, some components have internal components and elements that can be targetted via `props` and `classes` props to style these nested elements for complex components. + +In this example we can target the `AnnotationPoint`'s internal `circle` and `label` components. + +:example{ component="AnnotationPoint" name="series-annotation" showCode noResize highlight="26-27" } + +#### Color scales + +Picking a color isn't easy. Picking many colors that appear cohesive is even tougher. Why not use designer crafted color schemes? + +::info +more info [Color Schemes](/docs/components/ColorRamp#schemes) +:: + +:example{ path="./color-schemes.svelte" noResize showCode highight="40" } + +#### Data Driven Colors (choropleth, color prop on data for pie chart, etc) + +#### Color Enhancements + +:::tabs{key="color-enhancements"} + + ::tab{label="Linear gradient"} + :example{ component="AreaChart" name="gradient" noResize showCode highlight="11-15" } + :: + + ::tab{label="Radial gradient"} + ```svelte live {7-10} + + + + + + {#snippet children({ gradient })} + + {/snippet} + + + + ``` + :: + + ::tab{label="Pattern"} + :example{ component="AnnotationRange" name="vertical-with-pattern-range" noResize showCode highlight="14-20" } + :: + +::: + +## Padding + +Chart padding is the only other commonly styled element. +`Can xPadding and yPadding be added to example below?` + +:example{ path="./padding.svelte" noResize } diff --git a/docs/src/routes/docs/guides/styles/color-schemes.svelte b/docs/src/routes/docs/guides/styles/color-schemes.svelte new file mode 100644 index 000000000..fff8e4e62 --- /dev/null +++ b/docs/src/routes/docs/guides/styles/color-schemes.svelte @@ -0,0 +1,38 @@ + + + + diff --git a/docs/src/routes/docs/guides/styles/padding.svelte b/docs/src/routes/docs/guides/styles/padding.svelte new file mode 100644 index 000000000..2313c0796 --- /dev/null +++ b/docs/src/routes/docs/guides/styles/padding.svelte @@ -0,0 +1,221 @@ + + +
+ +
+ Customize Padding + Symmetric Padding +
+ + + +
+
+ + {#if paddingOption === 1} +
+ +
+ {:else} +
+ + + + +
+ {/if} + + +
+ + +
+ { + const color = colors[i]; + return { + label: species + ' 🐧', + key: species, + data, + color, + props: { + stroke: color, + fillOpacity: 0.3 + } + }; + })} + props={{ + xAxis: { + rule: true, + label: 'Flipper Length (mm)', + labelProps: { + dy: -(statePadding.bottom + 5) + } + }, + yAxis: { + rule: true, + label: 'Bill Length (mm)', + labelProps: { + dx: statePadding.left + 5 + } + } + }} + padding={defaultChartPadding({ + axis: axis, + legend: legend, + left: statePadding.left, + right: statePadding.right, + bottom: statePadding.bottom, + top: statePadding.top + })} + height={400} + /> +
diff --git a/packages/layerchart/src/lib/utils/common.ts b/packages/layerchart/src/lib/utils/common.ts index 4d9ee873a..cbfd0721d 100644 --- a/packages/layerchart/src/lib/utils/common.ts +++ b/packages/layerchart/src/lib/utils/common.ts @@ -62,7 +62,7 @@ export function defaultChartPadding