diff --git a/demo/brush-with-arguments-1d-multi.html b/demo/brush-with-arguments-1d-multi.html
new file mode 100644
index 0000000..d60eddc
--- /dev/null
+++ b/demo/brush-with-arguments-1d-multi.html
@@ -0,0 +1,64 @@
+
+
+
+
+
+Brushing Example
+
+
+
+
+
+Loads an external csv file, creates a custom quantitative color scale
+ using L*a*b interpolation, and enables brushing.
+
+
Brush Debug
+
+
+
+
+
+
+
+
+
diff --git a/demo/brush-with-arguments.html b/demo/brush-with-arguments.html
index fabab19..f7b2217 100644
--- a/demo/brush-with-arguments.html
+++ b/demo/brush-with-arguments.html
@@ -47,7 +47,7 @@ Brush Debug
})
.on("brushend", function(brushed, args){
if(args !== undefined && Object.keys(this.brushExtents()).length > 0) {
- var brush_selection = args.selection
+ var brush_selection = args.selection;
d3.select("#brush-results").html([
'brush end',
'dimension: ' + args.axis,
diff --git a/demo/index.html b/demo/index.html
index a003e1c..ac1c8f6 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -94,6 +94,9 @@ Demo
brush with arguments
+
+ brush with arguments (1d multi)
+
snapshot
diff --git a/package.json b/package.json
index e4873ef..84b67e2 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"test": "mocha",
"test:cover": "babel-node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha",
"prepare": "npm test",
- "pretty": "prettier --single-quote --trailing-comma es5 --write \"{src,__{tests,demo,dist}__}/**/*.js\""
+ "format": "prettier --single-quote --trailing-comma es5 --write \"{src,__{tests,demo,dist}__}/**/*.{js,html}\""
},
"files": [
"src",
diff --git a/src/brush/1d-multi/brushExtents.js b/src/brush/1d-multi/brushExtents.js
index 8f053d3..bd2e03c 100644
--- a/src/brush/1d-multi/brushExtents.js
+++ b/src/brush/1d-multi/brushExtents.js
@@ -2,6 +2,7 @@ import { select } from 'd3-selection';
import { brushSelection } from 'd3-brush';
import newBrush from './newBrush';
import drawBrushes from './drawBrushes';
+import invertByScale from '../invertByScale';
/**
*
@@ -23,13 +24,22 @@ const brushExtents = (state, config, pc, events, brushGroup) => extents => {
acc[cur] = [];
} else {
acc[cur] = axisBrushes.reduce((d, p, i) => {
- const range = brushSelection(
+ const raw = brushSelection(
document.getElementById('brush-' + pos + '-' + i)
);
- if (range !== null) {
- d = d.push(range);
- }
+ if (raw) {
+ const yScale = config.dimensions[cur].yscale;
+ const scaled = invertByScale(raw, yScale);
+
+ d.push({
+ extent: p.brush.extent(),
+ selection: {
+ raw,
+ scaled,
+ },
+ });
+ }
return d;
}, []);
}