Skip to content

Commit 72fae8d

Browse files
authored
no implicit round (#302)
1 parent 0565f63 commit 72fae8d

72 files changed

Lines changed: 3237 additions & 3244 deletions

File tree

Some content is hidden

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

src/axis.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {axisTop, axisBottom, axisRight, axisLeft} from "d3";
2-
import {interpolateRound} from "d3";
32
import {create} from "d3";
43

54
export class AxisX {
@@ -60,7 +59,7 @@ export class AxisX {
6059
const ty = offsetSign * offset + (axis === "top" ? marginTop : height - marginBottom);
6160
return create("svg:g")
6261
.attr("transform", `translate(0,${ty})`)
63-
.call((axis === "top" ? axisTop : axisBottom)(round(x))
62+
.call((axis === "top" ? axisTop : axisBottom)(x)
6463
.ticks(Array.isArray(ticks) ? null : ticks, typeof tickFormat === "function" ? null : tickFormat)
6564
.tickFormat(typeof tickFormat === "function" || !x.tickFormat ? tickFormat : null)
6665
.tickSizeInner(tickSize)
@@ -145,7 +144,7 @@ export class AxisY {
145144
const tx = offsetSign * offset + (axis === "right" ? width - marginRight : marginLeft);
146145
return create("svg:g")
147146
.attr("transform", `translate(${tx},0)`)
148-
.call((axis === "right" ? axisRight : axisLeft)(round(y))
147+
.call((axis === "right" ? axisRight : axisLeft)(y)
149148
.ticks(Array.isArray(ticks) ? null : ticks, typeof tickFormat === "function" ? null : tickFormat)
150149
.tickFormat(typeof tickFormat === "function" || !y.tickFormat ? tickFormat : null)
151150
.tickSizeInner(tickSize)
@@ -176,12 +175,6 @@ export class AxisY {
176175
}
177176
}
178177

179-
function round(scale) {
180-
return scale.interpolate // TODO round band and point scales?
181-
? scale.copy().interpolate(interpolateRound)
182-
: scale;
183-
}
184-
185178
function gridX(y2) {
186179
return g => g.selectAll(".tick line")
187180
.clone(true)

src/marks/rule.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export class RuleX extends Mark {
4747
.data(index)
4848
.join("line")
4949
.call(applyDirectStyles, this)
50-
.attr("x1", X ? i => Math.round(X[i]) : (marginLeft + width - marginRight) / 2)
51-
.attr("x2", X ? i => Math.round(X[i]) : (marginLeft + width - marginRight) / 2)
50+
.attr("x1", X ? i => X[i] : (marginLeft + width - marginRight) / 2)
51+
.attr("x2", X ? i => X[i] : (marginLeft + width - marginRight) / 2)
5252
.attr("y1", Y1 ? i => Y1[i] : marginTop)
5353
.attr("y2", Y2 ? (y.bandwidth ? i => Y2[i] + y.bandwidth() : i => Y2[i]) : height - marginBottom)
5454
.attr("stroke", S && (i => S[i]))
@@ -102,8 +102,8 @@ export class RuleY extends Mark {
102102
.call(applyDirectStyles, this)
103103
.attr("x1", X1 ? i => X1[i] : marginLeft)
104104
.attr("x2", X2 ? (x.bandwidth ? i => X2[i] + x.bandwidth() : i => X2[i]) : width - marginRight)
105-
.attr("y1", Y ? i => Math.round(Y[i]) : (marginTop + height - marginBottom) / 2)
106-
.attr("y2", Y ? i => Math.round(Y[i]) : (marginTop + height - marginBottom) / 2)
105+
.attr("y1", Y ? i => Y[i] : (marginTop + height - marginBottom) / 2)
106+
.attr("y2", Y ? i => Y[i] : (marginTop + height - marginBottom) / 2)
107107
.attr("stroke", S && (i => S[i]))
108108
.call(title(L)))
109109
.node();

src/marks/tick.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export class TickX extends AbstractTick {
6464
selection.call(applyTransform, x, null, 0.5, 0);
6565
}
6666
_x1(scales, {x: X}) {
67-
return i => Math.round(X[i]);
67+
return i => X[i];
6868
}
6969
_x2(scales, {x: X}) {
70-
return i => Math.round(X[i]);
70+
return i => X[i];
7171
}
7272
_y1(scales, {y: Y}, {marginTop}) {
7373
return Y ? i => Y[i] : marginTop;
@@ -98,10 +98,10 @@ export class TickY extends AbstractTick {
9898
return X ? i => X[i] + x.bandwidth() : width - marginRight;
9999
}
100100
_y1(scales, {y: Y}) {
101-
return i => Math.round(Y[i]);
101+
return i => Y[i];
102102
}
103103
_y2(scales, {y: Y}) {
104-
return i => Math.round(Y[i]);
104+
return i => Y[i];
105105
}
106106
}
107107

test/output/aaplCandlestick.svg

Lines changed: 250 additions & 250 deletions
Loading

test/output/aaplChangeVolume.svg

Lines changed: 23 additions & 23 deletions
Loading

test/output/aaplClose.svg

Lines changed: 14 additions & 14 deletions
Loading

test/output/aaplVolume.svg

Lines changed: 8 additions & 8 deletions
Loading

0 commit comments

Comments
 (0)