react-nvd3
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "react-nvd3", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/NuCivic/react-nvd3", | ||
@@ -23,11 +23,3 @@ "authors": [ | ||
}, | ||
"devDependencies": { | ||
"browser-sync": "^2.8.2", | ||
"gulp": "^3.9.0", | ||
"gulp-concat": "^2.6.0", | ||
"gulp-react": "^3.0.1", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-uglify": "^1.3.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -126,25 +126,47 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
key: 'componentDidMount', | ||
/** | ||
* Instantiate a new chart setting | ||
* a callback if exists | ||
*/ | ||
value: function componentDidMount() { | ||
var _this2 = this; | ||
_nvd2.default.addGraph(this.renderChart.bind(this), this.props.renderEnd); | ||
} | ||
_nvd2.default.addGraph(function () { | ||
/** | ||
* Update the chart after state is changed. | ||
*/ | ||
// Margins are an special case. It needs to be | ||
// passed to the margin function. | ||
_this2.chart = _nvd2.default.models[_this2.props.type]().x(_this2.getValueFunction(_this2.props.x, 'x')).y(_this2.getValueFunction(_this2.props.y, 'y')).margin(_this2.options(MARGIN, _utils.pick).margin || _this2.propsByPrefix('margin') || {}).options(_this2.options(SETTINGS.concat(AXIS_NAMES, SIZE, MARGIN), _utils.without)); | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.renderChart(); | ||
} | ||
// We need to set the axis options separatly | ||
_this2.setAxisOptions(_this2.chart, _this2.options(AXIS_NAMES)); | ||
/** | ||
* Creates a chart model and render it | ||
*/ | ||
// hook for configuring the chart | ||
!_this2.props.configure || _this2.props.configure(_this2.chart); | ||
}, { | ||
key: 'renderChart', | ||
value: function renderChart() { | ||
// Margins are an special case. It needs to be | ||
// passed to the margin function. | ||
this.chart = this.chart || _nvd2.default.models[this.props.type](); | ||
// Render chart using d3 | ||
_d2.default.select(_this2.refs.svg).datum(_this2.props.datum).call(_this2.chart); | ||
this.chart.x(this.getValueFunction(this.props.x, 'x')).y(this.getValueFunction(this.props.y, 'y')).margin(this.options(MARGIN, _utils.pick).margin || this.propsByPrefix('margin') || {}).options(this.options(SETTINGS.concat(AXIS_NAMES, SIZE, MARGIN), _utils.without)); | ||
// Update the chart if the window size change. | ||
// TODO: review posible leak. | ||
_nvd2.default.utils.windowResize(_this2.chart.update); | ||
return _this2.chart; | ||
}); | ||
// We need to set the axis options separatly | ||
this.setAxisOptions(this.chart, this.options(AXIS_NAMES)); | ||
// hook for configuring the chart | ||
!this.props.configure || this.props.configure(this.chart); | ||
// Render chart using d3 | ||
_d2.default.select(this.refs.svg).datum(this.props.datum).call(this.chart); | ||
// Update the chart if the window size change. | ||
// TODO: review posible leak. | ||
_nvd2.default.utils.windowResize(this.chart.update); | ||
return this.chart; | ||
} | ||
@@ -174,12 +196,2 @@ | ||
/** | ||
* Update the chart after state is changed. | ||
*/ | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
!this.chart || _d2.default.select(this.refs.svg).datum(this.props.datum).call(this.chart); | ||
} | ||
/** | ||
* Filter options base on predicates | ||
@@ -227,3 +239,3 @@ * @param {Array} keys An array of keys to preserve or remove | ||
value: function propsByPrefix(prefix) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -233,3 +245,3 @@ console.warn('Set margin with prefixes is deprecated use an object instead'); | ||
return (0, _keys2.default)(this.props).reduce(function (memo, prop) { | ||
if (prop.startsWith(prefix)) memo[prop.replace(prefix, '')] = _this3.props[prop]; | ||
if (prop.startsWith(prefix)) memo[prop.replace(prefix, '')] = _this2.props[prop]; | ||
return memo; | ||
@@ -236,0 +248,0 @@ }, {}); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("d3"),require("nvd3")):"function"==typeof define&&define.amd?define(["react","d3","nvd3"],e):"object"==typeof exports?exports.NVD3Chart=e(require("react"),require("d3"),require("nvd3")):t.NVD3Chart=e(t.React,t.d3,t.nv)}(this,function(t,e,n){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(17),c=r(i),s=n(21),f=r(s),a=n(43),p=r(a),l=n(46),d=r(l),y=n(47),h=r(y),v=n(50),g=r(v),b=n(51),m=r(b),x=n(58),_=r(x),O=n(59),w=r(O),j=n(60),S=r(j),P=n(61),M=["x","y","width","height","type","datum","configure"],k=["xAxis","yAxis","y1Axis","y2Axis","y3Axis","y4Axis","x2Axis"],E=["width","height"],D="margin",A=function(t){function e(){return(0,d["default"])(this,e),(0,g["default"])(this,(0,p["default"])(e).apply(this,arguments))}return(0,m["default"])(e,t),(0,h["default"])(e,[{key:"componentDidMount",value:function(){var t=this;S["default"].addGraph(function(){return t.chart=S["default"].models[t.props.type]().x(t.getValueFunction(t.props.x,"x")).y(t.getValueFunction(t.props.y,"y")).margin(t.options(D,P.pick).margin||t.propsByPrefix("margin")||{}).options(t.options(M.concat(k,E,D),P.without)),t.setAxisOptions(t.chart,t.options(k)),!t.props.configure||t.props.configure(t.chart),w["default"].select(t.refs.svg).datum(t.props.datum).call(t.chart),S["default"].utils.windowResize(t.chart.update),t.chart})}},{key:"setAxisOptions",value:function(t,e){for(var n in e){var r=e[n];t&&("object"!==("undefined"==typeof r?"undefined":(0,f["default"])(r))||r instanceof Array?"function"==typeof t[n]&&t[n](r):this.setAxisOptions(t[n],r))}}},{key:"componentDidUpdate",value:function(){!this.chart||w["default"].select(this.refs.svg).datum(this.props.datum).call(this.chart)}},{key:"options",value:function(t,e){this.props.chartOptions&&console.warn("chartOptions is deprecated use options instead");var n=this.props.options||this.props.chartOptions||this.props;return(e=e||P.pick)(n,t)}},{key:"getValueFunction",value:function(t,e){return"function"==typeof t?t:function(n){return"undefined"!=typeof n[t]?n[t]:n[e]}}},{key:"propsByPrefix",value:function(t){var e=this;return console.warn("Set margin with prefixes is deprecated use an object instead"),t+="-",(0,c["default"])(this.props).reduce(function(n,r){return r.startsWith(t)&&(n[r.replace(t,"")]=e.props[r]),n},{})}},{key:"render",value:function(){return _["default"].createElement("div",{ref:"root",className:"nv-chart"},_["default"].createElement("svg",(0,u["default"])({ref:"svg"},(0,P.pick)(this.props,E))))}}]),e}(_["default"].Component);e["default"]=A,t.exports=A},function(t,e,n){"use strict";var r=n(2)["default"];e["default"]=r||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e.__esModule=!0},function(t,e,n){t.exports={"default":n(3),__esModule:!0}},function(t,e,n){n(4),t.exports=n(7).Object.assign},function(t,e,n){var r=n(5);r(r.S+r.F,"Object",{assign:n(10)})},function(t,e,n){var r=n(6),o=n(7),u=n(8),i="prototype",c=function(t,e,n){var s,f,a,p=t&c.F,l=t&c.G,d=t&c.S,y=t&c.P,h=t&c.B,v=t&c.W,g=l?o:o[e]||(o[e]={}),b=l?r:d?r[e]:(r[e]||{})[i];l&&(n=e);for(s in n)f=!p&&b&&s in b,f&&s in g||(a=f?b[s]:n[s],g[s]=l&&"function"!=typeof b[s]?n[s]:h&&f?u(a,r):v&&b[s]==a?function(t){var e=function(e){return this instanceof t?new t(e):t(e)};return e[i]=t[i],e}(a):y&&"function"==typeof a?u(Function.call,a):a,y&&((g[i]||(g[i]={}))[s]=a))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,t.exports=c},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=t.exports={version:"1.2.6"};"number"==typeof __e&&(__e=n)},function(t,e,n){var r=n(9);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var r=n(11),o=n(12),u=n(14);t.exports=n(16)(function(){var t=Object.assign,e={},n={},r=Symbol(),o="abcdefghijklmnopqrst";return e[r]=7,o.split("").forEach(function(t){n[t]=t}),7!=t({},e)[r]||Object.keys(t({},n)).join("")!=o})?function(t,e){for(var n=o(t),i=arguments,c=i.length,s=1,f=r.getKeys,a=r.getSymbols,p=r.isEnum;c>s;)for(var l,d=u(i[s++]),y=a?f(d).concat(a(d)):f(d),h=y.length,v=0;h>v;)p.call(d,l=y[v++])&&(n[l]=d[l]);return n}:Object.assign},function(t,e){var n=Object;t.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(t,e,n){var r=n(13);t.exports=function(t){return Object(r(t))}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var r=n(15);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e){t.exports=function(t){try{return!!t()}catch(e){return!0}}},function(t,e,n){t.exports={"default":n(18),__esModule:!0}},function(t,e,n){n(19),t.exports=n(7).Object.keys},function(t,e,n){var r=n(12);n(20)("keys",function(t){return function(e){return t(r(e))}})},function(t,e,n){var r=n(5),o=n(7),u=n(16);t.exports=function(t,e){var n=(o.Object||{})[t]||Object[t],i={};i[t]=e(n),r(r.S+r.F*u(function(){n(1)}),"Object",i)}},function(t,e,n){"use strict";var r=n(22)["default"];e["default"]=function(t){return t&&t.constructor===r?"symbol":typeof t},e.__esModule=!0},function(t,e,n){t.exports={"default":n(23),__esModule:!0}},function(t,e,n){n(24),n(42),t.exports=n(7).Symbol},function(t,e,n){"use strict";var r=n(11),o=n(6),u=n(25),i=n(26),c=n(5),s=n(27),f=n(16),a=n(30),p=n(31),l=n(33),d=n(32),y=n(34),h=n(36),v=n(37),g=n(38),b=n(39),m=n(35),x=n(29),_=r.getDesc,O=r.setDesc,w=r.create,j=h.get,S=o.Symbol,P=o.JSON,M=P&&P.stringify,k=!1,E=d("_hidden"),D=r.isEnum,A=a("symbol-registry"),N=a("symbols"),F="function"==typeof S,T=Object.prototype,q=i&&f(function(){return 7!=w(O({},"a",{get:function(){return O(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=_(T,e);r&&delete T[e],O(t,e,n),r&&t!==T&&O(T,e,r)}:O,C=function(t){var e=N[t]=w(S.prototype);return e._k=t,i&&k&&q(T,t,{configurable:!0,set:function(e){u(this,E)&&u(this[E],t)&&(this[E][t]=!1),q(this,t,x(1,e))}}),e},V=function(t){return"symbol"==typeof t},W=function(t,e,n){return n&&u(N,e)?(n.enumerable?(u(t,E)&&t[E][e]&&(t[E][e]=!1),n=w(n,{enumerable:x(0,!1)})):(u(t,E)||O(t,E,x(1,{})),t[E][e]=!0),q(t,e,n)):O(t,e,n)},B=function(t,e){b(t);for(var n,r=v(e=m(e)),o=0,u=r.length;u>o;)W(t,n=r[o++],e[n]);return t},G=function(t,e){return void 0===e?w(t):B(w(t),e)},I=function(t){var e=D.call(this,t);return e||!u(this,t)||!u(N,t)||u(this,E)&&this[E][t]?e:!0},J=function(t,e){var n=_(t=m(t),e);return!n||!u(N,e)||u(t,E)&&t[E][e]||(n.enumerable=!0),n},K=function(t){for(var e,n=j(m(t)),r=[],o=0;n.length>o;)u(N,e=n[o++])||e==E||r.push(e);return r},R=function(t){for(var e,n=j(m(t)),r=[],o=0;n.length>o;)u(N,e=n[o++])&&r.push(N[e]);return r},z=function(t){if(void 0!==t&&!V(t)){for(var e,n,r=[t],o=1,u=arguments;u.length>o;)r.push(u[o++]);return e=r[1],"function"==typeof e&&(n=e),(n||!g(e))&&(e=function(t,e){return n&&(e=n.call(this,t,e)),V(e)?void 0:e}),r[1]=e,M.apply(P,r)}},U=f(function(){var t=S();return"[null]"!=M([t])||"{}"!=M({a:t})||"{}"!=M(Object(t))});F||(S=function(){if(V(this))throw TypeError("Symbol is not a constructor");return C(l(arguments.length>0?arguments[0]:void 0))},s(S.prototype,"toString",function(){return this._k}),V=function(t){return t instanceof S},r.create=G,r.isEnum=I,r.getDesc=J,r.setDesc=W,r.setDescs=B,r.getNames=h.get=K,r.getSymbols=R,i&&!n(41)&&s(T,"propertyIsEnumerable",I,!0));var H={"for":function(t){return u(A,t+="")?A[t]:A[t]=S(t)},keyFor:function(t){return y(A,t)},useSetter:function(){k=!0},useSimple:function(){k=!1}};r.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(t){var e=d(t);H[t]=F?e:C(e)}),k=!0,c(c.G+c.W,{Symbol:S}),c(c.S,"Symbol",H),c(c.S+c.F*!F,"Object",{create:G,defineProperty:W,defineProperties:B,getOwnPropertyDescriptor:J,getOwnPropertyNames:K,getOwnPropertySymbols:R}),P&&c(c.S+c.F*(!F||U),"JSON",{stringify:z}),p(S,"Symbol"),p(Math,"Math",!0),p(o.JSON,"JSON",!0)},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){t.exports=!n(16)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e,n){t.exports=n(28)},function(t,e,n){var r=n(11),o=n(29);t.exports=n(26)?function(t,e,n){return r.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var r=n(6),o="__core-js_shared__",u=r[o]||(r[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,e,n){var r=n(11).setDesc,o=n(25),u=n(32)("toStringTag");t.exports=function(t,e,n){t&&!o(t=n?t:t.prototype,u)&&r(t,u,{configurable:!0,value:e})}},function(t,e,n){var r=n(30)("wks"),o=n(33),u=n(6).Symbol;t.exports=function(t){return r[t]||(r[t]=u&&u[t]||(u||o)("Symbol."+t))}},function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},function(t,e,n){var r=n(11),o=n(35);t.exports=function(t,e){for(var n,u=o(t),i=r.getKeys(u),c=i.length,s=0;c>s;)if(u[n=i[s++]]===e)return n}},function(t,e,n){var r=n(14),o=n(13);t.exports=function(t){return r(o(t))}},function(t,e,n){var r=n(35),o=n(11).getNames,u={}.toString,i="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return o(t)}catch(e){return i.slice()}};t.exports.get=function(t){return i&&"[object Window]"==u.call(t)?c(t):o(r(t))}},function(t,e,n){var r=n(11);t.exports=function(t){var e=r.getKeys(t),n=r.getSymbols;if(n)for(var o,u=n(t),i=r.isEnum,c=0;u.length>c;)i.call(t,o=u[c++])&&e.push(o);return e}},function(t,e,n){var r=n(15);t.exports=Array.isArray||function(t){return"Array"==r(t)}},function(t,e,n){var r=n(40);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){t.exports=!0},function(t,e){},function(t,e,n){t.exports={"default":n(44),__esModule:!0}},function(t,e,n){n(45),t.exports=n(7).Object.getPrototypeOf},function(t,e,n){var r=n(12);n(20)("getPrototypeOf",function(t){return function(e){return t(r(e))}})},function(t,e){"use strict";e["default"]=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},e.__esModule=!0},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=n(48),u=r(o);e["default"]=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,u["default"])(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),e.__esModule=!0},function(t,e,n){t.exports={"default":n(49),__esModule:!0}},function(t,e,n){var r=n(11);t.exports=function(t,e,n){return r.setDesc(t,e,n)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=n(21),u=r(o);e["default"]=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":(0,u["default"])(e))&&"function"!=typeof e?t:e},e.__esModule=!0},function(t,e,n){"use strict";var r=n(52)["default"],o=n(54)["default"];e["default"]=function(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=r(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(o?o(t,e):t.__proto__=e)},e.__esModule=!0},function(t,e,n){t.exports={"default":n(53),__esModule:!0}},function(t,e,n){var r=n(11);t.exports=function(t,e){return r.create(t,e)}},function(t,e,n){t.exports={"default":n(55),__esModule:!0}},function(t,e,n){n(56),t.exports=n(7).Object.setPrototypeOf},function(t,e,n){var r=n(5);r(r.S,"Object",{setPrototypeOf:n(57).set})},function(t,e,n){var r=n(11).getDesc,o=n(40),u=n(39),i=function(t,e){if(u(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{o=n(8)(Function.call,r(Object.prototype,"__proto__").set,2),o(t,[]),e=!(t instanceof Array)}catch(u){e=!0}return function(t,n){return i(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:i}},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return t.indexOf(e)>=0}function u(t){return function(){return!t.apply(this,arguments)}}function i(t,e,n){for(var r={},o=(0,a["default"])(t),u=0,i=o.length;i>u;u++){var c=o[u],s=t[c];n(e,c)&&(r[c]=s)}return r}function c(t,e){return i(t,e,o)}function s(t,e){return i(t,e,u(o))}Object.defineProperty(e,"__esModule",{value:!0}),e.includes=o,e.negate=u,e.filterObject=i,e.pick=c,e.without=s;var f=n(17),a=r(f)}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("d3"),require("nvd3")):"function"==typeof define&&define.amd?define(["react","d3","nvd3"],e):"object"==typeof exports?exports.NVD3Chart=e(require("react"),require("d3"),require("nvd3")):t.NVD3Chart=e(t.React,t.d3,t.nv)}(this,function(t,e,n){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(17),c=r(i),s=n(21),f=r(s),a=n(43),p=r(a),l=n(46),d=r(l),h=n(47),y=r(h),v=n(50),g=r(v),b=n(51),m=r(b),x=n(58),_=r(x),O=n(59),w=r(O),j=n(60),S=r(j),P=n(61),M=["x","y","width","height","type","datum","configure"],k=["xAxis","yAxis","y1Axis","y2Axis","y3Axis","y4Axis","x2Axis"],E=["width","height"],D="margin",A=function(t){function e(){return(0,d["default"])(this,e),(0,g["default"])(this,(0,p["default"])(e).apply(this,arguments))}return(0,m["default"])(e,t),(0,y["default"])(e,[{key:"componentDidMount",value:function(){S["default"].addGraph(this.renderChart.bind(this),this.props.renderEnd)}},{key:"componentDidUpdate",value:function(){this.renderChart()}},{key:"renderChart",value:function(){return this.chart=this.chart||S["default"].models[this.props.type](),this.chart.x(this.getValueFunction(this.props.x,"x")).y(this.getValueFunction(this.props.y,"y")).margin(this.options(D,P.pick).margin||this.propsByPrefix("margin")||{}).options(this.options(M.concat(k,E,D),P.without)),this.setAxisOptions(this.chart,this.options(k)),!this.props.configure||this.props.configure(this.chart),w["default"].select(this.refs.svg).datum(this.props.datum).call(this.chart),S["default"].utils.windowResize(this.chart.update),this.chart}},{key:"setAxisOptions",value:function(t,e){for(var n in e){var r=e[n];t&&("object"!==("undefined"==typeof r?"undefined":(0,f["default"])(r))||r instanceof Array?"function"==typeof t[n]&&t[n](r):this.setAxisOptions(t[n],r))}}},{key:"options",value:function(t,e){this.props.chartOptions&&console.warn("chartOptions is deprecated use options instead");var n=this.props.options||this.props.chartOptions||this.props;return(e=e||P.pick)(n,t)}},{key:"getValueFunction",value:function(t,e){return"function"==typeof t?t:function(n){return"undefined"!=typeof n[t]?n[t]:n[e]}}},{key:"propsByPrefix",value:function(t){var e=this;return console.warn("Set margin with prefixes is deprecated use an object instead"),t+="-",(0,c["default"])(this.props).reduce(function(n,r){return r.startsWith(t)&&(n[r.replace(t,"")]=e.props[r]),n},{})}},{key:"render",value:function(){return _["default"].createElement("div",{ref:"root",className:"nv-chart"},_["default"].createElement("svg",(0,u["default"])({ref:"svg"},(0,P.pick)(this.props,E))))}}]),e}(_["default"].Component);e["default"]=A,t.exports=A},function(t,e,n){"use strict";var r=n(2)["default"];e["default"]=r||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e.__esModule=!0},function(t,e,n){t.exports={"default":n(3),__esModule:!0}},function(t,e,n){n(4),t.exports=n(7).Object.assign},function(t,e,n){var r=n(5);r(r.S+r.F,"Object",{assign:n(10)})},function(t,e,n){var r=n(6),o=n(7),u=n(8),i="prototype",c=function(t,e,n){var s,f,a,p=t&c.F,l=t&c.G,d=t&c.S,h=t&c.P,y=t&c.B,v=t&c.W,g=l?o:o[e]||(o[e]={}),b=l?r:d?r[e]:(r[e]||{})[i];l&&(n=e);for(s in n)f=!p&&b&&s in b,f&&s in g||(a=f?b[s]:n[s],g[s]=l&&"function"!=typeof b[s]?n[s]:y&&f?u(a,r):v&&b[s]==a?function(t){var e=function(e){return this instanceof t?new t(e):t(e)};return e[i]=t[i],e}(a):h&&"function"==typeof a?u(Function.call,a):a,h&&((g[i]||(g[i]={}))[s]=a))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,t.exports=c},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){var n=t.exports={version:"1.2.6"};"number"==typeof __e&&(__e=n)},function(t,e,n){var r=n(9);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var r=n(11),o=n(12),u=n(14);t.exports=n(16)(function(){var t=Object.assign,e={},n={},r=Symbol(),o="abcdefghijklmnopqrst";return e[r]=7,o.split("").forEach(function(t){n[t]=t}),7!=t({},e)[r]||Object.keys(t({},n)).join("")!=o})?function(t,e){for(var n=o(t),i=arguments,c=i.length,s=1,f=r.getKeys,a=r.getSymbols,p=r.isEnum;c>s;)for(var l,d=u(i[s++]),h=a?f(d).concat(a(d)):f(d),y=h.length,v=0;y>v;)p.call(d,l=h[v++])&&(n[l]=d[l]);return n}:Object.assign},function(t,e){var n=Object;t.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(t,e,n){var r=n(13);t.exports=function(t){return Object(r(t))}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var r=n(15);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e){t.exports=function(t){try{return!!t()}catch(e){return!0}}},function(t,e,n){t.exports={"default":n(18),__esModule:!0}},function(t,e,n){n(19),t.exports=n(7).Object.keys},function(t,e,n){var r=n(12);n(20)("keys",function(t){return function(e){return t(r(e))}})},function(t,e,n){var r=n(5),o=n(7),u=n(16);t.exports=function(t,e){var n=(o.Object||{})[t]||Object[t],i={};i[t]=e(n),r(r.S+r.F*u(function(){n(1)}),"Object",i)}},function(t,e,n){"use strict";var r=n(22)["default"];e["default"]=function(t){return t&&t.constructor===r?"symbol":typeof t},e.__esModule=!0},function(t,e,n){t.exports={"default":n(23),__esModule:!0}},function(t,e,n){n(24),n(42),t.exports=n(7).Symbol},function(t,e,n){"use strict";var r=n(11),o=n(6),u=n(25),i=n(26),c=n(5),s=n(27),f=n(16),a=n(30),p=n(31),l=n(33),d=n(32),h=n(34),y=n(36),v=n(37),g=n(38),b=n(39),m=n(35),x=n(29),_=r.getDesc,O=r.setDesc,w=r.create,j=y.get,S=o.Symbol,P=o.JSON,M=P&&P.stringify,k=!1,E=d("_hidden"),D=r.isEnum,A=a("symbol-registry"),N=a("symbols"),F="function"==typeof S,C=Object.prototype,T=i&&f(function(){return 7!=w(O({},"a",{get:function(){return O(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=_(C,e);r&&delete C[e],O(t,e,n),r&&t!==C&&O(C,e,r)}:O,q=function(t){var e=N[t]=w(S.prototype);return e._k=t,i&&k&&T(C,t,{configurable:!0,set:function(e){u(this,E)&&u(this[E],t)&&(this[E][t]=!1),T(this,t,x(1,e))}}),e},V=function(t){return"symbol"==typeof t},W=function(t,e,n){return n&&u(N,e)?(n.enumerable?(u(t,E)&&t[E][e]&&(t[E][e]=!1),n=w(n,{enumerable:x(0,!1)})):(u(t,E)||O(t,E,x(1,{})),t[E][e]=!0),T(t,e,n)):O(t,e,n)},B=function(t,e){b(t);for(var n,r=v(e=m(e)),o=0,u=r.length;u>o;)W(t,n=r[o++],e[n]);return t},G=function(t,e){return void 0===e?w(t):B(w(t),e)},I=function(t){var e=D.call(this,t);return e||!u(this,t)||!u(N,t)||u(this,E)&&this[E][t]?e:!0},J=function(t,e){var n=_(t=m(t),e);return!n||!u(N,e)||u(t,E)&&t[E][e]||(n.enumerable=!0),n},K=function(t){for(var e,n=j(m(t)),r=[],o=0;n.length>o;)u(N,e=n[o++])||e==E||r.push(e);return r},R=function(t){for(var e,n=j(m(t)),r=[],o=0;n.length>o;)u(N,e=n[o++])&&r.push(N[e]);return r},z=function(t){if(void 0!==t&&!V(t)){for(var e,n,r=[t],o=1,u=arguments;u.length>o;)r.push(u[o++]);return e=r[1],"function"==typeof e&&(n=e),(n||!g(e))&&(e=function(t,e){return n&&(e=n.call(this,t,e)),V(e)?void 0:e}),r[1]=e,M.apply(P,r)}},U=f(function(){var t=S();return"[null]"!=M([t])||"{}"!=M({a:t})||"{}"!=M(Object(t))});F||(S=function(){if(V(this))throw TypeError("Symbol is not a constructor");return q(l(arguments.length>0?arguments[0]:void 0))},s(S.prototype,"toString",function(){return this._k}),V=function(t){return t instanceof S},r.create=G,r.isEnum=I,r.getDesc=J,r.setDesc=W,r.setDescs=B,r.getNames=y.get=K,r.getSymbols=R,i&&!n(41)&&s(C,"propertyIsEnumerable",I,!0));var H={"for":function(t){return u(A,t+="")?A[t]:A[t]=S(t)},keyFor:function(t){return h(A,t)},useSetter:function(){k=!0},useSimple:function(){k=!1}};r.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(t){var e=d(t);H[t]=F?e:q(e)}),k=!0,c(c.G+c.W,{Symbol:S}),c(c.S,"Symbol",H),c(c.S+c.F*!F,"Object",{create:G,defineProperty:W,defineProperties:B,getOwnPropertyDescriptor:J,getOwnPropertyNames:K,getOwnPropertySymbols:R}),P&&c(c.S+c.F*(!F||U),"JSON",{stringify:z}),p(S,"Symbol"),p(Math,"Math",!0),p(o.JSON,"JSON",!0)},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){t.exports=!n(16)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e,n){t.exports=n(28)},function(t,e,n){var r=n(11),o=n(29);t.exports=n(26)?function(t,e,n){return r.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var r=n(6),o="__core-js_shared__",u=r[o]||(r[o]={});t.exports=function(t){return u[t]||(u[t]={})}},function(t,e,n){var r=n(11).setDesc,o=n(25),u=n(32)("toStringTag");t.exports=function(t,e,n){t&&!o(t=n?t:t.prototype,u)&&r(t,u,{configurable:!0,value:e})}},function(t,e,n){var r=n(30)("wks"),o=n(33),u=n(6).Symbol;t.exports=function(t){return r[t]||(r[t]=u&&u[t]||(u||o)("Symbol."+t))}},function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36))}},function(t,e,n){var r=n(11),o=n(35);t.exports=function(t,e){for(var n,u=o(t),i=r.getKeys(u),c=i.length,s=0;c>s;)if(u[n=i[s++]]===e)return n}},function(t,e,n){var r=n(14),o=n(13);t.exports=function(t){return r(o(t))}},function(t,e,n){var r=n(35),o=n(11).getNames,u={}.toString,i="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return o(t)}catch(e){return i.slice()}};t.exports.get=function(t){return i&&"[object Window]"==u.call(t)?c(t):o(r(t))}},function(t,e,n){var r=n(11);t.exports=function(t){var e=r.getKeys(t),n=r.getSymbols;if(n)for(var o,u=n(t),i=r.isEnum,c=0;u.length>c;)i.call(t,o=u[c++])&&e.push(o);return e}},function(t,e,n){var r=n(15);t.exports=Array.isArray||function(t){return"Array"==r(t)}},function(t,e,n){var r=n(40);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){t.exports=!0},function(t,e){},function(t,e,n){t.exports={"default":n(44),__esModule:!0}},function(t,e,n){n(45),t.exports=n(7).Object.getPrototypeOf},function(t,e,n){var r=n(12);n(20)("getPrototypeOf",function(t){return function(e){return t(r(e))}})},function(t,e){"use strict";e["default"]=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},e.__esModule=!0},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=n(48),u=r(o);e["default"]=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),(0,u["default"])(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),e.__esModule=!0},function(t,e,n){t.exports={"default":n(49),__esModule:!0}},function(t,e,n){var r=n(11);t.exports=function(t,e,n){return r.setDesc(t,e,n)}},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}var o=n(21),u=r(o);e["default"]=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==("undefined"==typeof e?"undefined":(0,u["default"])(e))&&"function"!=typeof e?t:e},e.__esModule=!0},function(t,e,n){"use strict";var r=n(52)["default"],o=n(54)["default"];e["default"]=function(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=r(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(o?o(t,e):t.__proto__=e)},e.__esModule=!0},function(t,e,n){t.exports={"default":n(53),__esModule:!0}},function(t,e,n){var r=n(11);t.exports=function(t,e){return r.create(t,e)}},function(t,e,n){t.exports={"default":n(55),__esModule:!0}},function(t,e,n){n(56),t.exports=n(7).Object.setPrototypeOf},function(t,e,n){var r=n(5);r(r.S,"Object",{setPrototypeOf:n(57).set})},function(t,e,n){var r=n(11).getDesc,o=n(40),u=n(39),i=function(t,e){if(u(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{o=n(8)(Function.call,r(Object.prototype,"__proto__").set,2),o(t,[]),e=!(t instanceof Array)}catch(u){e=!0}return function(t,n){return i(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:i}},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){return t.indexOf(e)>=0}function u(t){return function(){return!t.apply(this,arguments)}}function i(t,e,n){for(var r={},o=(0,a["default"])(t),u=0,i=o.length;i>u;u++){var c=o[u],s=t[c];n(e,c)&&(r[c]=s)}return r}function c(t,e){return i(t,e,o)}function s(t,e){return i(t,e,u(o))}Object.defineProperty(e,"__esModule",{value:!0}),e.includes=o,e.negate=u,e.filterObject=i,e.pick=c,e.without=s;var f=n(17),a=r(f)}])}); |
34
index.js
@@ -17,8 +17,26 @@ import React from 'react'; | ||
/** | ||
* Instantiate a new chart setting | ||
* a callback if exists | ||
*/ | ||
componentDidMount() { | ||
nv.addGraph(() => { | ||
nv.addGraph(this.renderChart.bind(this), this.props.renderEnd); | ||
} | ||
/** | ||
* Update the chart after state is changed. | ||
*/ | ||
componentDidUpdate() { | ||
this.renderChart(); | ||
} | ||
/** | ||
* Creates a chart model and render it | ||
*/ | ||
renderChart() { | ||
// Margins are an special case. It needs to be | ||
// passed to the margin function. | ||
this.chart = nv.models[this.props.type]() | ||
this.chart = this.chart || nv.models[this.props.type](); | ||
this.chart | ||
.x(this.getValueFunction(this.props.x, 'x')) | ||
@@ -36,3 +54,5 @@ .y(this.getValueFunction(this.props.y, 'y')) | ||
// Render chart using d3 | ||
d3.select(this.refs.svg).datum(this.props.datum).call(this.chart); | ||
d3.select(this.refs.svg) | ||
.datum(this.props.datum) | ||
.call(this.chart); | ||
@@ -43,3 +63,2 @@ // Update the chart if the window size change. | ||
return this.chart; | ||
}); | ||
} | ||
@@ -66,9 +85,2 @@ | ||
/** | ||
* Update the chart after state is changed. | ||
*/ | ||
componentDidUpdate() { | ||
!this.chart || d3.select(this.refs.svg).datum(this.props.datum).call(this.chart); | ||
} | ||
/** | ||
* Filter options base on predicates | ||
@@ -75,0 +87,0 @@ * @param {Array} keys An array of keys to preserve or remove |
{ | ||
"name": "react-nvd3", | ||
"description": "React nvd3 reusable graph components.", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "React", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
89720
1549
2