d3plus-legend
Advanced tools
Comparing version 0.8.16 to 0.8.17
/* | ||
d3plus-legend v0.8.16 | ||
d3plus-legend v0.8.17 | ||
An easy to use javascript chart legend. | ||
@@ -386,3 +386,3 @@ Copyright (c) 2018 D3plus - https://d3plus.org | ||
var domain = d3Array.extent(this._data, this._value); | ||
var colors = this._color, ticks; | ||
var colors = this._color, labels, ticks; | ||
@@ -419,2 +419,8 @@ if (!(colors instanceof Array)) { | ||
var tickSet = new Set(ticks); | ||
if (ticks.length !== tickSet.size) { | ||
labels = Array.from(tickSet); | ||
} | ||
this._colorScale = d3Scale.scaleThreshold() | ||
@@ -442,3 +448,3 @@ .domain(ticks) | ||
height: this._height, | ||
labels: ticks, | ||
labels: labels || ticks, | ||
orient: this._orient, | ||
@@ -1015,3 +1021,3 @@ padding: this._padding, | ||
.duration(this$1._duration) | ||
.labelPadding(0) | ||
.labelConfig({padding: 0}) | ||
.select(this$1._group.node()) | ||
@@ -1018,0 +1024,0 @@ .verticalAlign("top") |
/* | ||
d3plus-legend v0.8.16 | ||
d3plus-legend v0.8.17 | ||
An easy to use javascript chart legend. | ||
@@ -7,2 +7,2 @@ Copyright (c) 2018 D3plus - https://d3plus.org | ||
*/ | ||
if(typeof Object.assign!=="function"){Object.defineProperty(Object,"assign",{value:function t(i){"use strict";if(i===null){throw new TypeError("Cannot convert undefined or null to object")}var e=Object(i);for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r!==null){for(var h in r){if(Object.prototype.hasOwnProperty.call(r,h)){e[h]=r[h]}}}}return e},writable:true,configurable:true})}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function t(i,e){var n=Object(this);var r=n.length>>>0;if(r===0)return false;var h=e|0;var s=Math.max(h>=0?h:r-Math.abs(h),0);function o(t,i){return t===i||typeof t==="number"&&typeof i==="number"&&isNaN(t)&&isNaN(i)}while(s<r){if(o(n[s],i)){return true}s++}return false}})}(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.d3Array,t.d3Interpolate,t.d3Scale,t.d3Selection,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.shapes,t.d3plusText)})(this,function(t,D,z,S,W,e,A,j,x,C){"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 g(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 p(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=g(u,o,h,s);if(d+n[e-1][a-1]>=n[e][o]){break}var _=g(a,o,h,s);var c=_+n[e-1][a-1];if(c<n[e][o]){n[e][o]=c;r[e][o]=a}a++;var f=d+n[e-1][u-1];if(f<n[e][o]){n[e][o]=f;r[e][o]=u}}p(t,o-1,e,n,r,h,s);p(o+1,i,e,n,r,h,s)}function c(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]=g(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}p(u,n-1,l,i,e,h,s)}}function O(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);c(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 i=function(t){function i(){t.call(this);this._axisClass=new e.Axis;this._axisConfig={gridSize:0};this._axisTest=new e.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 x.Rect;this._rectConfig={stroke:"#000",strokeWidth:1};this._scale="linear";this._size=10;this._value=j.accessor("value");this._width=400}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype.render=function t(i){var e=this;var n;if(this._select===void 0){this.select(W.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}var r=["bottom","top"].includes(this._orient);var h=r?"height":"width",s=r?"width":"height",o=r?"x":"y",a=r?"y":"x";this._group=j.elem("g.d3plus-ColorScale",{parent:this._select});var l=D.extent(this._data,this._value);var u=this._color,d;if(!(u instanceof Array)){u=[A.colorLighter(u,.9),A.colorLighter(u,.75),A.colorLighter(u,.5),A.colorLighter(u,.25),u]}if(this._scale==="jenks"){var _=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});if(_.length<=u.length){var c=S.scaleLinear().domain(D.range(0,_.length-1)).interpolate(z.interpolateHsl).range(u);u=_.slice(0,_.length-1).map(function(t,i){return c(i)})}var f=O(_,u.length);d=D.merge(f.map(function(t,i){return i===f.length-1?[t[0],t[t.length-1]]:[t[0]]}));this._colorScale=S.scaleThreshold().domain(d).range(["black"].concat(u).concat(u[u.length-1]))}else{var g=(l[1]-l[0])/(u.length-1);var p=D.range(l[0],l[1]+g/2,g);if(this._scale==="buckets"){d=p}this._colorScale=S.scaleLinear().domain(p).range(u)}var v=Object.assign({domain:r?l:l.reverse(),duration:this._duration,height:this._height,labels:d,orient:this._orient,padding:this._padding,ticks:d,width:this._width},this._axisConfig);this._axisTest.select(j.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(v).render();var y=this._axisTest.outerBounds();this._outerBounds[s]=this["_"+s]-this._padding*2;this._outerBounds[h]=y[h]+this._size;this._outerBounds[o]=this._padding;this._outerBounds[a]=this._padding;if(this._align==="middle"){this._outerBounds[a]=(this["_"+h]-this._outerBounds[h])/2}else if(this._align==="end"){this._outerBounds[a]=this["_"+h]-this._padding-this._outerBounds[h]}var w=this._outerBounds[a]+(["bottom","right"].includes(this._orient)?this._size:0)-(v.padding||this._axisClass.padding());this._axisClass.select(j.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate("+(r?0:w)+", "+(r?w:0)+")"}}).node()).config(v).align("start").render();var m=this._axisTest._getPosition.bind(this._axisTest);var x=this._axisTest._getRange();var C=this._group.selectAll("defs").data([0]);var b=C.enter().append("defs");b.append("linearGradient").attr("id","gradient-"+this._uuid);C=b.merge(C);C.select("linearGradient").attr(o+"1",r?"0%":"100%").attr(o+"2",r?"100%":"0%").attr(a+"1","0%").attr(a+"2","0%");var B=C.select("linearGradient").selectAll("stop").data(u);B.enter().append("stop").merge(B).attr("offset",function(t,i){return i/(u.length-1)*100+"%"}).attr("stop-color",String);function H(t,i){var e=Math.abs(m(d[i+1])-m(t));return e||2}this._rectClass.data(d?d.slice(0,d.length-1):[0]).id(function(t,i){return i}).select(j.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config((n={fill:d?function(t){return e._colorScale(t)}:"url(#gradient-"+this._uuid+")"},n[o]=d?function(t,i){return m(t)+H(t,i)/2-(["left","right"].includes(e._orient)?H(t,i):0)}:x[0]+(x[1]-x[0])/2,n[a]=this._outerBounds[a]+(["top","left"].includes(this._orient)?y[h]:0)+this._size/2,n[s]=d?H:x[1]-x[0],n[h]=this._size,n)).config(this._rectConfig).render();if(i){setTimeout(i,this._duration+100)}return this};i.prototype.axisConfig=function t(i){return arguments.length?(this._axisConfig=Object.assign(this._axisConfig,i),this):this._axisConfig};i.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};i.prototype.color=function t(i){return arguments.length?(this._color=i,this):this._color};i.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};i.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};i.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};i.prototype.orient=function t(i){return arguments.length?(this._orient=i,this):this._orient};i.prototype.outerBounds=function t(){return this._outerBounds};i.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};i.prototype.rectConfig=function t(i){return arguments.length?(this._rectConfig=Object.assign(this._rectConfig,i),this):this._rectConfig};i.prototype.scale=function t(i){return arguments.length?(this._scale=i,this):this._scale};i.prototype.select=function t(i){return arguments.length?(this._select=W.select(i),this):this._select};i.prototype.size=function t(i){return arguments.length?(this._size=i,this):this._size};i.prototype.value=function t(i){return arguments.length?(this._value=typeof i==="function"?i:j.constant(i),this):this._value};i.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return i}(j.BaseClass);var n=function(t){function i(){var s=this;t.call(this);this._align="center";this._data=[];this._direction="row";this._duration=600;this._height=200;this._id=j.accessor("id");this._label=j.accessor("id");this._lineData=[];this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._shape=j.constant("Rect");this._shapes=[];this._shapeConfig={duration:this._duration,fill:j.accessor("color"),height:j.constant(10),hitArea:function(t,i){var e=s._lineData[i],n=D.max([e.height,e.shapeHeight]);return{width:e.width+e.shapeWidth,height:n,x:-e.shapeWidth/2,y:-n/2}},labelBounds:function(t,i,e){var n=s._lineData[i],r=e.r!==void 0?e.r:e.width/2;return{width:n.width,height:n.height,x:r+s._padding,y:-n.height/2+(n.lh-n.s)/2+1}},labelConfig:{fontColor:j.constant("#444"),fontFamily:(new C.TextBox).fontFamily(),fontResize:false,fontSize:j.constant(10)},opacity:1,r:j.constant(5),width:j.constant(10),x:function(t,i){var e=s._lineData[i];var n=e.y;var r=s._align==="left"||s._align==="right"&&s._direction==="column"?0:s._align==="center"?(s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return n===t.y})))/2:s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return n===t.y}));var h=s._lineData.slice(0,i).filter(function(t){return n===t.y});return s._rowWidth(h)+s._padding*(h.length?e.sentence?2:1:0)+s._outerBounds.x+e.shapeWidth/2+r},y:function(t,i){var e=s._lineData[i];return e.y+s._titleHeight+s._outerBounds.y+D.max(s._lineData.filter(function(t){return e.y===t.y}).map(function(t){return t.height}).concat(s._data.map(function(t,i){return s._fetchConfig("height",t,i)})))/2}};this._titleClass=new C.TextBox;this._titleConfig={};this._verticalAlign="middle";this._width=400}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype._fetchConfig=function t(i,e,n){var r=this._shapeConfig[i]||this._shapeConfig.labelConfig[i];if(!r&&i==="lineHeight"){return this._fetchConfig("fontSize",e,n)*1.4}return typeof r==="function"?r(e,n):r};i.prototype._rowHeight=function t(i){return D.max(i.map(function(t){return t.height}).concat(i.map(function(t){return t.shapeHeight})))+this._padding};i.prototype._rowWidth=function t(n){var r=this;return D.sum(n.map(function(t,i){var e=r._padding*(i===n.length-1?0:t.width?2:1);return t.shapeWidth+t.width+e}))};i.prototype.render=function t(i){var l=this;if(this._select===void 0){this.select(W.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}this._group=j.elem("g.d3plus-Legend",{parent:this._select});var u=this._height;this._titleHeight=0;if(this._title){var e=this._titleConfig.fontFamily||this._titleClass.fontFamily()(),n=this._titleConfig.fontSize||this._titleClass.fontSize()();var r=r=this._titleConfig.lineHeight||this._titleClass.lineHeight();r=r?r():n*1.4;var h=C.textWrap().fontFamily(e).fontSize(n).lineHeight(r).width(this._width).height(this._height)(this._title);this._titleHeight=r+h.lines.length+this._padding;u-=this._titleHeight}this._lineData=this._data.map(function(t,i){var e=l._label(t,i);var n={data:t,i:i,id:l._id(t,i),shapeWidth:l._fetchConfig("width",t,i),shapeHeight:l._fetchConfig("height",t,i),y:0};if(!e){n.sentence=false;n.words=[];n.height=0;n.width=0;return n}var r=l._fetchConfig("fontFamily",t,i),h=l._fetchConfig("lineHeight",t,i),s=l._fetchConfig("fontSize",t,i);var o=u-(l._data.length+1)*l._padding,a=l._width;n=Object.assign(n,C.textWrap().fontFamily(r).fontSize(s).lineHeight(h).width(a).height(o)(e));n.width=Math.ceil(D.max(n.lines.map(function(t){return C.textWidth(t,{"font-family":r,"font-size":s})})))+s*.75;n.height=Math.ceil(n.lines.length*(h+1));n.og={height:n.height,width:n.width};n.f=r;n.s=s;n.lh=h;return n});var s;var o=this._width-this._padding*2;s=this._rowWidth(this._lineData);if(this._direction==="column"||s>o){var a=1,d=[];var _=D.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var i=this;a++;if(a>_){return}var h=a===1?this._lineData.slice():this._lineData.filter(function(t){return t.width+t.shapeWidth+i._padding*(t.width?2:1)>o&&t.words.length>=a}).sort(function(t,i){return i.sentence.length-t.sentence.length});if(h.length&&u>h[0].height*a){var s=false;var t=function(t){var i=h[t];var e=i.og.height*a,n=i.og.width*(1.5*(1/a));var r=C.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(n).height(e)(i.sentence);if(!r.truncated){i.width=Math.ceil(D.max(r.lines.map(function(t){return C.textWidth(t,{"font-family":i.f,"font-size":i.s})})))+i.s;i.height=r.lines.length*(i.lh+1)}else{s=true;return"break"}};for(var e=0;e<h.length;e++){var n=t(e);if(n==="break")break}if(!s){this._wrapRows()}}else{d=[];return}};this._wrapRows=function(){var t=this;d=[];var i=1,e=0;for(var n=0;n<this._lineData.length;n++){var r=t._lineData[n],h=r.width+t._padding*(r.width?2:1)+r.shapeWidth;if(D.sum(d.map(function(t){return D.max(t,function(t){return D.max([t.height,t.shapeHeight])})}))>u){d=[];break}if(h>o){d=[];t._wrapLines();break}else if(e+h<o){e+=h}else if(t._direction!=="column"){e=h;i++}if(!d[i-1]){d[i-1]=[]}d[i-1].push(r);if(t._direction==="column"){e=0;i++}}};this._wrapRows();if(!d.length||D.sum(d,this._rowHeight.bind(this))+this._padding>u){s=D.sum(this._lineData.map(function(t){return t.shapeWidth+l._padding}))-this._padding;for(var c=0;c<this._lineData.length;c++){l._lineData[c].width=0;l._lineData[c].height=0}this._wrapRows()}if(d.length&&D.sum(d,this._rowHeight.bind(this))+this._padding<u){d.forEach(function(t,i){t.forEach(function(t){if(i){t.y=D.sum(d.slice(0,i),l._rowHeight.bind(l))}})});s=D.max(d,this._rowWidth.bind(this))}}var f=D.max(this._lineData,function(t,i){return D.max([t.height,l._fetchConfig("height",t.data,i)])+t.y})+this._titleHeight,g=s;this._outerBounds.width=g;this._outerBounds.height=f;var p=this._padding,v=this._padding;if(this._align==="center"){p=(this._width-g)/2}else if(this._align==="right"){p=this._width-this._padding-g}if(this._verticalAlign==="middle"){v=(this._height-f)/2}else if(this._verticalAlign==="bottom"){v=this._height-this._padding-f}this._outerBounds.x=p;this._outerBounds.y=v;this._titleClass.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 y=j.configPrep.bind(this)(this._shapeConfig,"legend"),w={id:function(t){return t.id},label:function(t){return t.label},lineHeight:function(t){return t.lH}};var m=this._data.map(function(t,i){var e={__d3plus__:true,data:t,i:i,id:l._id(t,i),label:l._lineData[i].width?l._label(t,i):false,lH:l._fetchConfig("lineHeight",t,i),shape:l._shape(t,i)};return e});this._shapes=[];["Circle","Rect"].forEach(function(i){l._shapes.push((new x[i]).data(m.filter(function(t){return t.shape===i})).duration(l._duration).labelPadding(0).select(l._group.node()).verticalAlign("top").config(j.assign({},y,w)).render())});if(i){setTimeout(i,this._duration+100)}return this};i.prototype.active=function t(i){this._shapes.forEach(function(t){return t.active(i)});return this};i.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};i.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};i.prototype.direction=function t(i){return arguments.length?(this._direction=i,this):this._direction};i.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};i.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};i.prototype.hover=function t(i){this._shapes.forEach(function(t){return t.hover(i)});return this};i.prototype.id=function t(i){return arguments.length?(this._id=i,this):this._id};i.prototype.label=function t(i){return arguments.length?(this._label=typeof i==="function"?i:j.constant(i),this):this._label};i.prototype.outerBounds=function t(){return this._outerBounds};i.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};i.prototype.select=function t(i){return arguments.length?(this._select=W.select(i),this):this._select};i.prototype.shape=function t(i){return arguments.length?(this._shape=typeof i==="function"?i:j.constant(i),this):this._shape};i.prototype.shapeConfig=function t(i){return arguments.length?(this._shapeConfig=j.assign(this._shapeConfig,i),this):this._shapeConfig};i.prototype.title=function t(i){return arguments.length?(this._title=i,this):this._title};i.prototype.titleConfig=function t(i){return arguments.length?(this._titleConfig=j.assign(this._titleConfig,i),this):this._titleConfig};i.prototype.verticalAlign=function t(i){return arguments.length?(this._verticalAlign=i,this):this._verticalAlign};i.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return i}(j.BaseClass);t.ckmeans=O;t.ColorScale=i;t.Legend=n;Object.defineProperty(t,"__esModule",{value:true})}); | ||
if(typeof Object.assign!=="function"){Object.defineProperty(Object,"assign",{value:function t(i){"use strict";if(i===null){throw new TypeError("Cannot convert undefined or null to object")}var e=Object(i);for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r!==null){for(var h in r){if(Object.prototype.hasOwnProperty.call(r,h)){e[h]=r[h]}}}}return e},writable:true,configurable:true})}if(!Array.prototype.includes){Object.defineProperty(Array.prototype,"includes",{value:function t(i,e){var n=Object(this);var r=n.length>>>0;if(r===0)return false;var h=e|0;var s=Math.max(h>=0?h:r-Math.abs(h),0);function o(t,i){return t===i||typeof t==="number"&&typeof i==="number"&&isNaN(t)&&isNaN(i)}while(s<r){if(o(n[s],i)){return true}s++}return false}})}(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.d3Array,t.d3Interpolate,t.d3Scale,t.d3Selection,t.d3plusAxis,t.d3plusColor,t.d3plusCommon,t.shapes,t.d3plusText)})(this,function(t,S,W,A,j,e,O,T,x,C){"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 g(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 p(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=g(u,o,h,s);if(d+n[e-1][a-1]>=n[e][o]){break}var _=g(a,o,h,s);var c=_+n[e-1][a-1];if(c<n[e][o]){n[e][o]=c;r[e][o]=a}a++;var f=d+n[e-1][u-1];if(f<n[e][o]){n[e][o]=f;r[e][o]=u}}p(t,o-1,e,n,r,h,s);p(o+1,i,e,n,r,h,s)}function c(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]=g(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}p(u,n-1,l,i,e,h,s)}}function k(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);c(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 i=function(t){function i(){t.call(this);this._axisClass=new e.Axis;this._axisConfig={gridSize:0};this._axisTest=new e.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 x.Rect;this._rectConfig={stroke:"#000",strokeWidth:1};this._scale="linear";this._size=10;this._value=T.accessor("value");this._width=400}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype.render=function t(i){var e=this;var n;if(this._select===void 0){this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}var r=["bottom","top"].includes(this._orient);var h=r?"height":"width",s=r?"width":"height",o=r?"x":"y",a=r?"y":"x";this._group=T.elem("g.d3plus-ColorScale",{parent:this._select});var l=S.extent(this._data,this._value);var u=this._color,d,_;if(!(u instanceof Array)){u=[O.colorLighter(u,.9),O.colorLighter(u,.75),O.colorLighter(u,.5),O.colorLighter(u,.25),u]}if(this._scale==="jenks"){var c=this._data.map(this._value).filter(function(t){return t!==null&&typeof t==="number"});if(c.length<=u.length){var f=A.scaleLinear().domain(S.range(0,c.length-1)).interpolate(W.interpolateHsl).range(u);u=c.slice(0,c.length-1).map(function(t,i){return f(i)})}var g=k(c,u.length);_=S.merge(g.map(function(t,i){return i===g.length-1?[t[0],t[t.length-1]]:[t[0]]}));var p=new Set(_);if(_.length!==p.size){d=Array.from(p)}this._colorScale=A.scaleThreshold().domain(_).range(["black"].concat(u).concat(u[u.length-1]))}else{var v=(l[1]-l[0])/(u.length-1);var y=S.range(l[0],l[1]+v/2,v);if(this._scale==="buckets"){_=y}this._colorScale=A.scaleLinear().domain(y).range(u)}var w=Object.assign({domain:r?l:l.reverse(),duration:this._duration,height:this._height,labels:d||_,orient:this._orient,padding:this._padding,ticks:_,width:this._width},this._axisConfig);this._axisTest.select(T.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:this._group}).node()).config(w).render();var m=this._axisTest.outerBounds();this._outerBounds[s]=this["_"+s]-this._padding*2;this._outerBounds[h]=m[h]+this._size;this._outerBounds[o]=this._padding;this._outerBounds[a]=this._padding;if(this._align==="middle"){this._outerBounds[a]=(this["_"+h]-this._outerBounds[h])/2}else if(this._align==="end"){this._outerBounds[a]=this["_"+h]-this._padding-this._outerBounds[h]}var x=this._outerBounds[a]+(["bottom","right"].includes(this._orient)?this._size:0)-(w.padding||this._axisClass.padding());this._axisClass.select(T.elem("g.d3plus-ColorScale-axis",{parent:this._group,update:{transform:"translate("+(r?0:x)+", "+(r?x:0)+")"}}).node()).config(w).align("start").render();var C=this._axisTest._getPosition.bind(this._axisTest);var b=this._axisTest._getRange();var B=this._group.selectAll("defs").data([0]);var H=B.enter().append("defs");H.append("linearGradient").attr("id","gradient-"+this._uuid);B=H.merge(B);B.select("linearGradient").attr(o+"1",r?"0%":"100%").attr(o+"2",r?"100%":"0%").attr(a+"1","0%").attr(a+"2","0%");var D=B.select("linearGradient").selectAll("stop").data(u);D.enter().append("stop").merge(D).attr("offset",function(t,i){return i/(u.length-1)*100+"%"}).attr("stop-color",String);function z(t,i){var e=Math.abs(C(_[i+1])-C(t));return e||2}this._rectClass.data(_?_.slice(0,_.length-1):[0]).id(function(t,i){return i}).select(T.elem("g.d3plus-ColorScale-Rect",{parent:this._group}).node()).config((n={fill:_?function(t){return e._colorScale(t)}:"url(#gradient-"+this._uuid+")"},n[o]=_?function(t,i){return C(t)+z(t,i)/2-(["left","right"].includes(e._orient)?z(t,i):0)}:b[0]+(b[1]-b[0])/2,n[a]=this._outerBounds[a]+(["top","left"].includes(this._orient)?m[h]:0)+this._size/2,n[s]=_?z:b[1]-b[0],n[h]=this._size,n)).config(this._rectConfig).render();if(i){setTimeout(i,this._duration+100)}return this};i.prototype.axisConfig=function t(i){return arguments.length?(this._axisConfig=Object.assign(this._axisConfig,i),this):this._axisConfig};i.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};i.prototype.color=function t(i){return arguments.length?(this._color=i,this):this._color};i.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};i.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};i.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};i.prototype.orient=function t(i){return arguments.length?(this._orient=i,this):this._orient};i.prototype.outerBounds=function t(){return this._outerBounds};i.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};i.prototype.rectConfig=function t(i){return arguments.length?(this._rectConfig=Object.assign(this._rectConfig,i),this):this._rectConfig};i.prototype.scale=function t(i){return arguments.length?(this._scale=i,this):this._scale};i.prototype.select=function t(i){return arguments.length?(this._select=j.select(i),this):this._select};i.prototype.size=function t(i){return arguments.length?(this._size=i,this):this._size};i.prototype.value=function t(i){return arguments.length?(this._value=typeof i==="function"?i:T.constant(i),this):this._value};i.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return i}(T.BaseClass);var n=function(t){function i(){var s=this;t.call(this);this._align="center";this._data=[];this._direction="row";this._duration=600;this._height=200;this._id=T.accessor("id");this._label=T.accessor("id");this._lineData=[];this._outerBounds={width:0,height:0,x:0,y:0};this._padding=5;this._shape=T.constant("Rect");this._shapes=[];this._shapeConfig={duration:this._duration,fill:T.accessor("color"),height:T.constant(10),hitArea:function(t,i){var e=s._lineData[i],n=S.max([e.height,e.shapeHeight]);return{width:e.width+e.shapeWidth,height:n,x:-e.shapeWidth/2,y:-n/2}},labelBounds:function(t,i,e){var n=s._lineData[i],r=e.r!==void 0?e.r:e.width/2;return{width:n.width,height:n.height,x:r+s._padding,y:-n.height/2+(n.lh-n.s)/2+1}},labelConfig:{fontColor:T.constant("#444"),fontFamily:(new C.TextBox).fontFamily(),fontResize:false,fontSize:T.constant(10)},opacity:1,r:T.constant(5),width:T.constant(10),x:function(t,i){var e=s._lineData[i];var n=e.y;var r=s._align==="left"||s._align==="right"&&s._direction==="column"?0:s._align==="center"?(s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return n===t.y})))/2:s._outerBounds.width-s._rowWidth(s._lineData.filter(function(t){return n===t.y}));var h=s._lineData.slice(0,i).filter(function(t){return n===t.y});return s._rowWidth(h)+s._padding*(h.length?e.sentence?2:1:0)+s._outerBounds.x+e.shapeWidth/2+r},y:function(t,i){var e=s._lineData[i];return e.y+s._titleHeight+s._outerBounds.y+S.max(s._lineData.filter(function(t){return e.y===t.y}).map(function(t){return t.height}).concat(s._data.map(function(t,i){return s._fetchConfig("height",t,i)})))/2}};this._titleClass=new C.TextBox;this._titleConfig={};this._verticalAlign="middle";this._width=400}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype._fetchConfig=function t(i,e,n){var r=this._shapeConfig[i]||this._shapeConfig.labelConfig[i];if(!r&&i==="lineHeight"){return this._fetchConfig("fontSize",e,n)*1.4}return typeof r==="function"?r(e,n):r};i.prototype._rowHeight=function t(i){return S.max(i.map(function(t){return t.height}).concat(i.map(function(t){return t.shapeHeight})))+this._padding};i.prototype._rowWidth=function t(n){var r=this;return S.sum(n.map(function(t,i){var e=r._padding*(i===n.length-1?0:t.width?2:1);return t.shapeWidth+t.width+e}))};i.prototype.render=function t(i){var l=this;if(this._select===void 0){this.select(j.select("body").append("svg").attr("width",this._width+"px").attr("height",this._height+"px").node())}this._group=T.elem("g.d3plus-Legend",{parent:this._select});var u=this._height;this._titleHeight=0;if(this._title){var e=this._titleConfig.fontFamily||this._titleClass.fontFamily()(),n=this._titleConfig.fontSize||this._titleClass.fontSize()();var r=r=this._titleConfig.lineHeight||this._titleClass.lineHeight();r=r?r():n*1.4;var h=C.textWrap().fontFamily(e).fontSize(n).lineHeight(r).width(this._width).height(this._height)(this._title);this._titleHeight=r+h.lines.length+this._padding;u-=this._titleHeight}this._lineData=this._data.map(function(t,i){var e=l._label(t,i);var n={data:t,i:i,id:l._id(t,i),shapeWidth:l._fetchConfig("width",t,i),shapeHeight:l._fetchConfig("height",t,i),y:0};if(!e){n.sentence=false;n.words=[];n.height=0;n.width=0;return n}var r=l._fetchConfig("fontFamily",t,i),h=l._fetchConfig("lineHeight",t,i),s=l._fetchConfig("fontSize",t,i);var o=u-(l._data.length+1)*l._padding,a=l._width;n=Object.assign(n,C.textWrap().fontFamily(r).fontSize(s).lineHeight(h).width(a).height(o)(e));n.width=Math.ceil(S.max(n.lines.map(function(t){return C.textWidth(t,{"font-family":r,"font-size":s})})))+s*.75;n.height=Math.ceil(n.lines.length*(h+1));n.og={height:n.height,width:n.width};n.f=r;n.s=s;n.lh=h;return n});var s;var o=this._width-this._padding*2;s=this._rowWidth(this._lineData);if(this._direction==="column"||s>o){var a=1,d=[];var _=S.max(this._lineData.map(function(t){return t.words.length}));this._wrapLines=function(){var i=this;a++;if(a>_){return}var h=a===1?this._lineData.slice():this._lineData.filter(function(t){return t.width+t.shapeWidth+i._padding*(t.width?2:1)>o&&t.words.length>=a}).sort(function(t,i){return i.sentence.length-t.sentence.length});if(h.length&&u>h[0].height*a){var s=false;var t=function(t){var i=h[t];var e=i.og.height*a,n=i.og.width*(1.5*(1/a));var r=C.textWrap().fontFamily(i.f).fontSize(i.s).lineHeight(i.lh).width(n).height(e)(i.sentence);if(!r.truncated){i.width=Math.ceil(S.max(r.lines.map(function(t){return C.textWidth(t,{"font-family":i.f,"font-size":i.s})})))+i.s;i.height=r.lines.length*(i.lh+1)}else{s=true;return"break"}};for(var e=0;e<h.length;e++){var n=t(e);if(n==="break")break}if(!s){this._wrapRows()}}else{d=[];return}};this._wrapRows=function(){var t=this;d=[];var i=1,e=0;for(var n=0;n<this._lineData.length;n++){var r=t._lineData[n],h=r.width+t._padding*(r.width?2:1)+r.shapeWidth;if(S.sum(d.map(function(t){return S.max(t,function(t){return S.max([t.height,t.shapeHeight])})}))>u){d=[];break}if(h>o){d=[];t._wrapLines();break}else if(e+h<o){e+=h}else if(t._direction!=="column"){e=h;i++}if(!d[i-1]){d[i-1]=[]}d[i-1].push(r);if(t._direction==="column"){e=0;i++}}};this._wrapRows();if(!d.length||S.sum(d,this._rowHeight.bind(this))+this._padding>u){s=S.sum(this._lineData.map(function(t){return t.shapeWidth+l._padding}))-this._padding;for(var c=0;c<this._lineData.length;c++){l._lineData[c].width=0;l._lineData[c].height=0}this._wrapRows()}if(d.length&&S.sum(d,this._rowHeight.bind(this))+this._padding<u){d.forEach(function(t,i){t.forEach(function(t){if(i){t.y=S.sum(d.slice(0,i),l._rowHeight.bind(l))}})});s=S.max(d,this._rowWidth.bind(this))}}var f=S.max(this._lineData,function(t,i){return S.max([t.height,l._fetchConfig("height",t.data,i)])+t.y})+this._titleHeight,g=s;this._outerBounds.width=g;this._outerBounds.height=f;var p=this._padding,v=this._padding;if(this._align==="center"){p=(this._width-g)/2}else if(this._align==="right"){p=this._width-this._padding-g}if(this._verticalAlign==="middle"){v=(this._height-f)/2}else if(this._verticalAlign==="bottom"){v=this._height-this._padding-f}this._outerBounds.x=p;this._outerBounds.y=v;this._titleClass.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 y=T.configPrep.bind(this)(this._shapeConfig,"legend"),w={id:function(t){return t.id},label:function(t){return t.label},lineHeight:function(t){return t.lH}};var m=this._data.map(function(t,i){var e={__d3plus__:true,data:t,i:i,id:l._id(t,i),label:l._lineData[i].width?l._label(t,i):false,lH:l._fetchConfig("lineHeight",t,i),shape:l._shape(t,i)};return e});this._shapes=[];["Circle","Rect"].forEach(function(i){l._shapes.push((new x[i]).data(m.filter(function(t){return t.shape===i})).duration(l._duration).labelConfig({padding:0}).select(l._group.node()).verticalAlign("top").config(T.assign({},y,w)).render())});if(i){setTimeout(i,this._duration+100)}return this};i.prototype.active=function t(i){this._shapes.forEach(function(t){return t.active(i)});return this};i.prototype.align=function t(i){return arguments.length?(this._align=i,this):this._align};i.prototype.data=function t(i){return arguments.length?(this._data=i,this):this._data};i.prototype.direction=function t(i){return arguments.length?(this._direction=i,this):this._direction};i.prototype.duration=function t(i){return arguments.length?(this._duration=i,this):this._duration};i.prototype.height=function t(i){return arguments.length?(this._height=i,this):this._height};i.prototype.hover=function t(i){this._shapes.forEach(function(t){return t.hover(i)});return this};i.prototype.id=function t(i){return arguments.length?(this._id=i,this):this._id};i.prototype.label=function t(i){return arguments.length?(this._label=typeof i==="function"?i:T.constant(i),this):this._label};i.prototype.outerBounds=function t(){return this._outerBounds};i.prototype.padding=function t(i){return arguments.length?(this._padding=i,this):this._padding};i.prototype.select=function t(i){return arguments.length?(this._select=j.select(i),this):this._select};i.prototype.shape=function t(i){return arguments.length?(this._shape=typeof i==="function"?i:T.constant(i),this):this._shape};i.prototype.shapeConfig=function t(i){return arguments.length?(this._shapeConfig=T.assign(this._shapeConfig,i),this):this._shapeConfig};i.prototype.title=function t(i){return arguments.length?(this._title=i,this):this._title};i.prototype.titleConfig=function t(i){return arguments.length?(this._titleConfig=T.assign(this._titleConfig,i),this):this._titleConfig};i.prototype.verticalAlign=function t(i){return arguments.length?(this._verticalAlign=i,this):this._verticalAlign};i.prototype.width=function t(i){return arguments.length?(this._width=i,this):this._width};return i}(T.BaseClass);t.ckmeans=k;t.ColorScale=i;t.Legend=n;Object.defineProperty(t,"__esModule",{value:true})}); |
@@ -81,3 +81,3 @@ /** | ||
var domain = extent(this._data, this._value); | ||
var colors = this._color, ticks; | ||
var colors = this._color, labels, ticks; | ||
@@ -114,2 +114,8 @@ if (!(colors instanceof Array)) { | ||
var tickSet = new Set(ticks); | ||
if (ticks.length !== tickSet.size) { | ||
labels = Array.from(tickSet); | ||
} | ||
this._colorScale = scaleThreshold() | ||
@@ -137,3 +143,3 @@ .domain(ticks) | ||
height: this._height, | ||
labels: ticks, | ||
labels: labels || ticks, | ||
orient: this._orient, | ||
@@ -140,0 +146,0 @@ padding: this._padding, |
@@ -352,3 +352,3 @@ /** | ||
.duration(this$1._duration) | ||
.labelPadding(0) | ||
.labelConfig({padding: 0}) | ||
.select(this$1._group.node()) | ||
@@ -355,0 +355,0 @@ .verticalAlign("top") |
{ | ||
"name": "d3plus-legend", | ||
"version": "0.8.16", | ||
"version": "0.8.17", | ||
"description": "An easy to use javascript chart legend.", | ||
@@ -30,6 +30,6 @@ "main": "build/d3plus-legend.js", | ||
"d3-selection": "^1.3.0", | ||
"d3plus-axis": "^0.3.42", | ||
"d3plus-axis": "^0.3.43", | ||
"d3plus-color": "^0.6.2", | ||
"d3plus-common": "^0.6.33", | ||
"d3plus-shape": "^0.14.1", | ||
"d3plus-shape": "^0.14.2", | ||
"d3plus-text": "^0.9.26" | ||
@@ -36,0 +36,0 @@ }, |
@@ -73,3 +73,3 @@ # d3plus-legend | ||
<a name="ColorScale.axisConfig" href="#ColorScale.axisConfig">#</a> ColorScale.**axisConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L215) | ||
<a name="ColorScale.axisConfig" href="#ColorScale.axisConfig">#</a> ColorScale.**axisConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L221) | ||
@@ -82,3 +82,3 @@ The [ColorScale](http://d3plus.org/docs/#ColorScale) is constructed by combining an [Axis](http://d3plus.org/docs/#Axis) for the ticks/labels and a [Rect](http://d3plus.org/docs/#Rect) for the actual color box (or multiple boxes, as in a jenks scale). Because of this, there are separate configs for the [Axis](http://d3plus.org/docs/#Axis) class used to display the text ([axisConfig](http://d3plus.org/docs/#ColorScale.axisConfig)) and the [Rect](http://d3plus.org/docs/#Rect) class used to draw the color breaks ([rectConfig](http://d3plus.org/docs/#ColorScale.rectConfig)). This method acts as a pass-through to the config method of the [Axis](http://d3plus.org/docs/#Axis). An example usage of this method can be seen [here](http://d3plus.org/examples/d3plus-legend/colorScale-dark/). | ||
<a name="ColorScale.align" href="#ColorScale.align">#</a> ColorScale.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L225) | ||
<a name="ColorScale.align" href="#ColorScale.align">#</a> ColorScale.**align**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L231) | ||
@@ -91,3 +91,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="ColorScale.color" href="#ColorScale.color">#</a> ColorScale.**color**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L235) | ||
<a name="ColorScale.color" href="#ColorScale.color">#</a> ColorScale.**color**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L241) | ||
@@ -100,3 +100,3 @@ Defines the color or colors to be used for the scale. If only a single color is given as a String, then the scale is interpolated by lightening that color. Otherwise, the function expects an Array of color values to be used in order for the scale. | ||
<a name="ColorScale.data" href="#ColorScale.data">#</a> ColorScale.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L245) | ||
<a name="ColorScale.data" href="#ColorScale.data">#</a> ColorScale.**data**([*data*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L251) | ||
@@ -109,3 +109,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="ColorScale.duration" href="#ColorScale.duration">#</a> ColorScale.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L255) | ||
<a name="ColorScale.duration" href="#ColorScale.duration">#</a> ColorScale.**duration**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L261) | ||
@@ -118,3 +118,3 @@ If *value* is specified, sets the transition duration of the ColorScale and returns the current class instance. If *value* is not specified, returns the current duration. | ||
<a name="ColorScale.height" href="#ColorScale.height">#</a> ColorScale.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L265) | ||
<a name="ColorScale.height" href="#ColorScale.height">#</a> ColorScale.**height**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L271) | ||
@@ -127,3 +127,3 @@ If *value* is specified, sets the overall height of the ColorScale and returns the current class instance. If *value* is not specified, returns the current height value. | ||
<a name="ColorScale.orient" href="#ColorScale.orient">#</a> ColorScale.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L275) | ||
<a name="ColorScale.orient" href="#ColorScale.orient">#</a> ColorScale.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L281) | ||
@@ -136,3 +136,3 @@ Sets the flow of the items inside the ColorScale. If no value is passed, the current flow will be returned. | ||
<a name="ColorScale.outerBounds" href="#ColorScale.outerBounds">#</a> ColorScale.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L285) | ||
<a name="ColorScale.outerBounds" href="#ColorScale.outerBounds">#</a> ColorScale.**outerBounds**() [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L291) | ||
@@ -150,3 +150,3 @@ If called after the elements have been drawn to DOM, will returns the outer bounds of the ColorScale content. | ||
<a name="ColorScale.padding" href="#ColorScale.padding">#</a> ColorScale.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L295) | ||
<a name="ColorScale.padding" href="#ColorScale.padding">#</a> ColorScale.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L301) | ||
@@ -159,3 +159,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="ColorScale.rectConfig" href="#ColorScale.rectConfig">#</a> ColorScale.**rectConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L305) | ||
<a name="ColorScale.rectConfig" href="#ColorScale.rectConfig">#</a> ColorScale.**rectConfig**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L311) | ||
@@ -168,3 +168,3 @@ The [ColorScale](http://d3plus.org/docs/#ColorScale) is constructed by combining an [Axis](http://d3plus.org/docs/#Axis) for the ticks/labels and a [Rect](http://d3plus.org/docs/#Rect) for the actual color box (or multiple boxes, as in a jenks scale). Because of this, there are separate configs for the [Axis](http://d3plus.org/docs/#Axis) class used to display the text ([axisConfig](http://d3plus.org/docs/#ColorScale.axisConfig)) and the [Rect](http://d3plus.org/docs/#Rect) class used to draw the color breaks ([rectConfig](http://d3plus.org/docs/#ColorScale.rectConfig)). This method acts as a pass-through to the config method of the [Rect](http://d3plus.org/docs/#Rect). An example usage of this method can be seen [here](http://d3plus.org/examples/d3plus-legend/colorScale-dark/). | ||
<a name="ColorScale.scale" href="#ColorScale.scale">#</a> ColorScale.**scale**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L315) | ||
<a name="ColorScale.scale" href="#ColorScale.scale">#</a> ColorScale.**scale**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L321) | ||
@@ -177,3 +177,3 @@ If *value* is specified, sets the scale of the ColorScale and returns the current class instance. If *value* is not specified, returns the current scale value. | ||
<a name="ColorScale.select" href="#ColorScale.select">#</a> ColorScale.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L325) | ||
<a name="ColorScale.select" href="#ColorScale.select">#</a> ColorScale.**select**([*selector*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L331) | ||
@@ -186,3 +186,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="ColorScale.size" href="#ColorScale.size">#</a> ColorScale.**size**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L335) | ||
<a name="ColorScale.size" href="#ColorScale.size">#</a> ColorScale.**size**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L341) | ||
@@ -195,3 +195,3 @@ The height of horizontal color scales, and width when positioned vertical. | ||
<a name="ColorScale.value" href="#ColorScale.value">#</a> ColorScale.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L349) | ||
<a name="ColorScale.value" href="#ColorScale.value">#</a> ColorScale.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L355) | ||
@@ -211,3 +211,3 @@ If *value* is specified, sets the value accessor to the specified function or string and returns the current class instance. If *value* is not specified, returns the current value accessor. | ||
<a name="ColorScale.width" href="#ColorScale.width">#</a> ColorScale.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L359) | ||
<a name="ColorScale.width" href="#ColorScale.width">#</a> ColorScale.**width**([*value*]) [<>](https://github.com/d3plus/d3plus-legend/blob/master/src/ColorScale.js#L365) | ||
@@ -426,2 +426,2 @@ If *value* is specified, sets the overall width of the ColorScale and returns the current class instance. If *value* is not specified, returns the current width value. | ||
###### <sub>Documentation generated on Wed, 28 Mar 2018 16:03:54 GMT</sub> | ||
###### <sub>Documentation generated on Wed, 28 Mar 2018 21:14:12 GMT</sub> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
289760
2026
Updatedd3plus-axis@^0.3.43
Updatedd3plus-shape@^0.14.2