diff --git a/package-lock.json b/package-lock.json index 9dea1102..7744760b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "d3-hierarchy": "^3.1.1", "d3-quadtree": "^3.0.1", "d3-sankey": "^0.12.3", + "d3-scale-chromatic": "^3.0.0", "d3-time": "^3.0.0", "d3-time-format": "^4.1.0", "degit": "^2.8.4", @@ -1477,6 +1478,19 @@ "node": ">=12" } }, + "node_modules/d3-scale-chromatic": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.0.0.tgz", + "integrity": "sha512-Lx9thtxAKrO2Pq6OO2Ua474opeziKr279P/TKZsMAhYyNDD3EnCffdbgeSYN5O7m2ByQsxtuP2CSDczNUIZ22g==", + "dev": true, + "dependencies": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/d3-shape": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", @@ -5189,6 +5203,16 @@ "d3-time-format": "2 - 4" } }, + "d3-scale-chromatic": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/d3-scale-chromatic/-/d3-scale-chromatic-3.0.0.tgz", + "integrity": "sha512-Lx9thtxAKrO2Pq6OO2Ua474opeziKr279P/TKZsMAhYyNDD3EnCffdbgeSYN5O7m2ByQsxtuP2CSDczNUIZ22g==", + "dev": true, + "requires": { + "d3-color": "1 - 3", + "d3-interpolate": "1 - 3" + } + }, "d3-shape": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz", diff --git a/package.json b/package.json index 9917307a..af0c1465 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "d3-hierarchy": "^3.1.1", "d3-quadtree": "^3.0.1", "d3-sankey": "^0.12.3", + "d3-scale-chromatic": "^3.0.0", "d3-time": "^3.0.0", "d3-time-format": "^4.1.0", "degit": "^2.8.4", diff --git a/src/_components/ColorBar.html.svelte b/src/_components/ColorBar.html.svelte new file mode 100644 index 00000000..70be08cf --- /dev/null +++ b/src/_components/ColorBar.html.svelte @@ -0,0 +1,191 @@ + + + +
+ {#if label}{label}{/if} +
+
+
+ {#each tickVals as tick_label, i} + {#if tickMarks === true} +
+ {/if} + + {formatTick(tick_label)} + + {/each} +
+
+
+ + diff --git a/src/routes/_components.js b/src/routes/_components.js index 26be9403..0f933c51 100644 --- a/src/routes/_components.js +++ b/src/routes/_components.js @@ -19,6 +19,7 @@ import CirclePack from './_components/CirclePack.svelte'; import CirclePackForce from './_components/CirclePackForce.svelte'; import ClevelandDotPlot from './_components/ClevelandDotPlot.svelte'; import ClevelandDotPlotHtml from './_components/ClevelandDotPlot.html.svelte'; +import ColorBar from './_components_ssr/ColorBar.html.svelte'; import Column from './_components/Column.svelte'; import ColumnStacked from './_components/ColumnStacked.svelte'; import Line from './_components/Line.svelte'; @@ -115,5 +116,6 @@ export default [ { slug: 'Key.html.svelte', component: Key }, { slug: 'Labels.html.svelte', component: Labels }, { slug: 'GroupLabels.html.svelte', component: GroupLabels }, + { slug: 'ColorBar.html.svelte', component: ColorBar }, ] } ]; diff --git a/src/routes/_components_ssr/ColorBar.html.svelte b/src/routes/_components_ssr/ColorBar.html.svelte new file mode 100644 index 00000000..d094f56d --- /dev/null +++ b/src/routes/_components_ssr/ColorBar.html.svelte @@ -0,0 +1,125 @@ + + +
+ + + d * 100} {tickSide} {snapTicks} {tickMarks} ticks={nTicks} --cbar-width="{cbarWidth}%" /> + + +
+ +
+
+ + {cbarWidth}% +
+ + +
+ + +
+
+ + +
+ +
+
tick side:
+ +
+ +
+
label side:
+ +
+
+
scale:
+ +
+
+ + + diff --git a/src/routes/_components_ssr/Key.html.svelte b/src/routes/_components_ssr/Key.html.svelte index 2b69ecc6..c8d823f9 100644 --- a/src/routes/_components_ssr/Key.html.svelte +++ b/src/routes/_components_ssr/Key.html.svelte @@ -43,6 +43,7 @@