Skip to content

Commit 4ebbb29

Browse files
committed
Fix extent bug in docs & annotation merge
1 parent 10bca0b commit 4ebbb29

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,4 @@
236236
"eslintConfig": {
237237
"extends": "react-app"
238238
}
239-
}
239+
}

src/components/InteractionLayer.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ const generateOEndMappingFn = projectedColumns => (d): null | Array<any> => {
113113
const lastColumn: { x: number; width: number } = foundColumns[
114114
foundColumns.length - 1
115115
] || {
116-
x: 0,
117-
width: 0
118-
}
116+
x: 0,
117+
width: 0
118+
}
119119

120120
const columnPosition = [
121121
firstColumn.x + Math.min(5, firstColumn.width / 10),
@@ -261,7 +261,7 @@ class InteractionLayer extends React.Component<Props, State> {
261261
this.props.interaction.during(e, columnName, data, columnData)
262262
}
263263

264-
brushEnd = (e?: number[] | number[][], columnName?: string, data?: object, columnData?: object ) => {
264+
brushEnd = (e?: number[] | number[][], columnName?: string, data?: object, columnData?: object) => {
265265
if (this.props.interaction && this.props.interaction.end)
266266
this.props.interaction.end(e, columnName, data, columnData)
267267
}
@@ -288,16 +288,20 @@ class InteractionLayer extends React.Component<Props, State> {
288288
: "xBrush"
289289
: interaction.brush
290290

291-
const {
291+
let {
292+
extent
293+
} = interaction
294+
295+
if (!extent) {
292296
extent = actualBrush === "xyBrush"
293297
? [
294-
[xScale.invert(0), yScale.invert(0)],
295-
[xScale.invert(size[0]), yScale.invert(size[1])]
296-
]
298+
[xScale.invert(0), yScale.invert(0)],
299+
[xScale.invert(size[0]), yScale.invert(size[1])]
300+
]
297301
: actualBrush === "xBrush"
298-
? [xScale.invert(0), xScale.invert(size[0])]
299-
: [yScale.invert(0), yScale.invert(size[1])]
300-
} = interaction
302+
? [xScale.invert(0), xScale.invert(size[0])]
303+
: [yScale.invert(0), yScale.invert(size[1])]
304+
}
301305

302306
if (extent.indexOf && extent.indexOf(undefined) !== -1) {
303307
return <g />
@@ -363,7 +367,7 @@ class InteractionLayer extends React.Component<Props, State> {
363367
selectedExtent = [
364368
projectedColumns[leftExtent].x,
365369
projectedColumns[rightExtent].x +
366-
projectedColumns[rightExtent].width
370+
projectedColumns[rightExtent].width
367371
]
368372
}
369373
}
@@ -446,8 +450,8 @@ class InteractionLayer extends React.Component<Props, State> {
446450
showLinePoints && d[whichPoints[showLinePoints]] !== undefined
447451
? d[whichPoints[showLinePoints]]
448452
: d[projectedYMiddle] !== undefined
449-
? d[projectedYMiddle]
450-
: d[projectedY]
453+
? d[projectedYMiddle]
454+
: d[projectedY]
451455
)
452456
)
453457
if (
@@ -653,9 +657,9 @@ class InteractionLayer extends React.Component<Props, State> {
653657
return !d
654658
? null
655659
: [
656-
rScaleReverse(rScale.invert(d[1])),
657-
rScaleReverse(rScale.invert(d[0]))
658-
]
660+
rScaleReverse(rScale.invert(d[1])),
661+
rScaleReverse(rScale.invert(d[0]))
662+
]
659663
}
660664

661665
const rRange = rScale.range()

src/docs/components/CreatingLineChart.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,16 @@ export default class CreatingLineChart extends React.Component {
469469
lines={movies}
470470
lineType={{
471471
type: "line",
472+
y1: () => 0,
472473
interpolator: "monotonex"
473474
}}
474-
lineDataAccessor={["coordinates"]}
475+
annotations={[{
476+
type: "highlight",
477+
title: "Ex Machina",
478+
style: { fill: "red", stroke: "purple" }
479+
}]}
480+
lineIDAccessor={"title"}
481+
lineDataAccessor={"coordinates"}
475482
xAccessor={["week"]}
476483
yAccessor={["theaterCount"]}
477484
lineStyle={d => ({

0 commit comments

Comments
 (0)