Skip to content

Commit 04535d5

Browse files
committed
back to individual paths, will allow selection (to vary the stroke-dasharray) and transitions (which is why we pass the unscaled ticks).
1 parent e03b7e5 commit 04535d5

File tree

78 files changed

+2307
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2307
-201
lines changed

src/axis.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class AxisX {
7070
.call(!grid ? () => {}
7171
: createGridX(
7272
grid(x, ticks),
73+
x,
7374
fy ? fy.bandwidth() : offsetSign * (marginBottom + marginTop - height),
7475
fy ? take(fy.domain().map(d => fy(d) - ty), index) : [0]
7576
))
@@ -159,6 +160,7 @@ export class AxisY {
159160
.call(!grid ? () => {}
160161
: createGridY(
161162
grid(y, ticks),
163+
y,
162164
fx ? fx.bandwidth() : offsetSign * (marginLeft + marginRight - width),
163165
fx ? take(fx.domain().map(d => fx(d) - tx), index) : [0]
164166
))
@@ -229,28 +231,36 @@ function maybeTickRotate(g, rotate) {
229231
}
230232
}
231233

232-
function createGridX(ticks, dy, steps) {
234+
function createGridX(ticks, x, dy, steps) {
233235
return g => g.append("g")
234236
.attr("class", "grid")
235237
.selectAll()
236238
.data(steps)
237-
.join("path")
238-
.attr("d", v => ticks.map(d => `M${offset + d},${v}v${dy}`).join(""));
239+
.join("g")
240+
.attr("transform", v => `translate(${offset},${v})`)
241+
.selectAll()
242+
.data(ticks)
243+
.join("path")
244+
.attr("d", d => `M${x(d)},0v${dy}`);
239245
}
240246

241-
function createGridY(ticks, dx, steps) {
247+
function createGridY(ticks, y, dx, steps) {
242248
return g => g.append("g")
243249
.attr("class", "grid")
244250
.selectAll()
245251
.data(steps)
246-
.join("path")
247-
.attr("d", v => ticks.map(d => `M${v},${offset + d}h${dx}`).join(""));
252+
.join("g")
253+
.attr("transform", v => `translate(${v},${offset})`)
254+
.selectAll()
255+
.data(ticks)
256+
.join("path")
257+
.attr("d", d => `M0,${y(d)}h${dx}`);
248258
}
249259

250260
function maybeTicks(grid) {
251261
if (!grid) return false;
252-
if (grid === true) return (scale, ticks) => (scale.ticks ? scale.ticks(ticks) : scale.domain()).map(scale);
253-
if (Array.isArray(grid)) return (scale) => grid.map(scale);
254-
if (grid === +grid) return (scale) => (scale.ticks ? scale.ticks.apply(scale, [grid]) : scale.domain()).map(scale);
262+
if (grid === true) return (scale, ticks) => (scale.ticks ? scale.ticks(ticks) : scale.domain());
263+
if (Array.isArray(grid)) return () => grid;
264+
if (grid === +grid) return (scale) => (scale.ticks ? scale.ticks.apply(scale, [grid]) : scale.domain());
255265
throw new Error(`Unexpected grid option: ${grid}`);
256266
}

test/output/aaplBollinger.svg

Lines changed: 16 additions & 1 deletion
Loading

test/output/aaplCandlestick.svg

Lines changed: 18 additions & 2 deletions
Loading

test/output/aaplChangeVolume.svg

Lines changed: 26 additions & 2 deletions
Loading

test/output/aaplClose.svg

Lines changed: 12 additions & 1 deletion
Loading

test/output/aaplCloseUntyped.svg

Lines changed: 12 additions & 1 deletion
Loading

test/output/aaplVolume.svg

Lines changed: 11 additions & 1 deletion
Loading

test/output/aaplVolumeRect.svg

Lines changed: 16 additions & 1 deletion
Loading

test/output/anscombeQuartet.svg

Lines changed: 48 additions & 8 deletions
Loading

0 commit comments

Comments
 (0)