UNPKG

react-chartjs

Version:

react charting components using the chartjs lib

6 lines 15.6 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom"),require("Chartjs")):"function"==typeof define&&define.amd?define(["react","react-dom","Chartjs"],e):"object"==typeof exports?exports["react-chartjs"]=e(require("react"),require("react-dom"),require("Chartjs")):t["react-chartjs"]=e(t.React,t.ReactDOM,t.Chart)}(this,function(t,e,n){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){t.exports={Bar:n(1),Doughnut:n(14),Line:n(15),Pie:n(16),PolarArea:n(17),Radar:n(18),createClass:n(2).createClass}},function(t,e,n){var o=n(2);t.exports=o.createClass("Bar",["getBarsAtEvent"])},function(t,e,n){var o=n(3),r=n(4),a=n(12);t.exports={createClass:function(t,e,c){function u(t){l[t]=function(){return this.state.chart[t].apply(this.state.chart,arguments)}}var p=["data","options","redraw"],l={displayName:t+"Chart",getInitialState:function(){return{}},render:function(){var t={ref:"canvass"};for(var e in this.props)this.props.hasOwnProperty(e)&&p.indexOf(e)===-1&&(t[e]=this.props[e]);return o.createElement("canvas",t)}},f=["clear","stop","resize","toBase64Image","generateLegend","update","addData","removeData"];l.componentDidMount=function(){this.initializeChart(this.props)},l.componentWillUnmount=function(){var t=this.state.chart;t.destroy()},l.componentWillReceiveProps=function(t){var e=this.state.chart;t.redraw?(e.destroy(),this.initializeChart(t)):(c=c||i[e.name],s(t,e,c),e.scale&&(e.scale.xLabels=t.data.labels,e.scale.calculateXLabelRotation&&e.scale.calculateXLabelRotation()),e.update())},l.initializeChart=function(e){var o=n(13),r=a.findDOMNode(this),i=r.getContext("2d"),s=new o(i)[t](e.data,e.options||{});this.state.chart=s},l.getChart=function(){return this.state.chart},l.getCanvass=function(){return this.refs.canvass},l.getCanvas=l.getCanvass;var d;for(d=0;d<f.length;d++)u(f[d]);for(d=0;d<e.length;d++)u(e[d]);return r(l)}};var i={Line:"points",Radar:"points",Bar:"bars"},s=function(t,e,n){var o=e.name;if("PolarArea"===o||"Pie"===o||"Doughnut"===o)for(t.data.forEach(function(t,n){e.segments[n]?Object.keys(t).forEach(function(o){e.segments[n][o]=t[o]}):e.addData(t)});t.data.length<e.segments.length;)e.removeData();else if("Radar"===o)e.removeData(),t.data.datasets.forEach(function(o,r){o.data.forEach(function(o,a){"undefined"==typeof e.datasets[r][n][a]?c(t,e,r,a):e.datasets[r][n][a].value=o})});else{for(;e.scale.xLabels.length>t.data.labels.length;)e.removeData();t.data.datasets.forEach(function(o,r){o.data.forEach(function(o,a){"undefined"==typeof e.datasets[r][n][a]?c(t,e,r,a):e.datasets[r][n][a].value=o})})}},c=function(t,e,n,o){var r=[];t.data.datasets.forEach(function(t){r.push(t.data[o])}),e.addData(r,t.data.labels[n])}},function(e,n){e.exports=t},function(t,e,n){"use strict";var o=n(3),r=n(5);if("undefined"==typeof o)throw Error("create-react-class could not find the React object. If you are using script tags, make sure that React is being loaded before create-react-class.");var a=(new o.Component).updater;t.exports=r(o.Component,o.isValidElement,a)},function(t,e,n){(function(e){"use strict";function o(t){return t}function r(t,n,r){function l(t,n,o){for(var r in n)n.hasOwnProperty(r)&&"production"!==e.env.NODE_ENV&&c("function"==typeof n[r],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",t.displayName||"ReactClass",u[o],r)}function f(t,e){var n=D.hasOwnProperty(e)?D[e]:null;w.hasOwnProperty(e)&&s("OVERRIDE_BASE"===n,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",e),t&&s("DEFINE_MANY"===n||"DEFINE_MANY_MERGED"===n,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",e)}function d(t,o){if(o){s("function"!=typeof o,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),s(!n(o),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var r=t.prototype,a=r.__reactAutoBindPairs;o.hasOwnProperty(p)&&b.mixins(t,o.mixins);for(var i in o)if(o.hasOwnProperty(i)&&i!==p){var u=o[i],l=r.hasOwnProperty(i);if(f(l,i),b.hasOwnProperty(i))b[i](t,u);else{var d=D.hasOwnProperty(i),h="function"==typeof u,m=h&&!d&&!l&&o.autobind!==!1;if(m)a.push(i,u),r[i]=u;else if(l){var E=D[i];s(d&&("DEFINE_MANY_MERGED"===E||"DEFINE_MANY"===E),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",E,i),"DEFINE_MANY_MERGED"===E?r[i]=y(r[i],u):"DEFINE_MANY"===E&&(r[i]=v(r[i],u))}else r[i]=u,"production"!==e.env.NODE_ENV&&"function"==typeof u&&o.displayName&&(r[i].displayName=o.displayName+"_"+i)}}}else if("production"!==e.env.NODE_ENV){var g=typeof o,N="object"===g&&null!==o;"production"!==e.env.NODE_ENV&&c(N,"%s: You're attempting to include a mixin that is either null or not an object. Check the mixins included by the component, as well as any mixins they include themselves. Expected object but got %s.",t.displayName||"ReactClass",null===o?null:g)}}function h(t,e){if(e)for(var n in e){var o=e[n];if(e.hasOwnProperty(n)){var r=n in b;s(!r,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',n);var a=n in t;s(!a,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",n),t[n]=o}}}function m(t,e){s(t&&e&&"object"==typeof t&&"object"==typeof e,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var n in e)e.hasOwnProperty(n)&&(s(void 0===t[n],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",n),t[n]=e[n]);return t}function y(t,e){return function(){var n=t.apply(this,arguments),o=e.apply(this,arguments);if(null==n)return o;if(null==o)return n;var r={};return m(r,n),m(r,o),r}}function v(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function E(t,n){var o=n.bind(t);if("production"!==e.env.NODE_ENV){o.__reactBoundContext=t,o.__reactBoundMethod=n,o.__reactBoundArguments=null;var r=t.constructor.displayName,a=o.bind;o.bind=function(i){for(var s=arguments.length,u=Array(s>1?s-1:0),p=1;p<s;p++)u[p-1]=arguments[p];if(i!==t&&null!==i)"production"!==e.env.NODE_ENV&&c(!1,"bind(): React component methods may only be bound to the component instance. See %s",r);else if(!u.length)return"production"!==e.env.NODE_ENV&&c(!1,"bind(): You are binding a component method to the component. React does this for you automatically in a high-performance way, so you can safely remove this call. See %s",r),o;var l=a.apply(o,arguments);return l.__reactBoundContext=t,l.__reactBoundMethod=n,l.__reactBoundArguments=u,l}}return o}function g(t){for(var e=t.__reactAutoBindPairs,n=0;n<e.length;n+=2){var o=e[n],r=e[n+1];t[o]=E(t,r)}}function N(t){var n=o(function(t,o,a){"production"!==e.env.NODE_ENV&&c(this instanceof n,"Something is calling a React component directly. Use a factory or JSX instead. See: https://fb.me/react-legacyfactory"),this.__reactAutoBindPairs.length&&g(this),this.props=t,this.context=o,this.refs=i,this.updater=a||r,this.state=null;var u=this.getInitialState?this.getInitialState():null;"production"!==e.env.NODE_ENV&&void 0===u&&this.getInitialState._isMockFunction&&(u=null),s("object"==typeof u&&!Array.isArray(u),"%s.getInitialState(): must return an object or null",n.displayName||"ReactCompositeComponent"),this.state=u});n.prototype=new O,n.prototype.constructor=n,n.prototype.__reactAutoBindPairs=[],_.forEach(d.bind(null,n)),d(n,x),d(n,t),d(n,C),n.getDefaultProps&&(n.defaultProps=n.getDefaultProps()),"production"!==e.env.NODE_ENV&&(n.getDefaultProps&&(n.getDefaultProps.isReactClassApproved={}),n.prototype.getInitialState&&(n.prototype.getInitialState.isReactClassApproved={})),s(n.prototype.render,"createClass(...): Class specification must implement a `render` method."),"production"!==e.env.NODE_ENV&&(c(!n.prototype.componentShouldUpdate,"%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.",t.displayName||"A component"),c(!n.prototype.componentWillRecieveProps,"%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?",t.displayName||"A component"));for(var a in D)n.prototype[a]||(n.prototype[a]=null);return n}var _=[],D={mixins:"DEFINE_MANY",statics:"DEFINE_MANY",propTypes:"DEFINE_MANY",contextTypes:"DEFINE_MANY",childContextTypes:"DEFINE_MANY",getDefaultProps:"DEFINE_MANY_MERGED",getInitialState:"DEFINE_MANY_MERGED",getChildContext:"DEFINE_MANY_MERGED",render:"DEFINE_ONCE",componentWillMount:"DEFINE_MANY",componentDidMount:"DEFINE_MANY",componentWillReceiveProps:"DEFINE_MANY",shouldComponentUpdate:"DEFINE_ONCE",componentWillUpdate:"DEFINE_MANY",componentDidUpdate:"DEFINE_MANY",componentWillUnmount:"DEFINE_MANY",updateComponent:"OVERRIDE_BASE"},b={displayName:function(t,e){t.displayName=e},mixins:function(t,e){if(e)for(var n=0;n<e.length;n++)d(t,e[n])},childContextTypes:function(t,n){"production"!==e.env.NODE_ENV&&l(t,n,"childContext"),t.childContextTypes=a({},t.childContextTypes,n)},contextTypes:function(t,n){"production"!==e.env.NODE_ENV&&l(t,n,"context"),t.contextTypes=a({},t.contextTypes,n)},getDefaultProps:function(t,e){t.getDefaultProps?t.getDefaultProps=y(t.getDefaultProps,e):t.getDefaultProps=e},propTypes:function(t,n){"production"!==e.env.NODE_ENV&&l(t,n,"prop"),t.propTypes=a({},t.propTypes,n)},statics:function(t,e){h(t,e)},autobind:function(){}},x={componentDidMount:function(){this.__isMounted=!0}},C={componentWillUnmount:function(){this.__isMounted=!1}},w={replaceState:function(t,e){this.updater.enqueueReplaceState(this,t,e)},isMounted:function(){return"production"!==e.env.NODE_ENV&&(c(this.__didWarnIsMounted,"%s: isMounted is deprecated. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.",this.constructor&&this.constructor.displayName||this.name||"Component"),this.__didWarnIsMounted=!0),!!this.__isMounted}},O=function(){};return a(O.prototype,t.prototype,w),N}var a=n(7),i=n(8),s=n(9);if("production"!==e.env.NODE_ENV)var c=n(10);var u,p="mixins";u="production"!==e.env.NODE_ENV?{prop:"prop",context:"context",childContext:"child context"}:{},t.exports=r}).call(e,n(6))},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function r(t){if(p===setTimeout)return setTimeout(t,0);if((p===n||!p)&&setTimeout)return p=setTimeout,setTimeout(t,0);try{return p(t,0)}catch(e){try{return p.call(null,t,0)}catch(e){return p.call(this,t,0)}}}function a(t){if(l===clearTimeout)return clearTimeout(t);if((l===o||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function i(){m&&d&&(m=!1,d.length?h=d.concat(h):y=-1,h.length&&s())}function s(){if(!m){var t=r(i);m=!0;for(var e=h.length;e;){for(d=h,h=[];++y<e;)d&&d[y].run();y=-1,e=h.length}d=null,m=!1,a(t)}}function c(t,e){this.fun=t,this.array=e}function u(){}var p,l,f=t.exports={};!function(){try{p="function"==typeof setTimeout?setTimeout:n}catch(t){p=n}try{l="function"==typeof clearTimeout?clearTimeout:o}catch(t){l=o}}();var d,h=[],m=!1,y=-1;f.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];h.push(new c(t,e)),1!==h.length||m||r(s)},c.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=u,f.addListener=u,f.once=u,f.off=u,f.removeListener=u,f.removeAllListeners=u,f.emit=u,f.prependListener=u,f.prependOnceListener=u,f.listeners=function(t){return[]},f.binding=function(t){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(t){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},function(t,e){/* object-assign (c) Sindre Sorhus @license MIT */ "use strict";function n(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function o(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;var o=Object.getOwnPropertyNames(e).map(function(t){return e[t]});if("0123456789"!==o.join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}var r=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;t.exports=o()?Object.assign:function(t,e){for(var o,s,c=n(t),u=1;u<arguments.length;u++){o=Object(arguments[u]);for(var p in o)a.call(o,p)&&(c[p]=o[p]);if(r){s=r(o);for(var l=0;l<s.length;l++)i.call(o,s[l])&&(c[s[l]]=o[s[l]])}}return c}},function(t,e,n){(function(e){"use strict";var n={};"production"!==e.env.NODE_ENV&&Object.freeze(n),t.exports=n}).call(e,n(6))},function(t,e,n){(function(e){"use strict";function n(t,e,n,r,a,i,s,c){if(o(e),!t){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var p=[n,r,a,i,s,c],l=0;u=new Error(e.replace(/%s/g,function(){return p[l++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}}var o=function(t){};"production"!==e.env.NODE_ENV&&(o=function(t){if(void 0===t)throw new Error("invariant requires an error message argument")}),t.exports=n}).call(e,n(6))},function(t,e,n){(function(e){"use strict";var o=n(11),r=o;if("production"!==e.env.NODE_ENV){var a=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),o=1;o<e;o++)n[o-1]=arguments[o];var r=0,a="Warning: "+t.replace(/%s/g,function(){return n[r++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(t){}};r=function(t,e){if(void 0===e)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==e.indexOf("Failed Composite propType: ")&&!t){for(var n=arguments.length,o=Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];a.apply(void 0,[e].concat(o))}}}t.exports=r}).call(e,n(6))},function(t,e){"use strict";function n(t){return function(){return t}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(t){return t},t.exports=o},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){var o=n(2);t.exports=o.createClass("Doughnut",["getSegmentsAtEvent"])},function(t,e,n){var o=n(2);t.exports=o.createClass("Line",["getPointsAtEvent"])},function(t,e,n){var o=n(2);t.exports=o.createClass("Pie",["getSegmentsAtEvent"])},function(t,e,n){var o=n(2);t.exports=o.createClass("PolarArea",["getSegmentsAtEvent"])},function(t,e,n){var o=n(2);t.exports=o.createClass("Radar",["getPointsAtEvent"])}])});