diff --git a/dist/react-chartjs-2.js b/dist/react-chartjs-2.js index 11f1185fa..2096520b9 100644 --- a/dist/react-chartjs-2.js +++ b/dist/react-chartjs-2.js @@ -3196,7 +3196,10 @@ var ChartComponent = function (_React$Component) { var node = this.element; var data = this.memoizeDataProps(); - options.legend = legend; + + if (typeof legend !== 'undefined' && !(0, _lodash2.default)(ChartComponent.defaultProps.legend, legend)) { + options.legend = legend; + } this.chart_instance = new _chart2.default(node, { type: type, diff --git a/dist/react-chartjs-2.min.js b/dist/react-chartjs-2.min.js index 3c606c86e..01bd2731d 100644 --- a/dist/react-chartjs-2.min.js +++ b/dist/react-chartjs-2.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.reactChartjs2=t()}}(function(){return function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a1?e-1:0),r=1;r2?r-2:0),i=2;i-1}function E(t,e){var n=this.__data__,r=B(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function P(t){var e=-1,n=null==t?0:t.length;for(this.clear();++es))return!1;var l=a.get(t);if(l&&a.get(e))return l==e;var p=-1,d=!0,h=n&jt?new C:void 0;for(a.set(t,e),a.set(e,t);++p-1&&t%1==0&&t-1&&t%1==0&&t<=Ot}function ht(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function yt(t){return null!=t&&"object"==typeof t}function vt(t){return ft(t)?U(t):G(t)}function bt(){return[]}function _t(){return!1}var gt=200,mt="__lodash_hash_undefined__",wt=1,jt=2,Ot=9007199254740991,Et="[object Arguments]",Pt="[object Array]",Tt="[object AsyncFunction]",kt="[object Boolean]",At="[object Date]",xt="[object Error]",Rt="[object Function]",Ct="[object GeneratorFunction]",St="[object Map]",Dt="[object Number]",zt="[object Null]",Nt="[object Object]",It="[object Promise]",Ft="[object Proxy]",Lt="[object RegExp]",qt="[object Set]",Ut="[object String]",Bt="[object Symbol]",Vt="[object Undefined]",Mt="[object WeakMap]",Wt="[object ArrayBuffer]",Kt="[object DataView]",$t="[object Float32Array]",Yt="[object Float64Array]",Ht="[object Int8Array]",Gt="[object Int16Array]",Jt="[object Int32Array]",Qt="[object Uint8Array]",Xt="[object Uint8ClampedArray]",Zt="[object Uint16Array]",te="[object Uint32Array]",ee=/[\\^$.*+?()[\]{}|]/g,ne=/^\[object .+?Constructor\]$/,re=/^(?:0|[1-9]\d*)$/,oe={};oe[$t]=oe[Yt]=oe[Ht]=oe[Gt]=oe[Jt]=oe[Qt]=oe[Xt]=oe[Zt]=oe[te]=!0,oe[Et]=oe[Pt]=oe[Wt]=oe[kt]=oe[Kt]=oe[At]=oe[xt]=oe[Rt]=oe[St]=oe[Dt]=oe[Nt]=oe[Lt]=oe[qt]=oe[Ut]=oe[Mt]=!1;var ie="object"==typeof t&&t&&t.Object===Object&&t,ae="object"==typeof self&&self&&self.Object===Object&&self,ue=ie||ae||Function("return this")(),ce="object"==typeof n&&n&&!n.nodeType&&n,se=ce&&"object"==typeof e&&e&&!e.nodeType&&e,fe=se&&se.exports===ce,le=fe&&ie.process,pe=function(){try{return le&&le.binding&&le.binding("util")}catch(t){}}(),de=pe&&pe.isTypedArray,he=Array.prototype,ye=Function.prototype,ve=Object.prototype,be=ue["__core-js_shared__"],_e=ye.toString,ge=ve.hasOwnProperty,me=function(){var t=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),we=ve.toString,je=RegExp("^"+_e.call(ge).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oe=fe?ue.Buffer:void 0,Ee=ue.Symbol,Pe=ue.Uint8Array,Te=ve.propertyIsEnumerable,ke=he.splice,Ae=Ee?Ee.toStringTag:void 0,xe=Object.getOwnPropertySymbols,Re=Oe?Oe.isBuffer:void 0,Ce=l(Object.keys,Object),Se=et(ue,"DataView"),De=et(ue,"Map"),ze=et(ue,"Promise"),Ne=et(ue,"Set"),Ie=et(ue,"WeakMap"),Fe=et(Object,"create"),Le=ct(Se),qe=ct(De),Ue=ct(ze),Be=ct(Ne),Ve=ct(Ie),Me=Ee?Ee.prototype:void 0,We=Me?Me.valueOf:void 0;d.prototype.clear=h,d.prototype["delete"]=y,d.prototype.get=v,d.prototype.has=b,d.prototype.set=_,g.prototype.clear=m,g.prototype["delete"]=w,g.prototype.get=j,g.prototype.has=O,g.prototype.set=E,P.prototype.clear=T,P.prototype["delete"]=k,P.prototype.get=A,P.prototype.has=x,P.prototype.set=R,C.prototype.add=C.prototype.push=S,C.prototype.has=D,z.prototype.clear=N,z.prototype["delete"]=I,z.prototype.get=F,z.prototype.has=L,z.prototype.set=q;var Ke=xe?function(t){return null==t?[]:(t=Object(t),r(xe(t),function(e){return Te.call(t,e)}))}:bt,$e=M;(Se&&$e(new Se(new ArrayBuffer(1)))!=Kt||De&&$e(new De)!=St||ze&&$e(ze.resolve())!=It||Ne&&$e(new Ne)!=qt||Ie&&$e(new Ie)!=Mt)&&($e=function(t){var e=M(t),n=e==Nt?t.constructor:void 0,r=n?ct(n):"";if(r)switch(r){case Le:return Kt;case qe:return St;case Ue:return It;case Be:return qt;case Ve:return Mt}return e});var Ye=W(function(){return arguments}())?W:function(t){return yt(t)&&ge.call(t,"callee")&&!Te.call(t,"callee")},He=Array.isArray,Ge=Re||_t,Je=de?u(de):H;e.exports=lt}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(t,e,n){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function a(t){if(p===clearTimeout)return clearTimeout(t);if((p===o||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(t);try{return p(t)}catch(e){try{return p.call(null,t)}catch(e){return p.call(this,t)}}}function u(){v&&h&&(v=!1,h.length?y=h.concat(y):b=-1,y.length&&c())}function c(){if(!v){var t=i(u);v=!0;for(var e=y.length;e;){for(h=y,y=[];++b1)for(var n=1;n=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(n,"__esModule",{value:!0}),n.Chart=n.defaults=n.Scatter=n.Bubble=n.Polar=n.Radar=n.HorizontalBar=n.Bar=n.Line=n.Pie=n.Doughnut=void 0;var c=Object.assign||function(t){for(var e=1;e>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o=0;l-=1)f(l);s.forEach(function(t){return r.push(t)});var p=(n.datasets,o(n,["datasets"]));this.chart_instance.config.data=c({},this.chart_instance.config.data,p),this.chart_instance.update()}}},{key:"renderChart",value:function(){var t=this.props,e=t.options,n=t.legend,r=t.type,o=(t.redraw,t.plugins),i=this.element,a=this.memoizeDataProps();e.legend=n,this.chart_instance=new y["default"](i,{type:r,data:a,options:e,plugins:o})}},{key:"render",value:function(){var t=this.props,e=t.height,n=t.width;t.onElementsClick;return l["default"].createElement("canvas",{ref:this.ref,height:e,width:n,onClick:this.handleOnClick})}}]),e}(l["default"].Component);_.getLabelAsKey=function(t){return t.label},_.propTypes={data:d["default"].oneOfType([d["default"].object,d["default"].func]).isRequired,getDatasetAtEvent:d["default"].func,getElementAtEvent:d["default"].func,getElementsAtEvent:d["default"].func,height:d["default"].number,legend:d["default"].object,onElementsClick:d["default"].func,options:d["default"].object,plugins:d["default"].arrayOf(d["default"].object),redraw:d["default"].bool,type:function(t,e,n){if(!Object.keys(y["default"].controllers).find(function(n){return n===t[e]}))return new Error("Invalid chart type `"+t[e]+"` supplied to `"+n+"`.")},width:d["default"].number,datasetKeyProvider:d["default"].func},_.defaultProps={legend:{display:!0,position:"bottom"},type:"doughnut",height:150,width:300,redraw:!1,options:{},datasetKeyProvider:_.getLabelAsKey},n["default"]=_;n.Doughnut=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"doughnut"}))}}]),e}(l["default"].Component),n.Pie=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"pie"}))}}]),e}(l["default"].Component),n.Line=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"line"}))}}]),e}(l["default"].Component),n.Bar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bar"}))}}]),e}(l["default"].Component),n.HorizontalBar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"horizontalBar"}))}}]),e}(l["default"].Component),n.Radar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"radar"}))}}]),e}(l["default"].Component),n.Polar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"polarArea"}))}}]),e}(l["default"].Component),n.Bubble=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bubble"}))}}]),e}(l["default"].Component),n.Scatter=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"scatter"}))}}]),e}(l["default"].Component),n.defaults=y["default"].defaults;n.Chart=y["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash.isequal":4,"prop-types":9}]},{},[11])(11)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.reactChartjs2=t()}}(function(){return function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a1?e-1:0),r=1;r2?r-2:0),i=2;i-1}function E(t,e){var n=this.__data__,r=B(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function P(t){var e=-1,n=null==t?0:t.length;for(this.clear();++es))return!1;var l=a.get(t);if(l&&a.get(e))return l==e;var p=-1,d=!0,h=n&jt?new C:void 0;for(a.set(t,e),a.set(e,t);++p-1&&t%1==0&&t-1&&t%1==0&&t<=Ot}function ht(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function yt(t){return null!=t&&"object"==typeof t}function vt(t){return ft(t)?U(t):G(t)}function bt(){return[]}function _t(){return!1}var gt=200,mt="__lodash_hash_undefined__",wt=1,jt=2,Ot=9007199254740991,Et="[object Arguments]",Pt="[object Array]",Tt="[object AsyncFunction]",kt="[object Boolean]",At="[object Date]",xt="[object Error]",Rt="[object Function]",Ct="[object GeneratorFunction]",St="[object Map]",Dt="[object Number]",zt="[object Null]",Nt="[object Object]",It="[object Promise]",Ft="[object Proxy]",Lt="[object RegExp]",qt="[object Set]",Ut="[object String]",Bt="[object Symbol]",Vt="[object Undefined]",Mt="[object WeakMap]",Wt="[object ArrayBuffer]",Kt="[object DataView]",$t="[object Float32Array]",Yt="[object Float64Array]",Ht="[object Int8Array]",Gt="[object Int16Array]",Jt="[object Int32Array]",Qt="[object Uint8Array]",Xt="[object Uint8ClampedArray]",Zt="[object Uint16Array]",te="[object Uint32Array]",ee=/[\\^$.*+?()[\]{}|]/g,ne=/^\[object .+?Constructor\]$/,re=/^(?:0|[1-9]\d*)$/,oe={};oe[$t]=oe[Yt]=oe[Ht]=oe[Gt]=oe[Jt]=oe[Qt]=oe[Xt]=oe[Zt]=oe[te]=!0,oe[Et]=oe[Pt]=oe[Wt]=oe[kt]=oe[Kt]=oe[At]=oe[xt]=oe[Rt]=oe[St]=oe[Dt]=oe[Nt]=oe[Lt]=oe[qt]=oe[Ut]=oe[Mt]=!1;var ie="object"==typeof t&&t&&t.Object===Object&&t,ae="object"==typeof self&&self&&self.Object===Object&&self,ue=ie||ae||Function("return this")(),ce="object"==typeof n&&n&&!n.nodeType&&n,se=ce&&"object"==typeof e&&e&&!e.nodeType&&e,fe=se&&se.exports===ce,le=fe&&ie.process,pe=function(){try{return le&&le.binding&&le.binding("util")}catch(t){}}(),de=pe&&pe.isTypedArray,he=Array.prototype,ye=Function.prototype,ve=Object.prototype,be=ue["__core-js_shared__"],_e=ye.toString,ge=ve.hasOwnProperty,me=function(){var t=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),we=ve.toString,je=RegExp("^"+_e.call(ge).replace(ee,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oe=fe?ue.Buffer:void 0,Ee=ue.Symbol,Pe=ue.Uint8Array,Te=ve.propertyIsEnumerable,ke=he.splice,Ae=Ee?Ee.toStringTag:void 0,xe=Object.getOwnPropertySymbols,Re=Oe?Oe.isBuffer:void 0,Ce=l(Object.keys,Object),Se=et(ue,"DataView"),De=et(ue,"Map"),ze=et(ue,"Promise"),Ne=et(ue,"Set"),Ie=et(ue,"WeakMap"),Fe=et(Object,"create"),Le=ct(Se),qe=ct(De),Ue=ct(ze),Be=ct(Ne),Ve=ct(Ie),Me=Ee?Ee.prototype:void 0,We=Me?Me.valueOf:void 0;d.prototype.clear=h,d.prototype["delete"]=y,d.prototype.get=v,d.prototype.has=b,d.prototype.set=_,g.prototype.clear=m,g.prototype["delete"]=w,g.prototype.get=j,g.prototype.has=O,g.prototype.set=E,P.prototype.clear=T,P.prototype["delete"]=k,P.prototype.get=A,P.prototype.has=x,P.prototype.set=R,C.prototype.add=C.prototype.push=S,C.prototype.has=D,z.prototype.clear=N,z.prototype["delete"]=I,z.prototype.get=F,z.prototype.has=L,z.prototype.set=q;var Ke=xe?function(t){return null==t?[]:(t=Object(t),r(xe(t),function(e){return Te.call(t,e)}))}:bt,$e=M;(Se&&$e(new Se(new ArrayBuffer(1)))!=Kt||De&&$e(new De)!=St||ze&&$e(ze.resolve())!=It||Ne&&$e(new Ne)!=qt||Ie&&$e(new Ie)!=Mt)&&($e=function(t){var e=M(t),n=e==Nt?t.constructor:void 0,r=n?ct(n):"";if(r)switch(r){case Le:return Kt;case qe:return St;case Ue:return It;case Be:return qt;case Ve:return Mt}return e});var Ye=W(function(){return arguments}())?W:function(t){return yt(t)&&ge.call(t,"callee")&&!Te.call(t,"callee")},He=Array.isArray,Ge=Re||_t,Je=de?u(de):H;e.exports=lt}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],5:[function(t,e,n){function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===r||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function a(t){if(p===clearTimeout)return clearTimeout(t);if((p===o||!p)&&clearTimeout)return p=clearTimeout,clearTimeout(t);try{return p(t)}catch(e){try{return p.call(null,t)}catch(e){return p.call(this,t)}}}function u(){v&&h&&(v=!1,h.length?y=h.concat(y):b=-1,y.length&&c())}function c(){if(!v){var t=i(u);v=!0;for(var e=y.length;e;){for(h=y,y=[];++b1)for(var n=1;n=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(n,"__esModule",{value:!0}),n.Chart=n.defaults=n.Scatter=n.Bubble=n.Polar=n.Radar=n.HorizontalBar=n.Bar=n.Line=n.Pie=n.Doughnut=void 0;var c=Object.assign||function(t){for(var e=1;e>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var r=arguments[1],o=0;o=0;l-=1)f(l);s.forEach(function(t){return r.push(t)});var p=(n.datasets,o(n,["datasets"]));this.chart_instance.config.data=c({},this.chart_instance.config.data,p),this.chart_instance.update()}}},{key:"renderChart",value:function(){var t=this.props,n=t.options,r=t.legend,o=t.type,i=(t.redraw,t.plugins),a=this.element,u=this.memoizeDataProps();"undefined"==typeof r||(0,b["default"])(e.defaultProps.legend,r)||(n.legend=r),this.chart_instance=new y["default"](a,{type:o,data:u,options:n,plugins:i})}},{key:"render",value:function(){var t=this.props,e=t.height,n=t.width;t.onElementsClick;return l["default"].createElement("canvas",{ref:this.ref,height:e,width:n,onClick:this.handleOnClick})}}]),e}(l["default"].Component);_.getLabelAsKey=function(t){return t.label},_.propTypes={data:d["default"].oneOfType([d["default"].object,d["default"].func]).isRequired,getDatasetAtEvent:d["default"].func,getElementAtEvent:d["default"].func,getElementsAtEvent:d["default"].func,height:d["default"].number,legend:d["default"].object,onElementsClick:d["default"].func,options:d["default"].object,plugins:d["default"].arrayOf(d["default"].object),redraw:d["default"].bool,type:function(t,e,n){if(!Object.keys(y["default"].controllers).find(function(n){return n===t[e]}))return new Error("Invalid chart type `"+t[e]+"` supplied to `"+n+"`.")},width:d["default"].number,datasetKeyProvider:d["default"].func},_.defaultProps={legend:{display:!0,position:"bottom"},type:"doughnut",height:150,width:300,redraw:!1,options:{},datasetKeyProvider:_.getLabelAsKey},n["default"]=_;n.Doughnut=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"doughnut"}))}}]),e}(l["default"].Component),n.Pie=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"pie"}))}}]),e}(l["default"].Component),n.Line=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"line"}))}}]),e}(l["default"].Component),n.Bar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bar"}))}}]),e}(l["default"].Component),n.HorizontalBar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"horizontalBar"}))}}]),e}(l["default"].Component),n.Radar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"radar"}))}}]),e}(l["default"].Component),n.Polar=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"polarArea"}))}}]),e}(l["default"].Component),n.Bubble=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bubble"}))}}]),e}(l["default"].Component),n.Scatter=function(t){function e(){return i(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return u(e,t),s(e,[{key:"render",value:function(){var t=this;return l["default"].createElement(_,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"scatter"}))}}]),e}(l["default"].Component),n.defaults=y["default"].defaults;n.Chart=y["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"lodash.isequal":4,"prop-types":9}]},{},[11])(11)}); \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index 3fb1127a9..9bf55acf2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -298,7 +298,10 @@ var ChartComponent = function (_React$Component) { var node = this.element; var data = this.memoizeDataProps(); - options.legend = legend; + + if (typeof legend !== 'undefined' && !(0, _lodash2.default)(ChartComponent.defaultProps.legend, legend)) { + options.legend = legend; + } this.chart_instance = new _chart2.default(node, { type: type, diff --git a/package.json b/package.json index ecf6caa8e..967e5c804 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-chartjs-2", - "version": "2.5.2", + "version": "2.5.3", "description": "react-chartjs-2", "main": "lib/index.js", "author": "Goran Udosic",