reset brush on window resize

This commit is contained in:
Colin Megill
2018-05-14 23:01:22 -07:00
parent 82a5bae2ff
commit 2b2bdba8ea
2 changed files with 64 additions and 53 deletions
+43
View File
@@ -0,0 +1,43 @@
// jshint esversion: 6
import styles from "./graph.css";
import _ from "lodash";
import * as globals from "../../globals";
/******************************************
*******************************************
put svg & brush in DOM
*******************************************
******************************************/
export const setupSVGandBrushElements = (
handleBrushSelectAction,
handleBrushDeselectAction,
responsive,
graphPaddingTop
) => {
const side = responsive.height - graphPaddingTop;
const svg = d3
.select("#graphAttachPoint")
.append("svg")
.attr("width", side)
.attr("height", side)
.attr("class", `${styles.graphSVG}`);
svg.append("g").call(
d3
.brush()
.extent([
[0, 0],
[
responsive.height - graphPaddingTop,
responsive.height - graphPaddingTop
]
])
.on("brush", handleBrushSelectAction)
.on("end", handleBrushDeselectAction)
);
return {
svg
};
};