d3plus-viz
Advanced tools
Comparing version 0.4.3 to 0.4.4
/* | ||
d3plus-viz v0.4.3 | ||
d3plus-viz v0.4.4 | ||
Abstract ES6 class that drives d3plus visualizations. | ||
@@ -258,3 +258,3 @@ Copyright (c) 2016 D3plus - https://d3plus.org | ||
if (shape) newConfig = Object.assign(newConfig, this._shapeConfig[shape]); | ||
if (shape) newConfig = d3plusCommon.assign(newConfig, this._shapeConfig[shape]); | ||
return newConfig; | ||
@@ -441,3 +441,3 @@ | ||
Viz.prototype.aggs = function aggs (_) { | ||
return arguments.length ? (this._aggs = Object.assign(this._aggs, _), this) : this._aggs; | ||
return arguments.length ? (this._aggs = d3plusCommon.assign(this._aggs, _), this) : this._aggs; | ||
}; | ||
@@ -620,3 +620,3 @@ | ||
Viz.prototype.shapeConfig = function shapeConfig (_) { | ||
return arguments.length ? (this._shapeConfig = Object.assign(this._shapeConfig, _), this) : this._shapeConfig; | ||
return arguments.length ? (this._shapeConfig = d3plusCommon.assign(this._shapeConfig, _), this) : this._shapeConfig; | ||
}; | ||
@@ -672,3 +672,3 @@ | ||
Viz.prototype.timelineConfig = function timelineConfig (_) { | ||
return arguments.length ? (this._timelineConfig = Object.assign(this._timelineConfig, _), this) : this._timelineConfig; | ||
return arguments.length ? (this._timelineConfig = d3plusCommon.assign(this._timelineConfig, _), this) : this._timelineConfig; | ||
}; | ||
@@ -691,3 +691,3 @@ | ||
Viz.prototype.tooltipConfig = function tooltipConfig (_) { | ||
return arguments.length ? (this._tooltipConfig = Object.assign(this._tooltipConfig, _), this) : this._tooltipConfig; | ||
return arguments.length ? (this._tooltipConfig = d3plusCommon.assign(this._tooltipConfig, _), this) : this._tooltipConfig; | ||
}; | ||
@@ -694,0 +694,0 @@ |
/* | ||
d3plus-viz v0.4.3 | ||
d3plus-viz v0.4.4 | ||
Abstract ES6 class that drives d3plus visualizations. | ||
@@ -7,2 +7,2 @@ Copyright (c) 2016 D3plus - https://d3plus.org | ||
*/ | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-color"),require("d3-collection"),require("d3-selection"),require("d3-transition"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-common"),require("d3plus-legend"),require("d3plus-text"),require("d3plus-timeline"),require("d3plus-tooltip")):typeof define==="function"&&define.amd?define("d3plus-viz",["exports","d3-array","d3-color","d3-collection","d3-selection","d3-transition","d3plus-axis","d3plus-color","d3plus-common","d3plus-legend","d3plus-text","d3plus-timeline","d3plus-tooltip"],e):e(t.d3plus=t.d3plus||{},t.d3Array,t.d3Color,t.d3Collection,t.d3Selection,t.d3Transition,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.d3plusLegend,t.d3plusText,t.d3plusTimeline,t.d3plusTooltip)})(this,function(t,e,i,n,s,r,o,h,a,l,u,p,d){"use strict";var _=function(t,i,s){if(s===void 0)s=[];if(s&&!(s instanceof Array))s=[s];var r=n.nest().key(i).entries(t);if(r.length<2)return{data:[],id:i};var o,h;if(s.length){var l=r.length;var u=function(i){var u=r.map(function(t){return Array.from(new Set(t.values.map(function(t){return s[i](t)})))}),p=e.sum(u,function(t){return t.length}),d=new Set(e.merge(u)).size;if(p===l&&d===l||i===s.length-1){h=s[i];o=n.nest().key(h).entries(t).map(function(t){return a.merge(t.values)});return"break"}};for(var p=0;p<s.length;p++){var d=u(p);if(d==="break")break}}else{h=i;o=r.map(function(t){return a.merge(t.values)})}return{data:o,id:h}};function f(t,e){if(t.tagName===undefined||["BODY","HTML"].indexOf(t.tagName)>=0){var i=window["inner"+(e.charAt(0).toUpperCase()+e.slice(1))];var n=s.select(t);if(e==="width"){i-=parseFloat(n.style("margin-left"),10);i-=parseFloat(n.style("margin-right"),10);i-=parseFloat(n.style("padding-left"),10);i-=parseFloat(n.style("padding-right"),10)}else{i-=parseFloat(n.style("margin-top"),10);i-=parseFloat(n.style("margin-bottom"),10);i-=parseFloat(n.style("padding-top"),10);i-=parseFloat(n.style("padding-bottom"),10)}return i}else{var r=parseFloat(s.select(t).style(e),10);if(typeof r==="number"&&r>0)return r;else return f(t.parentNode,e)}}var g=function(t){return[f(t,"width"),f(t,"height")]};var c=function(t){function f(){var e=this;t.call(this);this._aggs={};this._backClass=(new u.TextBox).on("click",function(){if(e._history.length)e.config(e._history.pop()).render();else e.depth(e._drawDepth-1).filter(false).render()}).on("mousemove",function(){return e._backClass.select().style("cursor","pointer")});this._data=[];this._duration=600;this._highlightOpacity=.5;this._history=[];this._groupBy=[a.accessor("id")];this._legend=true;this._legendConfig={shapeConfig:{fontResize:false}};this._legendClass=new l.Legend;this._on={click:function(t,i){e._select.style("cursor","auto");if(e._drawDepth<e._groupBy.length-1){var n=e._groupBy[e._drawDepth],s=n(t,i);e.highlight(false);if(e._tooltip)e._tooltipClass.data([]).render();e._history.push({depth:e._depth,filter:e._filter});e.config({depth:e._drawDepth+1,filter:function(t,e){return n(t,e)===s}}).render()}},mouseenter:function(t,i){var n=e._ids(t,i);e.highlight(function(t,i){var s=e._ids(t,i);return n[n.length-1]===s[n.length-1]});if(e._tooltip){var r=e._drawDepth<e._groupBy.length-1;e._select.style("cursor",r?"pointer":"auto");e._tooltipClass.data([t]).footer(r?"Click to Expand":"").translate(s.mouse(s.select("html").node())).render()}},mousemove:function(){if(e._tooltip){e._tooltipClass.translate(s.mouse(s.select("html").node())).render()}},mouseleave:function(){e.highlight(false);e._select.style("cursor","auto");if(e._tooltip)e._tooltipClass.data([]).render()}};this._padding=5;this._shapes=[];this._shapeConfig={fill:function(t,i){return h.assign(e._groupBy[0](t,i))},opacity:a.constant(1),stroke:function(t,n){return i.color(h.assign(e._groupBy[0](t,n))).darker()},strokeWidth:a.constant(0)};this._timeline=true;this._timelineClass=(new p.Timeline).align("end").on("end",function(t){if(!(t instanceof Array))t=[t,t];t=t.map(Number);e._timelineClass.selection(t);e.timeFilter(function(i){var n=o.date(e._time(i)).getTime();return n>=t[0]&&n<=t[1]}).render()});this._timelineConfig={};this._tooltip=true;this._tooltipClass=(new d.Tooltip).pointerEvents("none");this._tooltipConfig={duration:50}}if(t)f.__proto__=t;f.prototype=Object.create(t&&t.prototype);f.prototype.constructor=f;f.prototype._shapeConfigPrep=function t(e){var i=this;if(e===void 0)e=false;var n={duration:this._duration};var s=function(t){if({}.hasOwnProperty.call(i._shapeConfig,t)){if(typeof i._shapeConfig[t]==="function"){n[t]=function(e,n,s){return i._shapeConfig[t](e.__d3plus__?e.data:e,e.__d3plus__?e.i:n,s)}}else n[t]=i._shapeConfig[t]}};for(var r in this._shapeConfig)s(r);n.on=Object.keys(this._on).filter(function(t){return!t.includes(".")||t.includes(".shape")}).reduce(function(t,e){t[e]=function(t,n){return i._on[e]?i._on[e](t.__d3plus__?t.data:t,t.__d3plus__?t.i:n):null};return t},{});if(e)n=Object.assign(n,this._shapeConfig[e]);return n};f.prototype._uiGroup=function t(e,i){if(i===void 0)i=true;return a.elem("g.d3plus-viz-"+e,{condition:i,enter:{transform:"translate(0, "+this._height/2+")"},exit:{opacity:0},parent:this._select,transition:this._transition,update:{opacity:1,transform:"translate(0, "+this._height/2+")"}})};f.prototype.render=function t(i){var h=this;this._margin={bottom:0,left:0,right:0,top:0};this._transition=r.transition().duration(this._duration);if(this._select===void 0||this._select.node().tagName.toLowerCase()!=="svg"){var l=this._select===void 0?s.select("body"):this._select;var u=g(l.node());var p=u[0];var d=u[1];if(!this._width)this.width(p);if(!this._height)this.height(d);p=this._width;d=this._height;this.select(l.append("svg").style("width",p+"px").style("height",d+"px").style("display","block").node())}if(!this._width||!this._height){var f=g(this._select.node());var c=f[0];var y=f[1];if(!this._width)this.width(c);if(!this._height)this.height(y)}var m=this;this._drawDepth=this._depth!==void 0?this._depth:this._groupBy.length-1;this._id=this._groupBy[this._drawDepth];this._ids=function(t,e){return h._groupBy.map(function(i){return i(t.__d3plus__?t.data:t,t.__d3plus__?t.i:e)}).filter(function(t){return t!==void 0&&t.constructor!==Array})};this._drawLabel=this._label||function(t,e){var i=m._ids(t,e).filter(function(t){return t&&t.constructor!==Array});return i[i.length-1]};this._legendData=[];this._filteredData=[];if(this._data.length){var v=this._timeFilter?this._data.filter(this._timeFilter):this._data;if(this._filter)v=v.filter(this._filter);var C=n.nest();for(var w=0;w<=this._drawDepth;w++)C.key(h._groupBy[w]);C.rollup(function(t){return h._legendData.push(a.merge(t,h._aggs))}).entries(v);if(this._discrete&&"_"+this._discrete in this)C.key(this["_"+this._discrete]);C.rollup(function(t){return h._filteredData.push(a.merge(t,h._aggs))}).entries(v)}var b=this._time&&this._timeline;var k=b?Array.from(new Set(this._data.map(this._time))).map(o.date):[];b=b&&k.length>1;var x=this._uiGroup("timeline",b);if(b){var B=this._timelineClass.domain(e.extent(k)).duration(this._duration).height(this._height/2-this._margin.bottom).select(x.node()).ticks(k.sort()).width(this._width);if(B.selection()===void 0){var O=e.extent(Array.from(new Set(e.merge(this._filteredData.map(function(t){var e=h._time(t);return e instanceof Array?e:[e]})))).map(o.date));if(O.length===1)O=O[0];B.selection(O)}B.config(this._timelineConfig).render();this._margin.bottom+=B.outerBounds().height+B.padding()*2}var A=this._uiGroup("legend",this._legend);if(this._legend){var D=_(this._legendData,this._shapeConfig.fill,this._groupBy);this._legendClass.id(D.id).duration(this._duration).data(D.data.length>1?D.data:[]).height(this._height/2-this._margin.bottom).label(this._label||D.id).select(A.node()).verticalAlign("bottom").width(this._width).shapeConfig(this._shapeConfig).shapeConfig({on:Object.keys(this._on).filter(function(t){return!t.includes(".")||t.includes(".legend")}).reduce(function(t,e){t[e]=h._on[e];return t},{})}).config(this._legendConfig).render();var F=this._legendClass.outerBounds();if(F.height)this._margin.bottom+=F.height+this._legendClass.padding()*2}var q=a.elem("g.d3plus-viz-titles",{parent:this._select});this._backClass.data(this._history.length?[{text:"Back",x:this._padding*2,y:0}]:[]).select(q.node()).render();this._margin.top+=this._history.length?this._backClass.fontSize()()+this._padding:0;this._tooltipClass.title(this._drawLabel).config(this._tooltipConfig);if(i)setTimeout(i,this._duration+100);return this};f.prototype.aggs=function t(e){return arguments.length?(this._aggs=Object.assign(this._aggs,e),this):this._aggs};f.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};f.prototype.depth=function t(e){return arguments.length?(this._depth=e,this):this._depth};f.prototype.discrete=function t(e){return arguments.length?(this._discrete=e,this):this._discrete};f.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};f.prototype.filter=function t(e){return arguments.length?(this._filter=e,this):this._filter};f.prototype.groupBy=function t(e){var i=this;if(!arguments.length)return this._groupBy;if(!(e instanceof Array))e=[e];return this._groupBy=e.map(function(t){if(typeof t==="function")return t;else{if(!i._aggs[t]){i._aggs[t]=function(t){var e=Array.from(new Set(t));return e.length===1?e[0]:e}}return a.accessor(t)}}),this};f.prototype.height=function t(e){return arguments.length?(this._height=e,this):this._height};f.prototype.highlight=function t(e){var i=e?this._data.filter(e):[],n=this;var s=[];i.map(this._ids).forEach(function(t){for(var e=1;e<=t.length;e++){s.push(JSON.stringify(t.slice(0,e)))}});s=s.filter(function(t,e){return s.indexOf(t)===e});function r(t){t.selectAll(".d3plus-Shape").style(a.prefix()+"transition","opacity "+n._tooltipClass.duration()/1e3+"s").style("opacity",function(t,e){if(!s.length||!t)return 1;return s.includes(JSON.stringify(n._ids(t,e)))?1:n._highlightOpacity})}this._shapes.forEach(function(t){return t.select().call(r)});this._select.select(".d3plus-viz-legend").call(r);return this};f.prototype.highlightOpacity=function t(e){return arguments.length?(this._highlightOpacity=e,this):this._highlightOpacity};f.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:a.constant(e),this):this._label};f.prototype.legend=function t(e){return arguments.length?(this._legend=e,this):this._legend};f.prototype.legendConfig=function t(e){return arguments.length?(this._legendConfig=e,this):this._legendConfig};f.prototype.select=function t(e){return arguments.length?(this._select=s.select(e),this):this._select};f.prototype.shape=function t(e){return arguments.length?(this._shape=typeof e==="function"?e:a.constant(e),this):this._shape};f.prototype.shapeConfig=function t(e){return arguments.length?(this._shapeConfig=Object.assign(this._shapeConfig,e),this):this._shapeConfig};f.prototype.time=function t(e){if(arguments.length){if(typeof e==="function"){this._time=e}else{this._time=a.accessor(e);if(!this._aggs[e]){this._aggs[e]=function(t){var e=Array.from(new Set(t));return e.length===1?e[0]:e}}}return this}else return this._time};f.prototype.timeFilter=function t(e){return arguments.length?(this._timeFilter=e,this):this._timeFilter};f.prototype.timeline=function t(e){return arguments.length?(this._timeline=e,this):this._timeline};f.prototype.timelineConfig=function t(e){return arguments.length?(this._timelineConfig=Object.assign(this._timelineConfig,e),this):this._timelineConfig};f.prototype.tooltip=function t(e){return arguments.length?(this._tooltip=e,this):this._tooltip};f.prototype.tooltipConfig=function t(e){return arguments.length?(this._tooltipConfig=Object.assign(this._tooltipConfig,e),this):this._tooltipConfig};f.prototype.width=function t(e){return arguments.length?(this._width=e,this):this._width};return f}(a.BaseClass);t.Viz=c;Object.defineProperty(t,"__esModule",{value:true})}); | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-color"),require("d3-collection"),require("d3-selection"),require("d3-transition"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-common"),require("d3plus-legend"),require("d3plus-text"),require("d3plus-timeline"),require("d3plus-tooltip")):typeof define==="function"&&define.amd?define("d3plus-viz",["exports","d3-array","d3-color","d3-collection","d3-selection","d3-transition","d3plus-axis","d3plus-color","d3plus-common","d3plus-legend","d3plus-text","d3plus-timeline","d3plus-tooltip"],e):e(t.d3plus=t.d3plus||{},t.d3Array,t.d3Color,t.d3Collection,t.d3Selection,t.d3Transition,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.d3plusLegend,t.d3plusText,t.d3plusTimeline,t.d3plusTooltip)})(this,function(t,e,i,n,s,r,o,h,a,l,u,p,d){"use strict";var _=function(t,i,s){if(s===void 0)s=[];if(s&&!(s instanceof Array))s=[s];var r=n.nest().key(i).entries(t);if(r.length<2)return{data:[],id:i};var o,h;if(s.length){var l=r.length;var u=function(i){var u=r.map(function(t){return Array.from(new Set(t.values.map(function(t){return s[i](t)})))}),p=e.sum(u,function(t){return t.length}),d=new Set(e.merge(u)).size;if(p===l&&d===l||i===s.length-1){h=s[i];o=n.nest().key(h).entries(t).map(function(t){return a.merge(t.values)});return"break"}};for(var p=0;p<s.length;p++){var d=u(p);if(d==="break")break}}else{h=i;o=r.map(function(t){return a.merge(t.values)})}return{data:o,id:h}};function f(t,e){if(t.tagName===undefined||["BODY","HTML"].indexOf(t.tagName)>=0){var i=window["inner"+(e.charAt(0).toUpperCase()+e.slice(1))];var n=s.select(t);if(e==="width"){i-=parseFloat(n.style("margin-left"),10);i-=parseFloat(n.style("margin-right"),10);i-=parseFloat(n.style("padding-left"),10);i-=parseFloat(n.style("padding-right"),10)}else{i-=parseFloat(n.style("margin-top"),10);i-=parseFloat(n.style("margin-bottom"),10);i-=parseFloat(n.style("padding-top"),10);i-=parseFloat(n.style("padding-bottom"),10)}return i}else{var r=parseFloat(s.select(t).style(e),10);if(typeof r==="number"&&r>0)return r;else return f(t.parentNode,e)}}var g=function(t){return[f(t,"width"),f(t,"height")]};var c=function(t){function f(){var e=this;t.call(this);this._aggs={};this._backClass=(new u.TextBox).on("click",function(){if(e._history.length)e.config(e._history.pop()).render();else e.depth(e._drawDepth-1).filter(false).render()}).on("mousemove",function(){return e._backClass.select().style("cursor","pointer")});this._data=[];this._duration=600;this._highlightOpacity=.5;this._history=[];this._groupBy=[a.accessor("id")];this._legend=true;this._legendConfig={shapeConfig:{fontResize:false}};this._legendClass=new l.Legend;this._on={click:function(t,i){e._select.style("cursor","auto");if(e._drawDepth<e._groupBy.length-1){var n=e._groupBy[e._drawDepth],s=n(t,i);e.highlight(false);if(e._tooltip)e._tooltipClass.data([]).render();e._history.push({depth:e._depth,filter:e._filter});e.config({depth:e._drawDepth+1,filter:function(t,e){return n(t,e)===s}}).render()}},mouseenter:function(t,i){var n=e._ids(t,i);e.highlight(function(t,i){var s=e._ids(t,i);return n[n.length-1]===s[n.length-1]});if(e._tooltip){var r=e._drawDepth<e._groupBy.length-1;e._select.style("cursor",r?"pointer":"auto");e._tooltipClass.data([t]).footer(r?"Click to Expand":"").translate(s.mouse(s.select("html").node())).render()}},mousemove:function(){if(e._tooltip){e._tooltipClass.translate(s.mouse(s.select("html").node())).render()}},mouseleave:function(){e.highlight(false);e._select.style("cursor","auto");if(e._tooltip)e._tooltipClass.data([]).render()}};this._padding=5;this._shapes=[];this._shapeConfig={fill:function(t,i){return h.assign(e._groupBy[0](t,i))},opacity:a.constant(1),stroke:function(t,n){return i.color(h.assign(e._groupBy[0](t,n))).darker()},strokeWidth:a.constant(0)};this._timeline=true;this._timelineClass=(new p.Timeline).align("end").on("end",function(t){if(!(t instanceof Array))t=[t,t];t=t.map(Number);e._timelineClass.selection(t);e.timeFilter(function(i){var n=o.date(e._time(i)).getTime();return n>=t[0]&&n<=t[1]}).render()});this._timelineConfig={};this._tooltip=true;this._tooltipClass=(new d.Tooltip).pointerEvents("none");this._tooltipConfig={duration:50}}if(t)f.__proto__=t;f.prototype=Object.create(t&&t.prototype);f.prototype.constructor=f;f.prototype._shapeConfigPrep=function t(e){var i=this;if(e===void 0)e=false;var n={duration:this._duration};var s=function(t){if({}.hasOwnProperty.call(i._shapeConfig,t)){if(typeof i._shapeConfig[t]==="function"){n[t]=function(e,n,s){return i._shapeConfig[t](e.__d3plus__?e.data:e,e.__d3plus__?e.i:n,s)}}else n[t]=i._shapeConfig[t]}};for(var r in this._shapeConfig)s(r);n.on=Object.keys(this._on).filter(function(t){return!t.includes(".")||t.includes(".shape")}).reduce(function(t,e){t[e]=function(t,n){return i._on[e]?i._on[e](t.__d3plus__?t.data:t,t.__d3plus__?t.i:n):null};return t},{});if(e)n=a.assign(n,this._shapeConfig[e]);return n};f.prototype._uiGroup=function t(e,i){if(i===void 0)i=true;return a.elem("g.d3plus-viz-"+e,{condition:i,enter:{transform:"translate(0, "+this._height/2+")"},exit:{opacity:0},parent:this._select,transition:this._transition,update:{opacity:1,transform:"translate(0, "+this._height/2+")"}})};f.prototype.render=function t(i){var h=this;this._margin={bottom:0,left:0,right:0,top:0};this._transition=r.transition().duration(this._duration);if(this._select===void 0||this._select.node().tagName.toLowerCase()!=="svg"){var l=this._select===void 0?s.select("body"):this._select;var u=g(l.node());var p=u[0];var d=u[1];if(!this._width)this.width(p);if(!this._height)this.height(d);p=this._width;d=this._height;this.select(l.append("svg").style("width",p+"px").style("height",d+"px").style("display","block").node())}if(!this._width||!this._height){var f=g(this._select.node());var c=f[0];var y=f[1];if(!this._width)this.width(c);if(!this._height)this.height(y)}var m=this;this._drawDepth=this._depth!==void 0?this._depth:this._groupBy.length-1;this._id=this._groupBy[this._drawDepth];this._ids=function(t,e){return h._groupBy.map(function(i){return i(t.__d3plus__?t.data:t,t.__d3plus__?t.i:e)}).filter(function(t){return t!==void 0&&t.constructor!==Array})};this._drawLabel=this._label||function(t,e){var i=m._ids(t,e).filter(function(t){return t&&t.constructor!==Array});return i[i.length-1]};this._legendData=[];this._filteredData=[];if(this._data.length){var v=this._timeFilter?this._data.filter(this._timeFilter):this._data;if(this._filter)v=v.filter(this._filter);var C=n.nest();for(var w=0;w<=this._drawDepth;w++)C.key(h._groupBy[w]);C.rollup(function(t){return h._legendData.push(a.merge(t,h._aggs))}).entries(v);if(this._discrete&&"_"+this._discrete in this)C.key(this["_"+this._discrete]);C.rollup(function(t){return h._filteredData.push(a.merge(t,h._aggs))}).entries(v)}var b=this._time&&this._timeline;var k=b?Array.from(new Set(this._data.map(this._time))).map(o.date):[];b=b&&k.length>1;var x=this._uiGroup("timeline",b);if(b){var B=this._timelineClass.domain(e.extent(k)).duration(this._duration).height(this._height/2-this._margin.bottom).select(x.node()).ticks(k.sort()).width(this._width);if(B.selection()===void 0){var A=e.extent(Array.from(new Set(e.merge(this._filteredData.map(function(t){var e=h._time(t);return e instanceof Array?e:[e]})))).map(o.date));if(A.length===1)A=A[0];B.selection(A)}B.config(this._timelineConfig).render();this._margin.bottom+=B.outerBounds().height+B.padding()*2}var D=this._uiGroup("legend",this._legend);if(this._legend){var F=_(this._legendData,this._shapeConfig.fill,this._groupBy);this._legendClass.id(F.id).duration(this._duration).data(F.data.length>1?F.data:[]).height(this._height/2-this._margin.bottom).label(this._label||F.id).select(D.node()).verticalAlign("bottom").width(this._width).shapeConfig(this._shapeConfig).shapeConfig({on:Object.keys(this._on).filter(function(t){return!t.includes(".")||t.includes(".legend")}).reduce(function(t,e){t[e]=h._on[e];return t},{})}).config(this._legendConfig).render();var O=this._legendClass.outerBounds();if(O.height)this._margin.bottom+=O.height+this._legendClass.padding()*2}var q=a.elem("g.d3plus-viz-titles",{parent:this._select});this._backClass.data(this._history.length?[{text:"Back",x:this._padding*2,y:0}]:[]).select(q.node()).render();this._margin.top+=this._history.length?this._backClass.fontSize()()+this._padding:0;this._tooltipClass.title(this._drawLabel).config(this._tooltipConfig);if(i)setTimeout(i,this._duration+100);return this};f.prototype.aggs=function t(e){return arguments.length?(this._aggs=a.assign(this._aggs,e),this):this._aggs};f.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};f.prototype.depth=function t(e){return arguments.length?(this._depth=e,this):this._depth};f.prototype.discrete=function t(e){return arguments.length?(this._discrete=e,this):this._discrete};f.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};f.prototype.filter=function t(e){return arguments.length?(this._filter=e,this):this._filter};f.prototype.groupBy=function t(e){var i=this;if(!arguments.length)return this._groupBy;if(!(e instanceof Array))e=[e];return this._groupBy=e.map(function(t){if(typeof t==="function")return t;else{if(!i._aggs[t]){i._aggs[t]=function(t){var e=Array.from(new Set(t));return e.length===1?e[0]:e}}return a.accessor(t)}}),this};f.prototype.height=function t(e){return arguments.length?(this._height=e,this):this._height};f.prototype.highlight=function t(e){var i=e?this._data.filter(e):[],n=this;var s=[];i.map(this._ids).forEach(function(t){for(var e=1;e<=t.length;e++){s.push(JSON.stringify(t.slice(0,e)))}});s=s.filter(function(t,e){return s.indexOf(t)===e});function r(t){t.selectAll(".d3plus-Shape").style(a.prefix()+"transition","opacity "+n._tooltipClass.duration()/1e3+"s").style("opacity",function(t,e){if(!s.length||!t)return 1;return s.includes(JSON.stringify(n._ids(t,e)))?1:n._highlightOpacity})}this._shapes.forEach(function(t){return t.select().call(r)});this._select.select(".d3plus-viz-legend").call(r);return this};f.prototype.highlightOpacity=function t(e){return arguments.length?(this._highlightOpacity=e,this):this._highlightOpacity};f.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:a.constant(e),this):this._label};f.prototype.legend=function t(e){return arguments.length?(this._legend=e,this):this._legend};f.prototype.legendConfig=function t(e){return arguments.length?(this._legendConfig=e,this):this._legendConfig};f.prototype.select=function t(e){return arguments.length?(this._select=s.select(e),this):this._select};f.prototype.shape=function t(e){return arguments.length?(this._shape=typeof e==="function"?e:a.constant(e),this):this._shape};f.prototype.shapeConfig=function t(e){return arguments.length?(this._shapeConfig=a.assign(this._shapeConfig,e),this):this._shapeConfig};f.prototype.time=function t(e){if(arguments.length){if(typeof e==="function"){this._time=e}else{this._time=a.accessor(e);if(!this._aggs[e]){this._aggs[e]=function(t){var e=Array.from(new Set(t));return e.length===1?e[0]:e}}}return this}else return this._time};f.prototype.timeFilter=function t(e){return arguments.length?(this._timeFilter=e,this):this._timeFilter};f.prototype.timeline=function t(e){return arguments.length?(this._timeline=e,this):this._timeline};f.prototype.timelineConfig=function t(e){return arguments.length?(this._timelineConfig=a.assign(this._timelineConfig,e),this):this._timelineConfig};f.prototype.tooltip=function t(e){return arguments.length?(this._tooltip=e,this):this._tooltip};f.prototype.tooltipConfig=function t(e){return arguments.length?(this._tooltipConfig=a.assign(this._tooltipConfig,e),this):this._tooltipConfig};f.prototype.width=function t(e){return arguments.length?(this._width=e,this):this._width};return f}(a.BaseClass);t.Viz=c;Object.defineProperty(t,"__esModule",{value:true})}); |
{ | ||
"name": "d3plus-viz", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Abstract ES6 class that drives d3plus visualizations.", | ||
@@ -33,3 +33,3 @@ "main": "build/d3plus-viz.js", | ||
"d3plus-color": "^0.5.3", | ||
"d3plus-common": "^0.6.8", | ||
"d3plus-common": "^0.6.9", | ||
"d3plus-legend": "^0.6.18", | ||
@@ -36,0 +36,0 @@ "d3plus-text": "^0.9.9", |
@@ -317,2 +317,2 @@ # d3plus-viz | ||
###### <sub>Documentation generated on Mon, 21 Nov 2016 20:01:11 GMT</sub> | ||
###### <sub>Documentation generated on Tue, 22 Nov 2016 13:27:52 GMT</sub> |
@@ -8,4 +8,4 @@ import {extent, merge as arrayMerge} from "d3-array"; | ||
import {date} from "d3plus-axis"; | ||
import {assign} from "d3plus-color"; | ||
import {accessor, BaseClass, constant, elem, merge, prefix} from "d3plus-common"; | ||
import {assign as colorAssign} from "d3plus-color"; | ||
import {accessor, assign, BaseClass, constant, elem, merge, prefix} from "d3plus-common"; | ||
import {Legend} from "d3plus-legend"; | ||
@@ -113,5 +113,5 @@ import {TextBox} from "d3plus-text"; | ||
this._shapeConfig = { | ||
fill: (d, i) => assign(this._groupBy[0](d, i)), | ||
fill: (d, i) => colorAssign(this._groupBy[0](d, i)), | ||
opacity: constant(1), | ||
stroke: (d, i) => color(assign(this._groupBy[0](d, i))).darker(), | ||
stroke: (d, i) => color(colorAssign(this._groupBy[0](d, i))).darker(), | ||
strokeWidth: constant(0) | ||
@@ -170,3 +170,3 @@ }; | ||
if (shape) newConfig = Object.assign(newConfig, this._shapeConfig[shape]); | ||
if (shape) newConfig = assign(newConfig, this._shapeConfig[shape]); | ||
return newConfig; | ||
@@ -345,3 +345,3 @@ | ||
aggs(_) { | ||
return arguments.length ? (this._aggs = Object.assign(this._aggs, _), this) : this._aggs; | ||
return arguments.length ? (this._aggs = assign(this._aggs, _), this) : this._aggs; | ||
} | ||
@@ -522,3 +522,3 @@ | ||
shapeConfig(_) { | ||
return arguments.length ? (this._shapeConfig = Object.assign(this._shapeConfig, _), this) : this._shapeConfig; | ||
return arguments.length ? (this._shapeConfig = assign(this._shapeConfig, _), this) : this._shapeConfig; | ||
} | ||
@@ -574,3 +574,3 @@ | ||
timelineConfig(_) { | ||
return arguments.length ? (this._timelineConfig = Object.assign(this._timelineConfig, _), this) : this._timelineConfig; | ||
return arguments.length ? (this._timelineConfig = assign(this._timelineConfig, _), this) : this._timelineConfig; | ||
} | ||
@@ -593,3 +593,3 @@ | ||
tooltipConfig(_) { | ||
return arguments.length ? (this._tooltipConfig = Object.assign(this._tooltipConfig, _), this) : this._tooltipConfig; | ||
return arguments.length ? (this._tooltipConfig = assign(this._tooltipConfig, _), this) : this._tooltipConfig; | ||
} | ||
@@ -596,0 +596,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2151861
16067
Updatedd3plus-common@^0.6.9