@d3fc/d3fc-brush
Advanced tools
Comparing version 2.0.84 to 2.1.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-scale'), require('d3-dispatch'), require('d3-brush')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-scale', 'd3-dispatch', 'd3-brush'], factory) : | ||
(global = global || self, factory(global.fc = global.fc || {}, global.d3, global.d3, global.d3, global.d3)); | ||
}(this, function (exports, d3Selection, d3Scale, d3Dispatch, d3Brush) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-scale'), require('d3-dispatch'), require('@d3fc/d3fc-rebind'), require('@d3fc/d3fc-data-join'), require('d3-brush')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-scale', 'd3-dispatch', '@d3fc/d3fc-rebind', '@d3fc/d3fc-data-join', 'd3-brush'], factory) : | ||
(global = global || self, factory(global.fc = global.fc || {}, global.d3, global.d3, global.d3, global.fc, global.fc, global.d3)); | ||
}(this, function (exports, d3Selection, d3Scale, d3Dispatch, d3fcRebind, d3fcDataJoin, d3Brush) { 'use strict'; | ||
var createReboundMethod = ((target, source, name) => { | ||
const method = source[name]; | ||
if (typeof method !== 'function') { | ||
throw new Error(`Attempt to rebind ${name} which isn't a function on the source object`); | ||
} | ||
return (...args) => { | ||
var value = method.apply(source, args); | ||
return value === source ? target : value; | ||
}; | ||
}); | ||
var rebind = ((target, source, ...names) => { | ||
for (const name of names) { | ||
target[name] = createReboundMethod(target, source, name); | ||
} | ||
return target; | ||
}); | ||
// "Caution: avoid interpolating to or from the number zero when the interpolator is used to generate | ||
// a string (such as with attr). | ||
// Very small values, when stringified, may be converted to scientific notation and | ||
// cause a temporarily invalid attribute or style property value. | ||
// For example, the number 0.0000001 is converted to the string "1e-7". | ||
// This is particularly noticeable when interpolating opacity values. | ||
// To avoid scientific notation, start or end the transition at 1e-6, | ||
// which is the smallest value that is not stringified in exponential notation." | ||
// - https://github.com/mbostock/d3/wiki/Transitions#d3_interpolateNumber | ||
const effectivelyZero = 1e-6; // Wrapper around d3's selectAll/data data-join, which allows decoration of the result. | ||
// This is achieved by appending the element to the enter selection before exposing it. | ||
// A default transition of fade in/out is also implicitly added but can be modified. | ||
var dataJoin = ((element, className) => { | ||
element = element || 'g'; | ||
let key = (_, i) => i; | ||
let explicitTransition = null; | ||
const dataJoin = function (container, data) { | ||
data = data || (d => d); | ||
const implicitTransition = container.selection ? container : null; | ||
if (implicitTransition) { | ||
container = container.selection(); | ||
} | ||
const selected = container.selectAll((d, i, nodes) => Array.from(nodes[i].childNodes).filter(node => node.nodeType === 1)).filter(className == null ? element : `${element}.${className}`); | ||
let update = selected.data(data, key); | ||
const enter = update.enter().append(element).attr('class', className); | ||
let exit = update.exit(); // automatically merge in the enter selection | ||
update = update.merge(enter); // if transitions are enabled apply a default fade in/out transition | ||
const transition = implicitTransition || explicitTransition; | ||
if (transition) { | ||
update = update.transition(transition).style('opacity', 1); | ||
enter.style('opacity', effectivelyZero); | ||
exit = exit.transition(transition).style('opacity', effectivelyZero); | ||
} | ||
exit.remove(); | ||
update.enter = () => enter; | ||
update.exit = () => exit; | ||
return update; | ||
}; | ||
dataJoin.element = (...args) => { | ||
if (!args.length) { | ||
return element; | ||
} | ||
element = args[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.className = (...args) => { | ||
if (!args.length) { | ||
return className; | ||
} | ||
className = args[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.key = (...args) => { | ||
if (!args.length) { | ||
return key; | ||
} | ||
key = args[0]; | ||
return dataJoin; | ||
}; | ||
dataJoin.transition = (...args) => { | ||
if (!args.length) { | ||
return explicitTransition; | ||
} | ||
explicitTransition = args[0]; | ||
return dataJoin; | ||
}; | ||
return dataJoin; | ||
}); | ||
var brushForOrient = function brushForOrient(orient) { | ||
@@ -142,3 +29,3 @@ switch (orient) { | ||
var yScale = d3Scale.scaleIdentity(); | ||
var innerJoin = dataJoin('g', 'brush'); | ||
var innerJoin = d3fcDataJoin.dataJoin('g', 'brush'); | ||
@@ -239,4 +126,4 @@ var mapSelection = function mapSelection(selection, xMapping, yMapping) { | ||
rebind(base, eventDispatch, 'on'); | ||
rebind(base, brush, 'filter', 'handleSize'); | ||
d3fcRebind.rebind(base, eventDispatch, 'on'); | ||
d3fcRebind.rebind(base, brush, 'filter', 'handleSize'); | ||
return base; | ||
@@ -243,0 +130,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("d3-selection"),require("d3-scale"),require("d3-dispatch"),require("d3-brush")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-scale","d3-dispatch","d3-brush"],b):(a=a||self,b(a.fc=a.fc||{},a.d3,a.d3,a.d3,a.d3))})(this,function(a,b,c,d,e){'use strict';var f=(a,b,c)=>{const d=b[c];if("function"!=typeof d)throw new Error(`Attempt to rebind ${c} which isn't a function on the source object`);return(...c)=>{var e=d.apply(b,c);return e===b?a:e}},g=(a,b,...c)=>{for(const d of c)a[d]=f(a,b,d);return a};const h=1e-6;var i=(a,b)=>{a=a||"g";let c=(a,b)=>b,d=null;const e=function(e,f){f=f||(a=>a);const g=e.selection?e:null;g&&(e=e.selection());const i=e.selectAll((a,b,c)=>Array.from(c[b].childNodes).filter(a=>1===a.nodeType)).filter(null==b?a:`${a}.${b}`);let j=i.data(f,c);const k=j.enter().append(a).attr("class",b);let l=j.exit();j=j.merge(k);const m=g||d;return m&&(j=j.transition(m).style("opacity",1),k.style("opacity",h),l=l.transition(m).style("opacity",h)),l.remove(),j.enter=()=>k,j.exit=()=>l,j};return e.element=(...b)=>b.length?(a=b[0],e):a,e.className=(...a)=>a.length?(b=a[0],e):b,e.key=(...a)=>a.length?(c=a[0],e):c,e.transition=(...a)=>a.length?(d=a[0],e):d,e},j=function(a){return"x"===a?e.brushX():"y"===a?e.brushY():"xy"===a?e.brush():void 0},k=function(a){return[a[1],a[0]]},l=function(a){var e=j(a),f=d.dispatch("brush","start","end"),h=c.scaleIdentity(),l=c.scaleIdentity(),m=i("g","brush"),n=function(b,c,d){return"x"===a?b.map(c):"y"===a?b.map(d):"xy"===a?[[c(b[0][0]),d(b[0][1])],[c(b[1][0]),d(b[1][1])]]:void 0},o=function(a){return n(a,c.scaleLinear().domain(h.range()).invert,c.scaleLinear().domain(k(l.range())).invert)},p=function(a){return n(a,c.scaleLinear().domain(h.range()),c.scaleLinear().domain(k(l.range())))},q=function(b){var d=c.scaleLinear().domain(h.domain());return"x"===a?b.map(d.invert):"xy"===a?[d.invert(b[0][0]),d.invert(b[1][0])]:void 0},r=function(b){var d=c.scaleLinear().domain(k(l.domain()));return"y"===a?[b[1],b[0]].map(d.invert):"xy"===a?[d.invert(b[1][1]),d.invert(b[0][1])]:void 0},s=function(a){if(!(a.sourceEvent&&"draw"===a.sourceEvent.type))if(a.selection){var b=p(a.selection);f.call(a.type,{},{selection:b,xDomain:q(b),yDomain:r(b)})}else f.call(a.type,{},{})},t=function(a){a.each(function(a,c,d){e.extent([[h.range()[0],l.range()[1]],[h.range()[1],l.range()[0]]]),e.on("end",function(){return s(b.event)}).on("brush",function(){return s(b.event)}).on("start",function(){return s(b.event)});var f=m(b.select(d[c]),[a]);f.call(e).call(e.move,a?o(a):null)})};return t.xScale=function(){return arguments.length?(h=0>=arguments.length?void 0:arguments[0],t):h},t.yScale=function(){return arguments.length?(l=0>=arguments.length?void 0:arguments[0],t):l},g(t,f,"on"),g(t,e,"filter","handleSize"),t};a.brush=function(){return l("xy")},a.brushX=function(){return l("x")},a.brushY=function(){return l("y")},Object.defineProperty(a,"__esModule",{value:!0})}); | ||
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("d3-selection"),require("d3-scale"),require("d3-dispatch"),require("@d3fc/d3fc-rebind"),require("@d3fc/d3fc-data-join"),require("d3-brush")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-scale","d3-dispatch","@d3fc/d3fc-rebind","@d3fc/d3fc-data-join","d3-brush"],b):(a=a||self,b(a.fc=a.fc||{},a.d3,a.d3,a.d3,a.fc,a.fc,a.d3))})(this,function(a,b,c,d,e,f,g){'use strict';var h=function(a){return"x"===a?g.brushX():"y"===a?g.brushY():"xy"===a?g.brush():void 0},i=function(a){return[a[1],a[0]]},j=function(a){var g=h(a),j=d.dispatch("brush","start","end"),k=c.scaleIdentity(),l=c.scaleIdentity(),m=f.dataJoin("g","brush"),n=function(b,c,d){return"x"===a?b.map(c):"y"===a?b.map(d):"xy"===a?[[c(b[0][0]),d(b[0][1])],[c(b[1][0]),d(b[1][1])]]:void 0},o=function(a){return n(a,c.scaleLinear().domain(k.range()).invert,c.scaleLinear().domain(i(l.range())).invert)},p=function(a){return n(a,c.scaleLinear().domain(k.range()),c.scaleLinear().domain(i(l.range())))},q=function(b){var d=c.scaleLinear().domain(k.domain());return"x"===a?b.map(d.invert):"xy"===a?[d.invert(b[0][0]),d.invert(b[1][0])]:void 0},r=function(b){var d=c.scaleLinear().domain(i(l.domain()));return"y"===a?[b[1],b[0]].map(d.invert):"xy"===a?[d.invert(b[1][1]),d.invert(b[0][1])]:void 0},s=function(a){if(!(a.sourceEvent&&"draw"===a.sourceEvent.type))if(a.selection){var b=p(a.selection);j.call(a.type,{},{selection:b,xDomain:q(b),yDomain:r(b)})}else j.call(a.type,{},{})},t=function(a){a.each(function(a,c,d){g.extent([[k.range()[0],l.range()[1]],[k.range()[1],l.range()[0]]]),g.on("end",function(){return s(b.event)}).on("brush",function(){return s(b.event)}).on("start",function(){return s(b.event)});var e=m(b.select(d[c]),[a]);e.call(g).call(g.move,a?o(a):null)})};return t.xScale=function(){return arguments.length?(k=0>=arguments.length?void 0:arguments[0],t):k},t.yScale=function(){return arguments.length?(l=0>=arguments.length?void 0:arguments[0],t):l},e.rebind(t,j,"on"),e.rebind(t,g,"filter","handleSize"),t};a.brush=function(){return j("xy")},a.brushX=function(){return j("x")},a.brushY=function(){return j("y")},Object.defineProperty(a,"__esModule",{value:!0})}); |
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.1.0](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-brush@2.0.84...@d3fc/d3fc-brush@2.1.0) (2020-03-19) | ||
### Features | ||
* add fill to webgl boxplot ([7ea7859](https://github.com/d3fc/d3fc/commit/7ea7859)) | ||
## [2.0.84](https://github.com/d3fc/d3fc/compare/@d3fc/d3fc-brush@2.0.83...@d3fc/d3fc-brush@2.0.84) (2020-02-18) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@d3fc/d3fc-brush", | ||
"version": "2.0.84", | ||
"version": "2.1.0", | ||
"description": "Adapts the D3 brush, making it easier to create data-driven brushed charts.", | ||
@@ -25,9 +25,9 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@d3fc/d3fc-chart": "^3.0.2", | ||
"@d3fc/d3fc-extent": "^3.1.7", | ||
"@d3fc/d3fc-random-data": "^3.0.19", | ||
"@d3fc/d3fc-chart": "^3.1.0", | ||
"@d3fc/d3fc-extent": "^3.2.0", | ||
"@d3fc/d3fc-random-data": "^3.1.0", | ||
"d3": "^4.2.5" | ||
}, | ||
"dependencies": { | ||
"@d3fc/d3fc-data-join": "^5.0.11", | ||
"@d3fc/d3fc-data-join": "^5.1.0", | ||
"@d3fc/d3fc-rebind": "^5.0.10", | ||
@@ -42,3 +42,3 @@ "d3-brush": "^1.0.3", | ||
}, | ||
"gitHead": "6562a4dc0cea7adeb693f94c5844e5be081f53fc" | ||
"gitHead": "8a27597494353a1441a1a71ca06707d9e28c4381" | ||
} |
92623
378
Updated@d3fc/d3fc-data-join@^5.1.0