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

d3plus-legend

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3plus-legend - npm Package Compare versions

Comparing version 0.8.7 to 0.8.8

33

build/d3plus-legend.js
/*
d3plus-legend v0.8.7
d3plus-legend v0.8.8
An easy to use javascript chart legend.

@@ -639,4 +639,4 @@ Copyright (c) 2017 D3plus - https://d3plus.org

height: d3plusCommon.constant(10),
hitArea: function (dd) {
var d = this$1._lineData[this$1._data.indexOf(dd)],
hitArea: function (dd, i) {
var d = this$1._lineData[i],
h = d3Array.max([d.height, d.shapeHeight]);

@@ -646,3 +646,3 @@ return {width: d.width + d.shapeWidth, height: h, x: -d.shapeWidth / 2, y: -h / 2};

labelBounds: function (dd, i, s) {
var d = this$1._lineData[dd.i],
var d = this$1._lineData[i],
w = s.r !== void 0 ? s.r : s.width / 2;

@@ -906,3 +906,3 @@ return {width: d.width, height: d.height, x: w + this$1._padding, y: -d.height / 2};

this._shapes = [];
var baseConfig = this._shapeConfig,
var baseConfig = d3plusCommon.configPrep.bind(this)(this._shapeConfig, "legend"),
config = {

@@ -925,25 +925,2 @@ id: function (d) { return d.id; },

var loop = function ( k ) {
if (k !== "labelBounds" && {}.hasOwnProperty.call(baseConfig, k)) {
if (typeof baseConfig[k] === "function") {
obj[k] = baseConfig[k](d, i);
config[k] = function (d) { return d[k]; };
}
else if (k === "on") {
config[k] = {};
for (var t in baseConfig[k]) {
if ({}.hasOwnProperty.call(baseConfig[k], t)) {
var f = baseConfig[k][t];
config[k][t] = function(dd) {
if (!f) { return; }
f.bind(this)(dd.data, dd.i);
};
}
}
}
}
};
for (var k in baseConfig) loop( k );
return obj;

@@ -950,0 +927,0 @@

4

build/d3plus-legend.min.js
/*
d3plus-legend v0.8.7
d3plus-legend v0.8.8
An easy to use javascript chart legend.

@@ -7,2 +7,2 @@ Copyright (c) 2017 D3plus - https://d3plus.org

*/
(function(t,i){typeof exports==="object"&&typeof module!=="undefined"?i(exports,require("d3-array"),require("d3-interpolate"),require("d3-scale"),require("d3-selection"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-text")):typeof define==="function"&&define.amd?define("d3plus-legend",["exports","d3-array","d3-interpolate","d3-scale","d3-selection","d3plus-axis","d3plus-color","d3plus-common","d3plus-shape","d3plus-text"],i):i(t.d3plus=t.d3plus||{},t.d3Array,t.d3Interpolate,t.d3Scale,t.d3Selection,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.shapes,t.d3plusText)})(this,function(t,i,e,n,r,h,s,o,a,l){"use strict";function u(t){return t.slice().sort(function(t,i){return t-i})}function d(t){var i,e=0;for(var n=0;n<t.length;n++){if(n===0||t[n]!==i){i=t[n];e++}}return e}function _(t,i){var e=[];for(var n=0;n<t;n++){var r=[];for(var h=0;h<i;h++){r.push(0)}e.push(r)}return e}function c(t,i,e,n){var r;if(t>0){var h=(e[i]-e[t-1])/(i-t+1);r=n[i]-n[t-1]-(i-t+1)*h*h}else{r=n[i]-e[i]*e[i]/(i+1)}if(r<0){return 0}return r}function f(t,i,e,n,r,h,s){if(t>i){return}var o=Math.floor((t+i)/2);n[e][o]=n[e-1][o-1];r[e][o]=o;var a=e;if(t>e){a=Math.max(a,r[e][t-1]||0)}a=Math.max(a,r[e-1][o]||0);var l=o-1;if(i<n.length-1){l=Math.min(l,r[e][i+1]||0)}for(var u=l;u>=a;--u){var d=c(u,o,h,s);if(d+n[e-1][a-1]>=n[e][o]){break}var _=c(a,o,h,s);var g=_+n[e-1][a-1];if(g<n[e][o]){n[e][o]=g;r[e][o]=a}a++;var p=d+n[e-1][u-1];if(p<n[e][o]){n[e][o]=p;r[e][o]=u}}f(t,o-1,e,n,r,h,s);f(o+1,i,e,n,r,h,s)}function g(t,i,e){var n=i[0].length;var r=t[Math.floor(n/2)];var h=[];var s=[];for(var o=0,a=void 0;o<n;++o){a=t[o]-r;if(o===0){h.push(a);s.push(a*a)}else{h.push(h[o-1]+a);s.push(s[o-1]+a*a)}i[0][o]=c(0,o,h,s);e[0][o]=0}for(var l=1;l<i.length;++l){var u=n-1;if(l<i.length-1){u=l}f(u,n-1,l,i,e,h,s)}}var p=function(t,i){if(i>t.length){throw new Error("Cannot generate more classes than there are data values")}var e=u(t);var n=d(e);if(n===1){return[e]}var r=_(i,e.length),h=_(i,e.length);g(e,h,r);var s=r[0].length-1;var o=[];for(var a=r.length-1;a>=0;a--){var l=r[a][s];o[a]=e.slice(l,s+1);if(a>0){s=l-1}}return o};var v=function(t){function l(){t.call(this);this._axisClass=new h.Axis;this._axisConfig={gridSize:0};this._axisTest=new h.Axis;this._align="middle";this._color="#0C8040";this._data=[];this._duration=600;this._height=200;this._orient="bottom";this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._rectClass=new a.Rect;this._rectConfig={stroke:"#000",strokeWidth:1};this._scale="linear";this._size=10;this._value=o.accessor("value");this._width=400}if(t)l.__proto__=t;l.prototype=Object.create(t&&t.prototype);l.prototype.constructor=l;l.prototype.render=function t(h){var a=this;if(this._select===void 0){this.select(r.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}var l=["bottom","top"].includes(this._orient);var u=l?"height":"width",d=l?"width":"height",_=l?"x":"y",c=l?"y":"x";this._group=o.elem("g.d3plus-ColorScale",{parent:this._select});var f=i.extent(this._data,this._value);var g=this._color,v;if(!(g instanceof Array)){g=[s.colorLighter(g,.9),s.colorLighter(g,.75),s.colorLighter(g,.5),s.colorLighter(g,.25),g]}if(this._scale==="jenks"){var y=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});if(y.length<=g.length){var w=n.scaleLinear().domain(i.range(0,y.length-1)).interpolate(e.interpolateHsl).range(g);g=y.slice(0,y.length-1).map(function(t,i){return w(i)})}var m=p(y,g.length);v=i.merge(m.map(function(t,i){return i===m.length-1?[t[0],t[t.length-1]]:[t[0]]}));this._colorScale=n.scaleThreshold().domain(v).range(["black"].concat(g).concat(g[g.length-1]))}else{var x=(f[1]-f[0])/g.length;var C=i.range(f[0],f[1]+x/2,x);if(this._scale==="buckets"){v=C}this._colorScale=n.scaleLinear().domain(C).range(g)}var b=Object.assign({domain:l?f:f.reverse(),duration:this._duration,height:this._height,labels:v,orient:this._orient,padding:this._padding,ticks:v,width:this._width},this._axisConfig);this._axisTest.select(o.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(b).render();var B=this._axisTest.outerBounds();this._outerBounds[d]=this["_"+d]-this._padding*2;this._outerBounds[u]=B[u]+this._size;this._outerBounds[_]=this._padding;this._outerBounds[c]=this._padding;if(this._align==="middle"){this._outerBounds[c]=(this["_"+u]-this._outerBounds[u])/2}else if(this._align==="end"){this._outerBounds[c]=this["_"+u]-this._padding-this._outerBounds[u]}var H=this._outerBounds[c]+(["bottom","right"].includes(this._orient)?this._size:0)-(b.padding||this._axisClass.padding());this._axisClass.select(o.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate("+(l?0:H)+", "+(l?H:0)+")"}}).node()).config(b).align("start").render();var D=this._axisTest._d3Scale;var S=D.range();var z=this._group.selectAll("defs").data([0]);var W=z.enter().append("defs");W.append("linearGradient").attr("id","gradient-"+this._uuid);z=W.merge(z);z.select("linearGradient").attr(_+"1",l?"0%":"100%").attr(_+"2",l?"100%":"0%").attr(c+"1","0%").attr(c+"2","0%");var A=z.select("linearGradient").selectAll("stop").data(g);A.enter().append("stop").merge(A).attr("offset",function(t,i){return i/(g.length-1)*100+"%"}).attr("stop-color",String);function k(t,i){return Math.abs(D(v[i+1])-D(t))}this._rectClass.data(v?v.slice(0,v.length-1):[0]).id(function(t,i){return i}).select(o.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config((T={fill:v?function(t){return a._colorScale(t)}:"url(#gradient-"+this._uuid+")"},T[_]=v?function(t,i){return D(t)+k(t,i)/2-(["left","right"].includes(a._orient)?k(t,i):0)}:S[0]+(S[1]-S[0])/2,T[c]=this._outerBounds[c]+(["top","left"].includes(this._orient)?B[u]:0)+this._size/2,T[d]=v?k:S[1]-S[0],T[u]=this._size,T)).config(this._rectConfig).render();var T;if(h){setTimeout(h,this._duration+100)}return this};l.prototype.axisConfig=function t(i){return arguments.length?(this._axisConfig=Object.assign(this._axisConfig,i),this):this._axisConfig};l.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};l.prototype.color=function t(i){return arguments.length?(this._color=i,this):this._color};l.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};l.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};l.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};l.prototype.orient=function t(i){return arguments.length?(this._orient=i,this):this._orient};l.prototype.outerBounds=function t(){return this._outerBounds};l.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};l.prototype.rectConfig=function t(i){return arguments.length?(this._rectConfig=Object.assign(this._rectConfig,i),this):this._rectConfig};l.prototype.scale=function t(i){return arguments.length?(this._scale=i,this):this._scale};l.prototype.select=function t(i){return arguments.length?(this._select=r.select(i),this):this._select};l.prototype.size=function t(i){return arguments.length?(this._size=i,this):this._size};l.prototype.value=function t(i){return arguments.length?(this._value=typeof i==="function"?i:o.constant(i),this):this._value};l.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return l}(o.BaseClass);var y=function(t){function e(){var e=this;t.call(this);this._align="center";this._data=[];this._direction="row";this._duration=600;this._height=200;this._id=o.accessor("id");this._label=o.accessor("id");this._lineData=[];this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._shape=o.constant("Rect");this._shapeConfig={duration:this._duration,fill:o.accessor("color"),height:o.constant(10),hitArea:function(t){var n=e._lineData[e._data.indexOf(t)],r=i.max([n.height,n.shapeHeight]);return{width:n.width+n.shapeWidth,height:r,x:-n.shapeWidth/2,y:-r/2}},labelBounds:function(t,i,n){var r=e._lineData[t.i],h=n.r!==void 0?n.r:n.width/2;return{width:r.width,height:r.height,x:h+e._padding,y:-r.height/2}},labelConfig:{fontColor:o.constant("#444"),fontFamily:(new l.TextBox).fontFamily(),fontResize:false,fontSize:o.constant(10)},opacity:1,r:o.constant(5),width:o.constant(10),x:function(t,i){var n=e._shapeConfig.width;var r=e._lineData[i].y;var h=e._align==="left"||e._align==="right"&&e._direction==="column"?0:e._align==="center"?(e._outerBounds.width-e._rowWidth(e._lineData.filter(function(t){return r===t.y})))/2:e._outerBounds.width-e._rowWidth(e._lineData.filter(function(t){return r===t.y}));var s=e._lineData.slice(0,i).filter(function(t){return r===t.y});return e._rowWidth(s)+e._padding*(s.length?2:0)+e._outerBounds.x+n(t,i)/2+h},y:function(t,n){var r=e._shapeConfig.height;var h=e._lineData[n];return h.y+e._titleHeight+e._outerBounds.y+i.max(e._lineData.filter(function(t){return h.y===t.y}).map(function(t){return t.height}).concat(e._data.map(function(t,i){return r(t,i)})))/2}};this._titleConfig={fontFamily:"Verdana",fontSize:12,lineHeight:13};this._verticalAlign="middle";this._width=400}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype._fetchConfig=function t(i,e,n){var r=this._shapeConfig[i]||this._shapeConfig.labelConfig[i];return typeof r==="function"?r(e,n):r};e.prototype._rowHeight=function t(e){return i.max(e.map(function(t){return t.height}).concat(e.map(function(t){return t.shapeHeight})))+this._padding};e.prototype._rowWidth=function t(e){var n=this;return i.sum(e.map(function(t,i){var r=n._padding*(i===e.length-1?0:t.width?2:1);return t.shapeWidth+t.width+r}))};e.prototype.render=function t(e){var n=this;if(this._select===void 0){this.select(r.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}if(this._lineHeight===void 0){this._lineHeight=function(t,i){return n._fetchConfig("fontSize",t,i)*1.1}}this._group=o.elem("g.d3plus-Legend",{parent:this._select});var h=this._height;this._titleHeight=0;if(this._title){var s=this._titleConfig.fontFamily,u=this._titleConfig.lineHeight,d=this._titleConfig.fontSize;var _=l.textWrap().fontFamily(s).fontSize(d).lineHeight(u).width(this._width).height(this._height)(this._title);this._titleHeight=u+_.lines.length+this._padding;h-=this._titleHeight}this._lineData=this._data.map(function(t,e){var r=n._fetchConfig("fontFamily",t,e),s=n._lineHeight(t,e),o=n._fetchConfig("fontSize",t,e),a=n._fetchConfig("width",t,e);var u=h-(n._data.length+1)*n._padding,d=n._width;var _=l.textWrap().fontFamily(r).fontSize(o).lineHeight(s).width(d).height(u)(n._label(t,e));_.width=Math.ceil(i.max(_.lines.map(function(t){return l.textWidth(t,{"font-family":r,"font-size":o})})))+o*.75;_.height=Math.ceil(_.lines.length*(s+1));_.og={height:_.height,width:_.width};_.data=t;_.f=r;_.s=o;_.lh=s;_.y=0;_.id=n._id(t,e);_.i=e;_.shapeWidth=a;_.shapeHeight=n._fetchConfig("height",t,e);return _});var c;var f=this._width-this._padding*2;c=this._rowWidth(this._lineData);if(this._direction==="column"||c>f){var g=1,p=[];var v=i.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var t=this;g++;if(g>v){return}var e=g===1?this._lineData.slice():this._lineData.filter(function(i){return i.width+i.shapeWidth+t._padding*(i.width?2:1)>f&&i.words.length>=g}).sort(function(t,i){return i.sentence.length-t.sentence.length});if(e.length&&h>e[0].height*g){var n=false;var r=function(t){var r=e[t];var h=r.og.height*g,s=r.og.width*(1.5*(1/g));var o=l.textWrap().fontFamily(r.f).fontSize(r.s).lineHeight(r.lh).width(s).height(h)(r.sentence);if(!o.truncated){r.width=Math.ceil(i.max(o.lines.map(function(t){return l.textWidth(t,{"font-family":r.f,"font-size":r.s})})))+r.s;r.height=o.lines.length*(r.lh+1)}else{n=true;return"break"}};for(var s=0;s<e.length;s++){var o=r(s);if(o==="break")break}if(!n){this._wrapRows()}}else{p=[];return}};this._wrapRows=function(){var t=this;p=[];var e=1,n=0;for(var r=0;r<this._lineData.length;r++){var s=t._lineData[r],o=s.width+t._padding*(s.width?2:1)+s.shapeWidth;if(i.sum(p.map(function(t){return i.max(t,function(t){return i.max([t.height,t.shapeHeight])})}))>h){p=[];break}if(o>f){p=[];t._wrapLines();break}else if(n+o<f){n+=o}else if(t._direction!=="column"){n=o;e++}if(!p[e-1]){p[e-1]=[]}p[e-1].push(s);if(t._direction==="column"){n=0;e++}}};this._wrapRows();if(!p.length||i.sum(p,this._rowHeight.bind(this))+this._padding>h){c=i.sum(this._lineData.map(function(t){return t.shapeWidth+n._padding}))-this._padding;for(var y=0;y<this._lineData.length;y++){n._lineData[y].width=0;n._lineData[y].height=0}this._wrapRows()}if(p.length&&i.sum(p,this._rowHeight.bind(this))+this._padding<h){p.forEach(function(t,e){t.forEach(function(t){if(e){t.y=i.sum(p.slice(0,e),n._rowHeight.bind(n))}})});c=i.max(p,this._rowWidth.bind(this))}}var w=i.max(this._lineData,function(t,e){return i.max([t.height,n._fetchConfig("height",t.data,e)])+t.y})+this._titleHeight,m=c;this._outerBounds.width=m;this._outerBounds.height=w;var x=this._padding,C=this._padding;if(this._align==="center"){x=(this._width-m)/2}else if(this._align==="right"){x=this._width-this._padding-m}if(this._verticalAlign==="middle"){C=(this._height-w)/2}else if(this._verticalAlign==="bottom"){C=this._height-this._padding-w}this._outerBounds.x=x;this._outerBounds.y=C;(new l.TextBox).data(this._title?[{text:this._title}]:[]).duration(this._duration).select(this._group.node()).textAnchor({left:"start",center:"middle",right:"end"}[this._align]).width(this._width-this._padding*2).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render();this._shapes=[];var b=this._shapeConfig,B={id:function(t){return t.id},label:function(t){return t.label},lineHeight:function(t){return t.lH}};var H=this._data.map(function(t,i){var e={__d3plus__:true,data:t,i:i,id:n._id(t,i),label:n._lineData[i].width?n._label(t,i):false,lH:n._lineHeight(t,i),shape:n._shape(t,i)};var r=function(n){if(n!=="labelBounds"&&{}.hasOwnProperty.call(b,n)){if(typeof b[n]==="function"){e[n]=b[n](t,i);B[n]=function(t){return t[n]}}else if(n==="on"){B[n]={};for(var r in b[n]){if({}.hasOwnProperty.call(b[n],r)){var h=b[n][r];B[n][r]=function(t){if(!h){return}h.bind(this)(t.data,t.i)}}}}}};for(var h in b)r(h);return e});this._shapes=[];["Circle","Rect"].forEach(function(t){n._shapes.push((new a[t]).data(H.filter(function(i){return i.shape===t})).duration(n._duration).labelPadding(0).select(n._group.node()).verticalAlign("top").config(o.assign({},b,B)).render())});if(e){setTimeout(e,this._duration+100)}return this};e.prototype.active=function t(i){this._shapes.forEach(function(t){return t.active(i)});return this};e.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};e.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};e.prototype.direction=function t(i){return arguments.length?(this._direction=i,this):this._direction};e.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};e.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};e.prototype.hover=function t(i){this._shapes.forEach(function(t){return t.hover(i)});return this};e.prototype.id=function t(i){return arguments.length?(this._id=i,this):this._id};e.prototype.label=function t(i){return arguments.length?(this._label=typeof i==="function"?i:o.constant(i),this):this._label};e.prototype.outerBounds=function t(){return this._outerBounds};e.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};e.prototype.select=function t(i){return arguments.length?(this._select=r.select(i),this):this._select};e.prototype.shape=function t(i){return arguments.length?(this._shape=typeof i==="function"?i:o.constant(i),this):this._shape};e.prototype.shapeConfig=function t(i){return arguments.length?(this._shapeConfig=o.assign(this._shapeConfig,i),this):this._shapeConfig};e.prototype.title=function t(i){return arguments.length?(this._title=i,this):this._title};e.prototype.titleConfig=function t(i){return arguments.length?(this._titleConfig=o.assign(this._titleConfig,i),this):this._titleConfig};e.prototype.verticalAlign=function t(i){return arguments.length?(this._verticalAlign=i,this):this._verticalAlign};e.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return e}(o.BaseClass);t.ckmeans=p;t.ColorScale=v;t.Legend=y;Object.defineProperty(t,"__esModule",{value:true})});
(function(t,i){typeof exports==="object"&&typeof module!=="undefined"?i(exports,require("d3-array"),require("d3-interpolate"),require("d3-scale"),require("d3-selection"),require("d3plus-axis"),require("d3plus-color"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-text")):typeof define==="function"&&define.amd?define("d3plus-legend",["exports","d3-array","d3-interpolate","d3-scale","d3-selection","d3plus-axis","d3plus-color","d3plus-common","d3plus-shape","d3plus-text"],i):i(t.d3plus=t.d3plus||{},t.d3Array,t.d3Interpolate,t.d3Scale,t.d3Selection,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.shapes,t.d3plusText)})(this,function(t,i,e,n,r,h,s,o,a,l){"use strict";function u(t){return t.slice().sort(function(t,i){return t-i})}function d(t){var i,e=0;for(var n=0;n<t.length;n++){if(n===0||t[n]!==i){i=t[n];e++}}return e}function _(t,i){var e=[];for(var n=0;n<t;n++){var r=[];for(var h=0;h<i;h++){r.push(0)}e.push(r)}return e}function c(t,i,e,n){var r;if(t>0){var h=(e[i]-e[t-1])/(i-t+1);r=n[i]-n[t-1]-(i-t+1)*h*h}else{r=n[i]-e[i]*e[i]/(i+1)}if(r<0){return 0}return r}function g(t,i,e,n,r,h,s){if(t>i){return}var o=Math.floor((t+i)/2);n[e][o]=n[e-1][o-1];r[e][o]=o;var a=e;if(t>e){a=Math.max(a,r[e][t-1]||0)}a=Math.max(a,r[e-1][o]||0);var l=o-1;if(i<n.length-1){l=Math.min(l,r[e][i+1]||0)}for(var u=l;u>=a;--u){var d=c(u,o,h,s);if(d+n[e-1][a-1]>=n[e][o]){break}var _=c(a,o,h,s);var f=_+n[e-1][a-1];if(f<n[e][o]){n[e][o]=f;r[e][o]=a}a++;var p=d+n[e-1][u-1];if(p<n[e][o]){n[e][o]=p;r[e][o]=u}}g(t,o-1,e,n,r,h,s);g(o+1,i,e,n,r,h,s)}function f(t,i,e){var n=i[0].length;var r=t[Math.floor(n/2)];var h=[];var s=[];for(var o=0,a=void 0;o<n;++o){a=t[o]-r;if(o===0){h.push(a);s.push(a*a)}else{h.push(h[o-1]+a);s.push(s[o-1]+a*a)}i[0][o]=c(0,o,h,s);e[0][o]=0}for(var l=1;l<i.length;++l){var u=n-1;if(l<i.length-1){u=l}g(u,n-1,l,i,e,h,s)}}var p=function(t,i){if(i>t.length){throw new Error("Cannot generate more classes than there are data values")}var e=u(t);var n=d(e);if(n===1){return[e]}var r=_(i,e.length),h=_(i,e.length);f(e,h,r);var s=r[0].length-1;var o=[];for(var a=r.length-1;a>=0;a--){var l=r[a][s];o[a]=e.slice(l,s+1);if(a>0){s=l-1}}return o};var v=function(t){function l(){t.call(this);this._axisClass=new h.Axis;this._axisConfig={gridSize:0};this._axisTest=new h.Axis;this._align="middle";this._color="#0C8040";this._data=[];this._duration=600;this._height=200;this._orient="bottom";this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._rectClass=new a.Rect;this._rectConfig={stroke:"#000",strokeWidth:1};this._scale="linear";this._size=10;this._value=o.accessor("value");this._width=400}if(t)l.__proto__=t;l.prototype=Object.create(t&&t.prototype);l.prototype.constructor=l;l.prototype.render=function t(h){var a=this;if(this._select===void 0){this.select(r.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}var l=["bottom","top"].includes(this._orient);var u=l?"height":"width",d=l?"width":"height",_=l?"x":"y",c=l?"y":"x";this._group=o.elem("g.d3plus-ColorScale",{parent:this._select});var g=i.extent(this._data,this._value);var f=this._color,v;if(!(f instanceof Array)){f=[s.colorLighter(f,.9),s.colorLighter(f,.75),s.colorLighter(f,.5),s.colorLighter(f,.25),f]}if(this._scale==="jenks"){var y=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});if(y.length<=f.length){var m=n.scaleLinear().domain(i.range(0,y.length-1)).interpolate(e.interpolateHsl).range(f);f=y.slice(0,y.length-1).map(function(t,i){return m(i)})}var w=p(y,f.length);v=i.merge(w.map(function(t,i){return i===w.length-1?[t[0],t[t.length-1]]:[t[0]]}));this._colorScale=n.scaleThreshold().domain(v).range(["black"].concat(f).concat(f[f.length-1]))}else{var x=(g[1]-g[0])/f.length;var C=i.range(g[0],g[1]+x/2,x);if(this._scale==="buckets"){v=C}this._colorScale=n.scaleLinear().domain(C).range(f)}var b=Object.assign({domain:l?g:g.reverse(),duration:this._duration,height:this._height,labels:v,orient:this._orient,padding:this._padding,ticks:v,width:this._width},this._axisConfig);this._axisTest.select(o.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(b).render();var B=this._axisTest.outerBounds();this._outerBounds[d]=this["_"+d]-this._padding*2;this._outerBounds[u]=B[u]+this._size;this._outerBounds[_]=this._padding;this._outerBounds[c]=this._padding;if(this._align==="middle"){this._outerBounds[c]=(this["_"+u]-this._outerBounds[u])/2}else if(this._align==="end"){this._outerBounds[c]=this["_"+u]-this._padding-this._outerBounds[u]}var H=this._outerBounds[c]+(["bottom","right"].includes(this._orient)?this._size:0)-(b.padding||this._axisClass.padding());this._axisClass.select(o.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate("+(l?0:H)+", "+(l?H:0)+")"}}).node()).config(b).align("start").render();var D=this._axisTest._d3Scale;var S=D.range();var z=this._group.selectAll("defs").data([0]);var W=z.enter().append("defs");W.append("linearGradient").attr("id","gradient-"+this._uuid);z=W.merge(z);z.select("linearGradient").attr(_+"1",l?"0%":"100%").attr(_+"2",l?"100%":"0%").attr(c+"1","0%").attr(c+"2","0%");var A=z.select("linearGradient").selectAll("stop").data(f);A.enter().append("stop").merge(A).attr("offset",function(t,i){return i/(f.length-1)*100+"%"}).attr("stop-color",String);function k(t,i){return Math.abs(D(v[i+1])-D(t))}this._rectClass.data(v?v.slice(0,v.length-1):[0]).id(function(t,i){return i}).select(o.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config((T={fill:v?function(t){return a._colorScale(t)}:"url(#gradient-"+this._uuid+")"},T[_]=v?function(t,i){return D(t)+k(t,i)/2-(["left","right"].includes(a._orient)?k(t,i):0)}:S[0]+(S[1]-S[0])/2,T[c]=this._outerBounds[c]+(["top","left"].includes(this._orient)?B[u]:0)+this._size/2,T[d]=v?k:S[1]-S[0],T[u]=this._size,T)).config(this._rectConfig).render();var T;if(h){setTimeout(h,this._duration+100)}return this};l.prototype.axisConfig=function t(i){return arguments.length?(this._axisConfig=Object.assign(this._axisConfig,i),this):this._axisConfig};l.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};l.prototype.color=function t(i){return arguments.length?(this._color=i,this):this._color};l.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};l.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};l.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};l.prototype.orient=function t(i){return arguments.length?(this._orient=i,this):this._orient};l.prototype.outerBounds=function t(){return this._outerBounds};l.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};l.prototype.rectConfig=function t(i){return arguments.length?(this._rectConfig=Object.assign(this._rectConfig,i),this):this._rectConfig};l.prototype.scale=function t(i){return arguments.length?(this._scale=i,this):this._scale};l.prototype.select=function t(i){return arguments.length?(this._select=r.select(i),this):this._select};l.prototype.size=function t(i){return arguments.length?(this._size=i,this):this._size};l.prototype.value=function t(i){return arguments.length?(this._value=typeof i==="function"?i:o.constant(i),this):this._value};l.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return l}(o.BaseClass);var y=function(t){function e(){var e=this;t.call(this);this._align="center";this._data=[];this._direction="row";this._duration=600;this._height=200;this._id=o.accessor("id");this._label=o.accessor("id");this._lineData=[];this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._shape=o.constant("Rect");this._shapeConfig={duration:this._duration,fill:o.accessor("color"),height:o.constant(10),hitArea:function(t,n){var r=e._lineData[n],h=i.max([r.height,r.shapeHeight]);return{width:r.width+r.shapeWidth,height:h,x:-r.shapeWidth/2,y:-h/2}},labelBounds:function(t,i,n){var r=e._lineData[i],h=n.r!==void 0?n.r:n.width/2;return{width:r.width,height:r.height,x:h+e._padding,y:-r.height/2}},labelConfig:{fontColor:o.constant("#444"),fontFamily:(new l.TextBox).fontFamily(),fontResize:false,fontSize:o.constant(10)},opacity:1,r:o.constant(5),width:o.constant(10),x:function(t,i){var n=e._shapeConfig.width;var r=e._lineData[i].y;var h=e._align==="left"||e._align==="right"&&e._direction==="column"?0:e._align==="center"?(e._outerBounds.width-e._rowWidth(e._lineData.filter(function(t){return r===t.y})))/2:e._outerBounds.width-e._rowWidth(e._lineData.filter(function(t){return r===t.y}));var s=e._lineData.slice(0,i).filter(function(t){return r===t.y});return e._rowWidth(s)+e._padding*(s.length?2:0)+e._outerBounds.x+n(t,i)/2+h},y:function(t,n){var r=e._shapeConfig.height;var h=e._lineData[n];return h.y+e._titleHeight+e._outerBounds.y+i.max(e._lineData.filter(function(t){return h.y===t.y}).map(function(t){return t.height}).concat(e._data.map(function(t,i){return r(t,i)})))/2}};this._titleConfig={fontFamily:"Verdana",fontSize:12,lineHeight:13};this._verticalAlign="middle";this._width=400}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype._fetchConfig=function t(i,e,n){var r=this._shapeConfig[i]||this._shapeConfig.labelConfig[i];return typeof r==="function"?r(e,n):r};e.prototype._rowHeight=function t(e){return i.max(e.map(function(t){return t.height}).concat(e.map(function(t){return t.shapeHeight})))+this._padding};e.prototype._rowWidth=function t(e){var n=this;return i.sum(e.map(function(t,i){var r=n._padding*(i===e.length-1?0:t.width?2:1);return t.shapeWidth+t.width+r}))};e.prototype.render=function t(e){var n=this;if(this._select===void 0){this.select(r.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}if(this._lineHeight===void 0){this._lineHeight=function(t,i){return n._fetchConfig("fontSize",t,i)*1.1}}this._group=o.elem("g.d3plus-Legend",{parent:this._select});var h=this._height;this._titleHeight=0;if(this._title){var s=this._titleConfig.fontFamily,u=this._titleConfig.lineHeight,d=this._titleConfig.fontSize;var _=l.textWrap().fontFamily(s).fontSize(d).lineHeight(u).width(this._width).height(this._height)(this._title);this._titleHeight=u+_.lines.length+this._padding;h-=this._titleHeight}this._lineData=this._data.map(function(t,e){var r=n._fetchConfig("fontFamily",t,e),s=n._lineHeight(t,e),o=n._fetchConfig("fontSize",t,e),a=n._fetchConfig("width",t,e);var u=h-(n._data.length+1)*n._padding,d=n._width;var _=l.textWrap().fontFamily(r).fontSize(o).lineHeight(s).width(d).height(u)(n._label(t,e));_.width=Math.ceil(i.max(_.lines.map(function(t){return l.textWidth(t,{"font-family":r,"font-size":o})})))+o*.75;_.height=Math.ceil(_.lines.length*(s+1));_.og={height:_.height,width:_.width};_.data=t;_.f=r;_.s=o;_.lh=s;_.y=0;_.id=n._id(t,e);_.i=e;_.shapeWidth=a;_.shapeHeight=n._fetchConfig("height",t,e);return _});var c;var g=this._width-this._padding*2;c=this._rowWidth(this._lineData);if(this._direction==="column"||c>g){var f=1,p=[];var v=i.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var t=this;f++;if(f>v){return}var e=f===1?this._lineData.slice():this._lineData.filter(function(i){return i.width+i.shapeWidth+t._padding*(i.width?2:1)>g&&i.words.length>=f}).sort(function(t,i){return i.sentence.length-t.sentence.length});if(e.length&&h>e[0].height*f){var n=false;var r=function(t){var r=e[t];var h=r.og.height*f,s=r.og.width*(1.5*(1/f));var o=l.textWrap().fontFamily(r.f).fontSize(r.s).lineHeight(r.lh).width(s).height(h)(r.sentence);if(!o.truncated){r.width=Math.ceil(i.max(o.lines.map(function(t){return l.textWidth(t,{"font-family":r.f,"font-size":r.s})})))+r.s;r.height=o.lines.length*(r.lh+1)}else{n=true;return"break"}};for(var s=0;s<e.length;s++){var o=r(s);if(o==="break")break}if(!n){this._wrapRows()}}else{p=[];return}};this._wrapRows=function(){var t=this;p=[];var e=1,n=0;for(var r=0;r<this._lineData.length;r++){var s=t._lineData[r],o=s.width+t._padding*(s.width?2:1)+s.shapeWidth;if(i.sum(p.map(function(t){return i.max(t,function(t){return i.max([t.height,t.shapeHeight])})}))>h){p=[];break}if(o>g){p=[];t._wrapLines();break}else if(n+o<g){n+=o}else if(t._direction!=="column"){n=o;e++}if(!p[e-1]){p[e-1]=[]}p[e-1].push(s);if(t._direction==="column"){n=0;e++}}};this._wrapRows();if(!p.length||i.sum(p,this._rowHeight.bind(this))+this._padding>h){c=i.sum(this._lineData.map(function(t){return t.shapeWidth+n._padding}))-this._padding;for(var y=0;y<this._lineData.length;y++){n._lineData[y].width=0;n._lineData[y].height=0}this._wrapRows()}if(p.length&&i.sum(p,this._rowHeight.bind(this))+this._padding<h){p.forEach(function(t,e){t.forEach(function(t){if(e){t.y=i.sum(p.slice(0,e),n._rowHeight.bind(n))}})});c=i.max(p,this._rowWidth.bind(this))}}var m=i.max(this._lineData,function(t,e){return i.max([t.height,n._fetchConfig("height",t.data,e)])+t.y})+this._titleHeight,w=c;this._outerBounds.width=w;this._outerBounds.height=m;var x=this._padding,C=this._padding;if(this._align==="center"){x=(this._width-w)/2}else if(this._align==="right"){x=this._width-this._padding-w}if(this._verticalAlign==="middle"){C=(this._height-m)/2}else if(this._verticalAlign==="bottom"){C=this._height-this._padding-m}this._outerBounds.x=x;this._outerBounds.y=C;(new l.TextBox).data(this._title?[{text:this._title}]:[]).duration(this._duration).select(this._group.node()).textAnchor({left:"start",center:"middle",right:"end"}[this._align]).width(this._width-this._padding*2).x(this._padding).y(this._outerBounds.y).config(this._titleConfig).render();this._shapes=[];var b=o.configPrep.bind(this)(this._shapeConfig,"legend"),B={id:function(t){return t.id},label:function(t){return t.label},lineHeight:function(t){return t.lH}};var H=this._data.map(function(t,i){var e={__d3plus__:true,data:t,i:i,id:n._id(t,i),label:n._lineData[i].width?n._label(t,i):false,lH:n._lineHeight(t,i),shape:n._shape(t,i)};return e});this._shapes=[];["Circle","Rect"].forEach(function(t){n._shapes.push((new a[t]).data(H.filter(function(i){return i.shape===t})).duration(n._duration).labelPadding(0).select(n._group.node()).verticalAlign("top").config(o.assign({},b,B)).render())});if(e){setTimeout(e,this._duration+100)}return this};e.prototype.active=function t(i){this._shapes.forEach(function(t){return t.active(i)});return this};e.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};e.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};e.prototype.direction=function t(i){return arguments.length?(this._direction=i,this):this._direction};e.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};e.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};e.prototype.hover=function t(i){this._shapes.forEach(function(t){return t.hover(i)});return this};e.prototype.id=function t(i){return arguments.length?(this._id=i,this):this._id};e.prototype.label=function t(i){return arguments.length?(this._label=typeof i==="function"?i:o.constant(i),this):this._label};e.prototype.outerBounds=function t(){return this._outerBounds};e.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};e.prototype.select=function t(i){return arguments.length?(this._select=r.select(i),this):this._select};e.prototype.shape=function t(i){return arguments.length?(this._shape=typeof i==="function"?i:o.constant(i),this):this._shape};e.prototype.shapeConfig=function t(i){return arguments.length?(this._shapeConfig=o.assign(this._shapeConfig,i),this):this._shapeConfig};e.prototype.title=function t(i){return arguments.length?(this._title=i,this):this._title};e.prototype.titleConfig=function t(i){return arguments.length?(this._titleConfig=o.assign(this._titleConfig,i),this):this._titleConfig};e.prototype.verticalAlign=function t(i){return arguments.length?(this._verticalAlign=i,this):this._verticalAlign};e.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return e}(o.BaseClass);t.ckmeans=p;t.ColorScale=v;t.Legend=y;Object.defineProperty(t,"__esModule",{value:true})});
{
"name": "d3plus-legend",
"version": "0.8.7",
"version": "0.8.8",
"description": "An easy to use javascript chart legend.",

@@ -32,3 +32,3 @@ "main": "build/d3plus-legend.js",

"d3plus-color": "^0.6.0",
"d3plus-common": "^0.6.16",
"d3plus-common": "^0.6.17",
"d3plus-shape": "^0.13.1",

@@ -35,0 +35,0 @@ "d3plus-text": "^0.9.15"

@@ -224,3 +224,3 @@ # d3plus-legend

<a name="Legend.active" href="Legend.active">#</a> Legend.**active**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L361)
<a name="Legend.active" href="Legend.active">#</a> Legend.**active**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L340)

@@ -232,3 +232,3 @@ If *value* is specified, sets the active method for all shapes to the specified function and returns the current class instance. If *value* is not specified, returns the current active method.

<a name="Legend.align" href="Legend.align">#</a> Legend.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L372)
<a name="Legend.align" href="Legend.align">#</a> Legend.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L351)

@@ -240,3 +240,3 @@ If *value* is specified, sets the horizontal alignment to the specified value and returns the current class instance. If *value* is not specified, returns the current horizontal alignment.

<a name="Legend.data" href="Legend.data">#</a> Legend.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L382)
<a name="Legend.data" href="Legend.data">#</a> Legend.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L361)

@@ -248,3 +248,3 @@ If *data* is specified, sets the data array to the specified array and returns the current class instance. If *data* is not specified, returns the current data array. A shape key will be drawn for each object in the array.

<a name="Legend.direction" href="Legend.direction">#</a> Legend.**direction**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L392)
<a name="Legend.direction" href="Legend.direction">#</a> Legend.**direction**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L371)

@@ -256,3 +256,3 @@ Sets the flow of the items inside the legend. If no value is passed, the current flow will be returned.

<a name="Legend.duration" href="Legend.duration">#</a> Legend.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L402)
<a name="Legend.duration" href="Legend.duration">#</a> Legend.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L381)

@@ -264,3 +264,3 @@ If *value* is specified, sets the transition duration of the legend and returns the current class instance. If *value* is not specified, returns the current duration.

<a name="Legend.height" href="Legend.height">#</a> Legend.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L412)
<a name="Legend.height" href="Legend.height">#</a> Legend.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L391)

@@ -272,3 +272,3 @@ If *value* is specified, sets the overall height of the legend and returns the current class instance. If *value* is not specified, returns the current height value.

<a name="Legend.hover" href="Legend.hover">#</a> Legend.**hover**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L422)
<a name="Legend.hover" href="Legend.hover">#</a> Legend.**hover**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L401)

@@ -280,3 +280,3 @@ If *value* is specified, sets the hover method for all shapes to the specified function and returns the current class instance. If *value* is not specified, returns the current hover method.

<a name="Legend.id" href="Legend.id">#</a> Legend.**id**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L437)
<a name="Legend.id" href="Legend.id">#</a> Legend.**id**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L416)

@@ -294,3 +294,3 @@ If *value* is specified, sets the id accessor to the specified function and returns the current class instance. If *value* is not specified, returns the current id accessor.

```
<a name="Legend.label" href="Legend.label">#</a> Legend.**label**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L447)
<a name="Legend.label" href="Legend.label">#</a> Legend.**label**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L426)

@@ -302,3 +302,3 @@ If *value* is specified, sets the label accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current label accessor, which is the [id](#shape.id) accessor by default.

<a name="Legend.outerBounds" href="Legend.outerBounds">#</a> Legend.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L457)
<a name="Legend.outerBounds" href="Legend.outerBounds">#</a> Legend.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L436)

@@ -314,3 +314,3 @@ If called after the elements have been drawn to DOM, will returns the outer bounds of the legend content.

```
<a name="Legend.padding" href="Legend.padding">#</a> Legend.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L467)
<a name="Legend.padding" href="Legend.padding">#</a> Legend.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L446)

@@ -322,3 +322,3 @@ If *value* is specified, sets the padding between each key to the specified number and returns the current class instance. If *value* is not specified, returns the current padding value.

<a name="Legend.select" href="Legend.select">#</a> Legend.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L477)
<a name="Legend.select" href="Legend.select">#</a> Legend.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L456)

@@ -330,3 +330,3 @@ If *selector* is specified, sets the SVG container element to the specified d3 selector or DOM element and returns the current class instance. If *selector* is not specified, returns the current SVG container element.

<a name="Legend.shape" href="Legend.shape">#</a> Legend.**shape**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L487)
<a name="Legend.shape" href="Legend.shape">#</a> Legend.**shape**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L466)

@@ -338,3 +338,3 @@ If *value* is specified, sets the shape accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current shape accessor.

<a name="Legend.shapeConfig" href="Legend.shapeConfig">#</a> Legend.**shapeConfig**([*config*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L497)
<a name="Legend.shapeConfig" href="Legend.shapeConfig">#</a> Legend.**shapeConfig**([*config*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L476)

@@ -346,3 +346,3 @@ If *config* is specified, sets the methods that correspond to the key/value pairs for each shape and returns the current class instance. If *config* is not specified, returns the current shape configuration.

<a name="Legend.title" href="Legend.title">#</a> Legend.**title**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L507)
<a name="Legend.title" href="Legend.title">#</a> Legend.**title**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L486)

@@ -354,3 +354,3 @@ If *value* is specified, sets the title of the legend and returns the current class instance. If *value* is not specified, returns the current title.

<a name="Legend.titleConfig" href="Legend.titleConfig">#</a> Legend.**titleConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L517)
<a name="Legend.titleConfig" href="Legend.titleConfig">#</a> Legend.**titleConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L496)

@@ -362,3 +362,3 @@ If *value* is specified, sets the title configuration of the legend and returns the current class instance. If *value* is not specified, returns the current title configuration.

<a name="Legend.verticalAlign" href="Legend.verticalAlign">#</a> Legend.**verticalAlign**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L527)
<a name="Legend.verticalAlign" href="Legend.verticalAlign">#</a> Legend.**verticalAlign**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L506)

@@ -370,3 +370,3 @@ If *value* is specified, sets the vertical alignment to the specified value and returns the current class instance. If *value* is not specified, returns the current vertical alignment.

<a name="Legend.width" href="Legend.width">#</a> Legend.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L537)
<a name="Legend.width" href="Legend.width">#</a> Legend.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/Legend.js#L516)

@@ -380,2 +380,2 @@ If *value* is specified, sets the overall width of the legend and returns the current class instance. If *value* is not specified, returns the current width value.

###### <sub>Documentation generated on Tue, 23 May 2017 20:52:30 GMT</sub>
###### <sub>Documentation generated on Wed, 24 May 2017 16:36:35 GMT</sub>

@@ -9,3 +9,3 @@ /**

import {accessor, assign, BaseClass, constant, elem} from "d3plus-common";
import {accessor, assign, BaseClass, configPrep, constant, elem} from "d3plus-common";
import * as shapes from "d3plus-shape";

@@ -45,4 +45,4 @@ import {TextBox, textWidth, textWrap} from "d3plus-text";

height: constant(10),
hitArea: dd => {
const d = this._lineData[this._data.indexOf(dd)],
hitArea: (dd, i) => {
const d = this._lineData[i],
h = max([d.height, d.shapeHeight]);

@@ -52,3 +52,3 @@ return {width: d.width + d.shapeWidth, height: h, x: -d.shapeWidth / 2, y: -h / 2};

labelBounds: (dd, i, s) => {
const d = this._lineData[dd.i],
const d = this._lineData[i],
w = s.r !== void 0 ? s.r : s.width / 2;

@@ -294,3 +294,3 @@ return {width: d.width, height: d.height, x: w + this._padding, y: -d.height / 2};

this._shapes = [];
const baseConfig = this._shapeConfig,
const baseConfig = configPrep.bind(this)(this._shapeConfig, "legend"),
config = {

@@ -313,23 +313,2 @@ id: d => d.id,

for (const k in baseConfig) {
if (k !== "labelBounds" && {}.hasOwnProperty.call(baseConfig, k)) {
if (typeof baseConfig[k] === "function") {
obj[k] = baseConfig[k](d, i);
config[k] = d => d[k];
}
else if (k === "on") {
config[k] = {};
for (const t in baseConfig[k]) {
if ({}.hasOwnProperty.call(baseConfig[k], t)) {
const f = baseConfig[k][t];
config[k][t] = function(dd) {
if (!f) return;
f.bind(this)(dd.data, dd.i);
};
}
}
}
}
}
return obj;

@@ -336,0 +315,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

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