diff --git a/src/_components/AxisX.html.svelte b/src/_components/AxisX.html.svelte deleted file mode 100644 index 81313c04..00000000 --- a/src/_components/AxisX.html.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - - -
- {#each tickVals as tick, i (tick)} - {#if gridlines !== false} -
- {/if} - {#if tickMarks === true} -
- {/if} -
-
{formatTick(tick)}
-
- {/each} - {#if baseline === true} -
- {/if} -
- - diff --git a/src/_components/AxisX.percent-range.html.svelte b/src/_components/AxisX.percent-range.html.svelte new file mode 100644 index 00000000..7ab3b5e2 --- /dev/null +++ b/src/_components/AxisX.percent-range.html.svelte @@ -0,0 +1,131 @@ + + + +
+ {#each tickVals as tick, i (tick)} + {@const tickValPx = $xScale(tick)} + + {#if baseline === true} +
+ {/if} + + {#if gridlines === true} +
+ {/if} + {#if tickMarks === true} +
+ {/if} +
+
{format(tick)}
+
+ {/each} +
+ + diff --git a/src/_components/AxisX.svelte b/src/_components/AxisX.svelte index e45c34d0..91990390 100644 --- a/src/_components/AxisX.svelte +++ b/src/_components/AxisX.svelte @@ -4,43 +4,41 @@ --> - + {#each tickVals as tick, i (tick)} + {#if baseline === true} + + {/if} + - {#if gridlines !== false} - + {#if gridlines === true} + {/if} {#if tickMarks === true} {/if} {formatTick(tick)}{format(tick)} {/each} - {#if baseline === true} - - {/if} diff --git a/src/_components/AxisXTop.percent-range.html.svelte b/src/_components/AxisXTop.percent-range.html.svelte new file mode 100644 index 00000000..595faf56 --- /dev/null +++ b/src/_components/AxisXTop.percent-range.html.svelte @@ -0,0 +1,132 @@ + + + +
+ {#each tickVals as tick, i (tick)} + {@const tickValPx = $xScale(tick)} + + {#if baseline === true} +
+ {/if} + + {#if gridlines === true} +
+ {/if} + {#if tickMarks === true} +
+ {/if} +
+
{format(tick)}
+
+ {/each} +
+ + diff --git a/src/_components/AxisXTop.svelte b/src/_components/AxisXTop.svelte new file mode 100644 index 00000000..35106c21 --- /dev/null +++ b/src/_components/AxisXTop.svelte @@ -0,0 +1,130 @@ + + + + + {#each tickVals as tick, i (tick)} + {#if baseline === true} + + {/if} + + + {#if gridlines === true} + + {/if} + {#if tickMarks === true} + + {/if} + {format(tick)} + + {/each} + + + diff --git a/src/_components/AxisY.html.svelte b/src/_components/AxisY.html.svelte deleted file mode 100644 index 48037a00..00000000 --- a/src/_components/AxisY.html.svelte +++ /dev/null @@ -1,98 +0,0 @@ - - - -
- {#each tickVals as tick, i (tick)} -
- {#if gridlines !== false} -
- {/if} - {#if baseline !== false && i === 0} -
- {/if} - {#if tickMarks === true} -
- {/if} -
{formatTick(tick)}
-
- {/each} -
- - diff --git a/src/_components/AxisY.percent-range.html.svelte b/src/_components/AxisY.percent-range.html.svelte new file mode 100644 index 00000000..6f9d2866 --- /dev/null +++ b/src/_components/AxisY.percent-range.html.svelte @@ -0,0 +1,136 @@ + + + +
+ {#each tickVals as tick, i (tick)} + {@const tickValPx = $yScale(tick)} + +
+ {#if gridlines === true} +
+ {/if} + {#if tickMarks === true} +
+ {/if} +
{format(tick)}
+
+ {/each} +
+ + diff --git a/src/_components/AxisY.svelte b/src/_components/AxisY.svelte index 38439862..0393dd45 100644 --- a/src/_components/AxisY.svelte +++ b/src/_components/AxisY.svelte @@ -1,38 +1,44 @@ - + {#each tickVals as tick (tick)} - - {#if gridlines !== false} + {@const tickValPx = $yScale(tick)} + + {#if gridlines === true} {/if} {#if tickMarks === true} {/if} {formatTick(tick)} + x='{x1}' + {y} + dx={dx + (labelPosition === 'even' ? -3 : 0)} + text-anchor={labelPosition === 'above' ? 'start' : 'end'} + dy='{dy + (labelPosition === 'above' || (snapBaselineLabel === true && tickValPx === maxTickValPx) ? -3 : 4)}' + >{format(tick)} {/each} diff --git a/src/_components/AxisYRight.svelte b/src/_components/AxisYRight.svelte new file mode 100644 index 00000000..a67d9fd7 --- /dev/null +++ b/src/_components/AxisYRight.svelte @@ -0,0 +1,123 @@ + + + + + {#each tickVals as tick (tick)} + {@const tickValPx = $yScale(tick)} + + {#if gridlines === true} + + {/if} + {#if tickMarks === true} + + {/if} + + {format(tick)} + + {/each} + + + diff --git a/src/_components/SyncedBrushWrapper.percent-range.svelte b/src/_components/SyncedBrushWrapper.percent-range.svelte index 886c24e6..bc8f90fa 100644 --- a/src/_components/SyncedBrushWrapper.percent-range.svelte +++ b/src/_components/SyncedBrushWrapper.percent-range.svelte @@ -3,8 +3,8 @@ import Line from './Line.svelte'; import Area from './Area.svelte'; - import AxisX from './AxisX.html.svelte'; - import AxisY from './AxisY.html.svelte'; + import AxisX from './AxisX.percent-range.html.svelte'; + import AxisY from './AxisY.percent-range.html.svelte'; import Brush from './Brush.html.svelte'; export let min = null; diff --git a/src/routes/_components.js b/src/routes/_components.js index 26be9403..0e4cf255 100644 --- a/src/routes/_components.js +++ b/src/routes/_components.js @@ -6,7 +6,9 @@ import AreaD3 from './_components/Area-D3.svelte'; import AreaStacked from './_components/AreaStacked.svelte'; import AxisRadial from './_components/AxisRadial.svelte'; import AxisX from './_components/AxisX.svelte'; +import AxisXTop from './_components/AxisXTop.svelte'; import AxisY from './_components/AxisY.svelte'; +import AxisYRight from './_components/AxisYRight.svelte'; import Bar from './_components/Bar.svelte'; import BarStacked from './_components/BarStacked.svelte'; import Beeswarm from './_components/Beeswarm.svelte'; @@ -43,22 +45,31 @@ import Tooltip from './_components/Tooltip.html.svelte'; import SharedTooltip from './_components/SharedTooltip.html.svelte'; import SharedTooltipPercentRange from './_components_ssr/SharedTooltip.percent-range.html.svelte'; import AxisXHtml from './_components_ssr/AxisX.html.svelte'; +import AxisXTopHtml from './_components_ssr/AxisXTop.html.svelte'; import AxisYHtml from './_components_ssr/AxisY.html.svelte'; +import AxisYRightHtml from './_components_ssr/AxisYRight.html.svelte'; import ScatterHtml from './_components_ssr/Scatter.html.svelte'; import Key from './_components_ssr/Key.html.svelte'; import QuadTree from './_components/QuadTree.html.svelte'; import QuadTreePercentRange from './_components_ssr/QuadTree.percent-range.html.svelte'; export default [ - { name: 'axis', + { + name: 'axis', components: [ { slug: 'AxisX.svelte', component: AxisX }, { slug: 'AxisY.svelte', component: AxisY }, - { slug: 'AxisX.html.svelte', component: AxisXHtml }, - { slug: 'AxisY.html.svelte', component: AxisYHtml }, - { slug: 'AxisRadial.svelte', component: AxisRadial }, - ] }, - { name: 'chart', + { slug: 'AxisYRight.svelte', component: AxisYRight }, + { slug: 'AxisXTop.svelte', component: AxisXTop }, + { slug: 'AxisX.percent-range.html.svelte', component: AxisXHtml }, + { slug: 'AxisXTop.percent-range.html.svelte', component: AxisXTopHtml }, + { slug: 'AxisY.percent-range.html.svelte', component: AxisYHtml }, + { slug: 'AxisYRight.percent-range.html.svelte', component: AxisYRightHtml }, + { slug: 'AxisRadial.svelte', component: AxisRadial } + ] + }, + { + name: 'chart', components: [ { slug: 'Area.svelte', component: Area }, { slug: 'Area-D3.svelte', component: AreaD3 }, @@ -85,9 +96,11 @@ export default [ { slug: 'Scatter.canvas.svelte', component: ScatterCanvas }, { slug: 'Scatter.svg.svelte', component: ScatterSvg }, { slug: 'Scatter.webgl.svelte', component: ScatterWebgl }, - { slug: 'Scatter.html.svelte', component: ScatterHtml }, - ] }, - { name: 'map', + { slug: 'Scatter.html.svelte', component: ScatterHtml } + ] + }, + { + name: 'map', components: [ { slug: 'Map.svg.svelte', component: MapSvg }, { slug: 'Map.canvas.svelte', component: MapCanvas }, @@ -95,9 +108,11 @@ export default [ { slug: 'MapPoints.html.svelte', component: MapPointsHtml }, { slug: 'MapPoints.canvas.svelte', component: MapPointsCanvas }, { slug: 'MapLabels.html.svelte', component: MapLabelsHtml }, - { slug: 'MapLabels.svg.svelte', component: MapLabels }, - ] }, - { name: 'interaction', + { slug: 'MapLabels.svg.svelte', component: MapLabels } + ] + }, + { + name: 'interaction', components: [ { slug: 'Voronoi.svelte', component: Voronoi }, { slug: 'Brush.html.svelte', component: Brush }, @@ -105,15 +120,18 @@ export default [ { slug: 'QuadTree.percent-range.html.svelte', component: QuadTreePercentRange }, { slug: 'Tooltip.html.svelte', component: Tooltip }, { slug: 'SharedTooltip.html.svelte', component: SharedTooltip }, - { slug: 'SharedTooltip.percent-range.html.svelte', component: SharedTooltipPercentRange }, - ] }, - { name: 'annotation', + { slug: 'SharedTooltip.percent-range.html.svelte', component: SharedTooltipPercentRange } + ] + }, + { + name: 'annotation', components: [ { slug: 'Annotations.html.svelte', component: Annotations }, { slug: 'AnnotationsData.html.svelte', component: AnnotationsData }, { slug: 'Arrows.svelte', component: Arrows }, { slug: 'Key.html.svelte', component: Key }, { slug: 'Labels.html.svelte', component: Labels }, - { slug: 'GroupLabels.html.svelte', component: GroupLabels }, - ] } + { slug: 'GroupLabels.html.svelte', component: GroupLabels } + ] + } ]; diff --git a/src/routes/_components/AxisX.svelte b/src/routes/_components/AxisX.svelte index 67f33aed..47d3895d 100644 --- a/src/routes/_components/AxisX.svelte +++ b/src/routes/_components/AxisX.svelte @@ -12,9 +12,24 @@ data.forEach(d => { d[yKey] = +d[yKey]; }); + + let tickMarks = false; + let gridlines = true; + let snapLabels = false; + let baseline = true; + let tickMarkLength = 6; + let tickGutter = 0; + let dx = 0; + let dy = 12; -
- - - - - +
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + +
diff --git a/src/routes/_components/AxisXTop.svelte b/src/routes/_components/AxisXTop.svelte new file mode 100644 index 00000000..a7bfac08 --- /dev/null +++ b/src/routes/_components/AxisXTop.svelte @@ -0,0 +1,137 @@ + + + + +
+
+ + + + + + + + + + + + + + +
+ +
+ + + + + +
+
diff --git a/src/routes/_components/AxisY.svelte b/src/routes/_components/AxisY.svelte index 9fbcd99e..a05521f7 100644 --- a/src/routes/_components/AxisY.svelte +++ b/src/routes/_components/AxisY.svelte @@ -12,9 +12,24 @@ data.forEach(d => { d[yKey] = +d[yKey]; }); + + let tickMarks = false; + let snapBaselineLabel = false; + let gridlines = true; + let labelPosition = 'above'; + let tickMarkLength = undefined; + let tickGutter = 0; + let dx = 0; + let dy = 0; -
- - - - - +
+
+ + + + + + + + + + + + +
+ +
+ + + + + +
diff --git a/src/routes/_components/AxisYRight.svelte b/src/routes/_components/AxisYRight.svelte new file mode 100644 index 00000000..27b6c4dc --- /dev/null +++ b/src/routes/_components/AxisYRight.svelte @@ -0,0 +1,140 @@ + + + + +
+
+ + + + + + + + + + + + +
+ +
+ + + + + +
+
diff --git a/src/routes/_components/GroupLabels.html.svelte b/src/routes/_components/GroupLabels.html.svelte index 761ab0ea..01f6ce84 100644 --- a/src/routes/_components/GroupLabels.html.svelte +++ b/src/routes/_components/GroupLabels.html.svelte @@ -42,9 +42,6 @@ const flatten = data => data.reduce((memo, group) => { return memo.concat(group.values); }, []); - - const formatTickX = timeFormat('%b. %e'); - const formatTickY = d => format(`~s`)(d); -
- d[yKey]} - yDomain={[0, null]} - data={data} - > - - - - +
+
+ + + + + + + + + + + + + + +
+ +
+ d[yKey]} + yDomain={[0, null]} + data={data} + > + + + + +
diff --git a/src/routes/_components_ssr/AxisXTop.html.svelte b/src/routes/_components_ssr/AxisXTop.html.svelte new file mode 100644 index 00000000..bc2588ad --- /dev/null +++ b/src/routes/_components_ssr/AxisXTop.html.svelte @@ -0,0 +1,139 @@ + + + + +
+
+ + + + + + + + + + + + + + +
+ +
+ d[yKey]} + {data} + > + + + + +
+
diff --git a/src/routes/_components_ssr/AxisY.html.svelte b/src/routes/_components_ssr/AxisY.html.svelte index 55acbd7b..d757bdbb 100644 --- a/src/routes/_components_ssr/AxisY.html.svelte +++ b/src/routes/_components_ssr/AxisY.html.svelte @@ -1,7 +1,7 @@ -
- d[yKey]} - yDomain={[0, null]} - data={data} - > - - +
+ + + + + + + + + + + + +
+ +
+ d[yKey]} + data={data} + > + + - - + + +
diff --git a/src/routes/_components_ssr/AxisYRight.html.svelte b/src/routes/_components_ssr/AxisYRight.html.svelte new file mode 100644 index 00000000..7548aea4 --- /dev/null +++ b/src/routes/_components_ssr/AxisYRight.html.svelte @@ -0,0 +1,142 @@ + + + + +
+
+ + + + + + + + + + + + +
+ +
+ d[yKey]} + data={data} + > + + + + +
+
diff --git a/src/routes/_components_ssr/SharedTooltip.percent-range.html.svelte b/src/routes/_components_ssr/SharedTooltip.percent-range.html.svelte index c945c311..f4bfb0a3 100644 --- a/src/routes/_components_ssr/SharedTooltip.percent-range.html.svelte +++ b/src/routes/_components_ssr/SharedTooltip.percent-range.html.svelte @@ -43,8 +43,8 @@ return memo.concat(group.values); }, []); - const formatTickX = timeFormat('%b. %e'); - const formatTickY = d => format(`~s`)(d); + const formatLabelX = timeFormat('%b. %e'); + const formatLabelY = d => format(`~s`)(d);