Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3plus-viz

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3plus-viz - npm Package Compare versions

Comparing version 0.3.12 to 0.4.0

46

build/d3plus-viz.js
/*
d3plus-viz v0.3.12
d3plus-viz v0.4.0
Abstract ES6 class that drives d3plus visualizations.

@@ -28,2 +28,3 @@ Copyright (c) 2016 D3plus - https://d3plus.org

var colors = d3Collection.nest().key(fill).entries(raw);
if (colors.length < 2) return {data: [], id: fill};
var data, id;

@@ -142,3 +143,3 @@

var filterGroup = this$1._groupBy[this$1._drawDepth],
filterId = this$1._id(d, i);
filterId = filterGroup(d, i);

@@ -163,9 +164,7 @@ this$1.highlight(false);

var filterId = this$1._id(d, i);
var filterId = this$1._ids(d, i);
this$1.highlight(function (h, x) {
var myId = this$1._id(h, x);
if (myId.constructor === Array && filterId.constructor !== Array) return myId.includes(filterId);
if (myId.constructor !== Array && filterId.constructor === Array) return filterId.includes(myId);
return myId === filterId;
var ids = this$1._ids(h, x);
return filterId[filterId.length - 1] === ids[filterId.length - 1];
});

@@ -199,5 +198,5 @@

this._shapeConfig = {
fill: function (d, i) { return d3plusColor.assign(this$1._id(d, i)); },
fill: function (d, i) { return d3plusColor.assign(this$1._groupBy[0](d, i)); },
opacity: d3plusCommon.constant(1),
stroke: function (d, i) { return d3Color.color(d3plusColor.assign(this$1._id(d, i))).darker(); },
stroke: function (d, i) { return d3Color.color(d3plusColor.assign(this$1._groupBy[0](d, i))).darker(); },
strokeWidth: d3plusCommon.constant(0)

@@ -286,10 +285,8 @@ };

this._id = this._groupBy[this._drawDepth];
this._ids = function (d, i) { return this$1._groupBy
.map(function (g) { return g(d.__d3plus__ ? d.data : d, d.__d3plus__ ? d.i : i); })
.filter(function (g) { return g !== void 0 && g.constructor !== Array; }); };
this._drawLabel = this._label || function(d, i) {
var l = that._id(d, i);
if (l.constructor !== Array) return l;
for (var x = that._drawDepth; x >= 0; x--) {
l = that._groupBy[x](d, i);
if (l.constructor !== Array) break;
}
return l;
var l = that._ids(d, i).filter(function (d) { return d && d.constructor !== Array; });
return l[l.length - 1];
};

@@ -499,11 +496,20 @@

Viz.prototype.highlight = function highlight (_) {
var ids = _ ? Array.from(new Set(this._data.filter(_).map(this._id))).map(d3plusText.strip) : [],
var highlightData = _ ? this._data.filter(_) : [],
that = this;
var highlightIds = [];
highlightData.map(this._ids).forEach(function (ids) {
for (var x = 1; x <= ids.length; x++) {
highlightIds.push(JSON.stringify(ids.slice(0, x)));
}
});
highlightIds = highlightIds.filter(function (id, i) { return highlightIds.indexOf(id) === i; });
function opacity(group) {
group.selectAll(".d3plus-Shape")
.style(((d3plusCommon.prefix()) + "transition"), ("opacity " + (that._tooltipClass.duration() / 1000) + "s"))
.style("opacity", function() {
var id = this.className.baseVal.split(" ").filter(function (c) { return c.indexOf("d3plus-id-") === 0; })[0].slice(10);
return ids.length === 0 || ids.includes(id) ? 1 : that._highlightOpacity;
.style("opacity", function (d, i) {
if (!highlightIds.length || !d) return 1;
return highlightIds.includes(JSON.stringify(that._ids(d, i))) ? 1 : that._highlightOpacity;
});

@@ -510,0 +516,0 @@ }

/*
d3plus-viz v0.3.12
d3plus-viz v0.4.0
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,r,s,o,h,a,l,u,p,d){"use strict";var _=function(t,i,r){if(r===void 0)r=[];if(r&&!(r instanceof Array))r=[r];var s=n.nest().key(i).entries(t);var o,h;if(r.length){var l=s.length;var u=function(i){var u=s.map(function(t){return Array.from(new Set(t.values.map(function(t){return r[i](t)})))}),p=e.sum(u,function(t){return t.length}),d=new Set(e.merge(u)).size;if(p===l&&d===l||i===r.length-1){h=r[i];o=n.nest().key(h).entries(t).map(function(t){return a.merge(t.values)});return"break"}};for(var p=0;p<r.length;p++){var d=u(p);if(d==="break")break}}else{h=i;o=s.map(function(t){return a.merge(t.values)})}return{data:o,id:h}};function g(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=r.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 s=parseFloat(r.select(t).style(e),10);if(typeof s==="number"&&s>0)return s;else return g(t.parentNode,e)}}var c=function(t){return[g(t,"width"),g(t,"height")]};var f=function(t){function g(){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],r=e._id(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)===r}}).render()}},mouseenter:function(t,i){var n=e._id(t,i);e.highlight(function(t,i){var r=e._id(t,i);if(r.constructor===Array&&n.constructor!==Array)return r.includes(n);if(r.constructor!==Array&&n.constructor===Array)return n.includes(r);return r===n});if(e._tooltip){var s=e._drawDepth<e._groupBy.length-1;e._select.style("cursor",s?"pointer":"auto");e._tooltipClass.data([t]).footer(s?"Click to Expand":"").translate(r.mouse(r.select("html").node())).render()}},mousemove:function(){if(e._tooltip){e._tooltipClass.translate(r.mouse(r.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._id(t,i))},opacity:a.constant(1),stroke:function(t,n){return i.color(h.assign(e._id(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)g.__proto__=t;g.prototype=Object.create(t&&t.prototype);g.prototype.constructor=g;g.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+")"}})};g.prototype.render=function t(i){var h=this;this._margin={bottom:0,left:0,right:0,top:0};this._transition=s.transition().duration(this._duration);if(this._select===void 0||this._select.node().tagName.toLowerCase()!=="svg"){var l=this._select===void 0?r.select("body"):this._select;var u=c(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 g=c(this._select.node());var f=g[0];var y=g[1];if(!this._width)this.width(f);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._drawLabel=this._label||function(t,e){var i=m._id(t,e);if(i.constructor!==Array)return i;for(var n=m._drawDepth;n>=0;n--){i=m._groupBy[n](t,e);if(i.constructor!==Array)break}return i};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 A=this._timelineClass.domain(e.extent(k)).duration(this._duration).height(this._height/2-this._margin.bottom).select(x.node()).ticks(k).width(this._width);if(A.selection()===void 0){var B=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(B.length===1)B=B[0];A.selection(B)}A.config(this._timelineConfig).render();this._margin.bottom+=A.outerBounds().height+A.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};g.prototype.aggs=function t(e){return arguments.length?(this._aggs=Object.assign(this._aggs,e),this):this._aggs};g.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};g.prototype.depth=function t(e){return arguments.length?(this._depth=e,this):this._depth};g.prototype.discrete=function t(e){return arguments.length?(this._discrete=e,this):this._discrete};g.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};g.prototype.filter=function t(e){return arguments.length?(this._filter=e,this):this._filter};g.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};g.prototype.height=function t(e){return arguments.length?(this._height=e,this):this._height};g.prototype.highlight=function t(e){var i=e?Array.from(new Set(this._data.filter(e).map(this._id))).map(u.strip):[],n=this;function r(t){t.selectAll(".d3plus-Shape").style(a.prefix()+"transition","opacity "+n._tooltipClass.duration()/1e3+"s").style("opacity",function(){var t=this.className.baseVal.split(" ").filter(function(t){return t.indexOf("d3plus-id-")===0})[0].slice(10);return i.length===0||i.includes(t)?1:n._highlightOpacity})}this._shapes.forEach(function(t){return t.select().call(r)});this._select.select(".d3plus-viz-legend").call(r);return this};g.prototype.highlightOpacity=function t(e){return arguments.length?(this._highlightOpacity=e,this):this._highlightOpacity};g.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:a.constant(e),this):this._label};g.prototype.legend=function t(e){return arguments.length?(this._legend=e,this):this._legend};g.prototype.legendConfig=function t(e){return arguments.length?(this._legendConfig=e,this):this._legendConfig};g.prototype.select=function t(e){return arguments.length?(this._select=r.select(e),this):this._select};g.prototype.shape=function t(e){return arguments.length?(this._shape=typeof e==="function"?e:a.constant(e),this):this._shape};g.prototype.shapeConfig=function t(e){return arguments.length?(this._shapeConfig=Object.assign(this._shapeConfig,e),this):this._shapeConfig};g.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};g.prototype.timeFilter=function t(e){return arguments.length?(this._timeFilter=e,this):this._timeFilter};g.prototype.timeline=function t(e){return arguments.length?(this._timeline=e,this):this._timeline};g.prototype.timelineConfig=function t(e){return arguments.length?(this._timelineConfig=Object.assign(this._timelineConfig,e),this):this._timelineConfig};g.prototype.tooltip=function t(e){return arguments.length?(this._tooltip=e,this):this._tooltip};g.prototype.tooltipConfig=function t(e){return arguments.length?(this._tooltipConfig=Object.assign(this._tooltipConfig,e),this):this._tooltipConfig};g.prototype.width=function t(e){return arguments.length?(this._width=e,this):this._width};return g}(a.BaseClass);t.Viz=f;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,l,a,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 a=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===a&&d===a||i===s.length-1){h=s[i];o=n.nest().key(h).entries(t).map(function(t){return l.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 l.merge(t.values)})}return{data:o,id:h}};function g(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 g(t.parentNode,e)}}var f=function(t){return[g(t,"width"),g(t,"height")]};var c=function(t){function g(){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=[l.accessor("id")];this._legend=true;this._legendConfig={shapeConfig:{fontResize:false}};this._legendClass=new a.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:l.constant(1),stroke:function(t,n){return i.color(h.assign(e._groupBy[0](t,n))).darker()},strokeWidth:l.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)g.__proto__=t;g.prototype=Object.create(t&&t.prototype);g.prototype.constructor=g;g.prototype._uiGroup=function t(e,i){if(i===void 0)i=true;return l.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+")"}})};g.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 a=this._select===void 0?s.select("body"):this._select;var u=f(a.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(a.append("svg").style("width",p+"px").style("height",d+"px").style("display","block").node())}if(!this._width||!this._height){var g=f(this._select.node());var c=g[0];var y=g[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(l.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(l.merge(t,h._aggs))}).entries(v)}var b=this._time&&this._timeline;var x=b?Array.from(new Set(this._data.map(this._time))).map(o.date):[];b=b&&x.length>1;var k=this._uiGroup("timeline",b);if(b){var B=this._timelineClass.domain(e.extent(x)).duration(this._duration).height(this._height/2-this._margin.bottom).select(k.node()).ticks(x).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=l.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};g.prototype.aggs=function t(e){return arguments.length?(this._aggs=Object.assign(this._aggs,e),this):this._aggs};g.prototype.data=function t(e){return arguments.length?(this._data=e,this):this._data};g.prototype.depth=function t(e){return arguments.length?(this._depth=e,this):this._depth};g.prototype.discrete=function t(e){return arguments.length?(this._discrete=e,this):this._discrete};g.prototype.duration=function t(e){return arguments.length?(this._duration=e,this):this._duration};g.prototype.filter=function t(e){return arguments.length?(this._filter=e,this):this._filter};g.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 l.accessor(t)}}),this};g.prototype.height=function t(e){return arguments.length?(this._height=e,this):this._height};g.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(l.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};g.prototype.highlightOpacity=function t(e){return arguments.length?(this._highlightOpacity=e,this):this._highlightOpacity};g.prototype.label=function t(e){return arguments.length?(this._label=typeof e==="function"?e:l.constant(e),this):this._label};g.prototype.legend=function t(e){return arguments.length?(this._legend=e,this):this._legend};g.prototype.legendConfig=function t(e){return arguments.length?(this._legendConfig=e,this):this._legendConfig};g.prototype.select=function t(e){return arguments.length?(this._select=s.select(e),this):this._select};g.prototype.shape=function t(e){return arguments.length?(this._shape=typeof e==="function"?e:l.constant(e),this):this._shape};g.prototype.shapeConfig=function t(e){return arguments.length?(this._shapeConfig=Object.assign(this._shapeConfig,e),this):this._shapeConfig};g.prototype.time=function t(e){if(arguments.length){if(typeof e==="function"){this._time=e}else{this._time=l.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};g.prototype.timeFilter=function t(e){return arguments.length?(this._timeFilter=e,this):this._timeFilter};g.prototype.timeline=function t(e){return arguments.length?(this._timeline=e,this):this._timeline};g.prototype.timelineConfig=function t(e){return arguments.length?(this._timelineConfig=Object.assign(this._timelineConfig,e),this):this._timelineConfig};g.prototype.tooltip=function t(e){return arguments.length?(this._tooltip=e,this):this._tooltip};g.prototype.tooltipConfig=function t(e){return arguments.length?(this._tooltipConfig=Object.assign(this._tooltipConfig,e),this):this._tooltipConfig};g.prototype.width=function t(e){return arguments.length?(this._width=e,this):this._width};return g}(l.BaseClass);t.Viz=c;Object.defineProperty(t,"__esModule",{value:true})});
{
"name": "d3plus-viz",
"version": "0.3.12",
"version": "0.4.0",
"description": "Abstract ES6 class that drives d3plus visualizations.",

@@ -28,12 +28,12 @@ "main": "build/d3plus-viz.js",

"d3-collection": "^1.0.1",
"d3-color": "^1.0.1",
"d3-color": "^1.0.2",
"d3-selection": "^1.0.2",
"d3-transition": "^1.0.1",
"d3-transition": "^1.0.3",
"d3plus-axis": "^0.3.11",
"d3plus-color": "^0.5.3",
"d3plus-common": "^0.6.8",
"d3plus-legend": "^0.6.14",
"d3plus-legend": "^0.6.15",
"d3plus-text": "^0.9.8",
"d3plus-timeline": "^0.2.1",
"d3plus-tooltip": "^0.2.1"
"d3plus-tooltip": "^0.2.2"
},

@@ -40,0 +40,0 @@ "scripts": {

@@ -15,3 +15,3 @@ # d3plus-viz

```html
<script src="https://d3plus.org/js/d3plus-viz.v0.3.full.min.js"></script>
<script src="https://d3plus.org/js/d3plus-viz.v0.4.full.min.js"></script>
```

@@ -318,2 +318,2 @@

###### <sub>Documentation generated on Wed, 02 Nov 2016 19:03:17 GMT</sub>
###### <sub>Documentation generated on Wed, 16 Nov 2016 03:00:42 GMT</sub>

@@ -18,2 +18,3 @@ import {merge, sum} from "d3-array";

const colors = nest().key(fill).entries(raw);
if (colors.length < 2) return {data: [], id: fill};
let data, id;

@@ -20,0 +21,0 @@

@@ -11,3 +11,3 @@ import {extent, merge as arrayMerge} from "d3-array";

import {Legend} from "d3plus-legend";
import {strip, TextBox} from "d3plus-text";
import {TextBox} from "d3plus-text";
import {Timeline} from "d3plus-timeline";

@@ -60,3 +60,3 @@ import {Tooltip} from "d3plus-tooltip";

const filterGroup = this._groupBy[this._drawDepth],
filterId = this._id(d, i);
filterId = filterGroup(d, i);

@@ -81,9 +81,7 @@ this.highlight(false);

const filterId = this._id(d, i);
const filterId = this._ids(d, i);
this.highlight((h, x) => {
const myId = this._id(h, x);
if (myId.constructor === Array && filterId.constructor !== Array) return myId.includes(filterId);
if (myId.constructor !== Array && filterId.constructor === Array) return filterId.includes(myId);
return myId === filterId;
const ids = this._ids(h, x);
return filterId[filterId.length - 1] === ids[filterId.length - 1];
});

@@ -117,5 +115,5 @@

this._shapeConfig = {
fill: (d, i) => assign(this._id(d, i)),
fill: (d, i) => assign(this._groupBy[0](d, i)),
opacity: constant(1),
stroke: (d, i) => color(assign(this._id(d, i))).darker(),
stroke: (d, i) => color(assign(this._groupBy[0](d, i))).darker(),
strokeWidth: constant(0)

@@ -192,10 +190,8 @@ };

this._id = this._groupBy[this._drawDepth];
this._ids = (d, i) => this._groupBy
.map(g => g(d.__d3plus__ ? d.data : d, d.__d3plus__ ? d.i : i))
.filter(g => g !== void 0 && g.constructor !== Array);
this._drawLabel = this._label || function(d, i) {
let l = that._id(d, i);
if (l.constructor !== Array) return l;
for (let x = that._drawDepth; x >= 0; x--) {
l = that._groupBy[x](d, i);
if (l.constructor !== Array) break;
}
return l;
const l = that._ids(d, i).filter(d => d && d.constructor !== Array);
return l[l.length - 1];
};

@@ -403,11 +399,20 @@

highlight(_) {
const ids = _ ? Array.from(new Set(this._data.filter(_).map(this._id))).map(strip) : [],
const highlightData = _ ? this._data.filter(_) : [],
that = this;
let highlightIds = [];
highlightData.map(this._ids).forEach(ids => {
for (let x = 1; x <= ids.length; x++) {
highlightIds.push(JSON.stringify(ids.slice(0, x)));
}
});
highlightIds = highlightIds.filter((id, i) => highlightIds.indexOf(id) === i);
function opacity(group) {
group.selectAll(".d3plus-Shape")
.style(`${prefix()}transition`, `opacity ${that._tooltipClass.duration() / 1000}s`)
.style("opacity", function() {
const id = this.className.baseVal.split(" ").filter(c => c.indexOf("d3plus-id-") === 0)[0].slice(10);
return ids.length === 0 || ids.includes(id) ? 1 : that._highlightOpacity;
.style("opacity", (d, i) => {
if (!highlightIds.length || !d) return 1;
return highlightIds.includes(JSON.stringify(that._ids(d, i))) ? 1 : that._highlightOpacity;
});

@@ -414,0 +419,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc