react-chartjs-2
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -5,18 +5,11 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Chart = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Polar = exports.Radar = exports.HorizontalBar = exports.Bar = exports.Line = exports.Pie = exports.Doughnut = undefined; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null); | ||
@@ -30,12 +23,20 @@ | ||
var _chartJs = require('chart.js'); | ||
var _chart = require('chart.js'); | ||
var _chartJs2 = _interopRequireDefault(_chartJs); | ||
var _chart2 = _interopRequireDefault(_chart); | ||
var _utilsDeepEqual = require('./utils/deepEqual'); | ||
var _deepEqual = require('./utils/deepEqual'); | ||
var _utilsDeepEqual2 = _interopRequireDefault(_utilsDeepEqual); | ||
var _deepEqual2 = _interopRequireDefault(_deepEqual); | ||
var ChartComponent = _react2['default'].createClass({ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var ChartComponent = _react2.default.createClass({ | ||
displayName: 'ChartComponent', | ||
@@ -66,11 +67,8 @@ | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.chart_instance = undefined; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
this.renderChart(); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
@@ -84,3 +82,2 @@ if (this.props.redraw) { | ||
}, | ||
_objectWithoutProperties: function _objectWithoutProperties(obj, keys) { | ||
@@ -95,3 +92,2 @@ var target = {}; | ||
}, | ||
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { | ||
@@ -101,9 +97,7 @@ var ignoredProperties = ['id', 'width', 'height', 'onElementsClick']; | ||
var compareNow = this._objectWithoutProperties(this.props, ignoredProperties); | ||
return !(0, _utilsDeepEqual2['default'])(compareNext, compareNow, { strict: true }); | ||
return !(0, _deepEqual2.default)(compareNext, compareNow, { strict: true }); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.chart_instance.destroy(); | ||
}, | ||
updateChart: function updateChart() { | ||
@@ -114,6 +108,7 @@ var _props = this.props; | ||
if (!this.chart_instance) return; | ||
if (options) { | ||
this.chart_instance.options = _chartJs2['default'].helpers.configMerge(this.chart_instance.options, options); | ||
this.chart_instance.options = _chart2.default.helpers.configMerge(this.chart_instance.options, options); | ||
} | ||
@@ -125,3 +120,2 @@ | ||
}, | ||
renderChart: function renderChart() { | ||
@@ -134,5 +128,5 @@ var _props2 = this.props; | ||
var node = _reactDom2['default'].findDOMNode(this); | ||
var node = _reactDom2.default.findDOMNode(this); | ||
this.chart_instance = new _chartJs2['default'](node, { | ||
this.chart_instance = new _chart2.default(node, { | ||
type: type, | ||
@@ -143,3 +137,2 @@ data: data, | ||
}, | ||
handleOnClick: function handleOnClick(evt) { | ||
@@ -153,3 +146,2 @@ var elems = this.chart_instance.getElementsAtEvent(evt); | ||
}, | ||
render: function render() { | ||
@@ -161,3 +153,4 @@ var _props3 = this.props; | ||
return _react2['default'].createElement('canvas', { | ||
return _react2.default.createElement('canvas', { | ||
height: height, | ||
@@ -170,5 +163,5 @@ width: width, | ||
exports['default'] = ChartComponent; | ||
exports.default = ChartComponent; | ||
var Doughnut = (function (_React$Component) { | ||
var Doughnut = exports.Doughnut = function (_React$Component) { | ||
_inherits(Doughnut, _React$Component); | ||
@@ -179,3 +172,3 @@ | ||
_get(Object.getPrototypeOf(Doughnut.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Doughnut.__proto__ || Object.getPrototypeOf(Doughnut)).apply(this, arguments)); | ||
} | ||
@@ -186,7 +179,7 @@ | ||
value: function render() { | ||
var _this = this; | ||
var _this2 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref) { | ||
return _this2.chart_instance = _ref && _ref.chart_instance; | ||
}, | ||
@@ -199,7 +192,5 @@ type: 'doughnut' | ||
return Doughnut; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Doughnut = Doughnut; | ||
var Pie = (function (_React$Component2) { | ||
var Pie = exports.Pie = function (_React$Component2) { | ||
_inherits(Pie, _React$Component2); | ||
@@ -210,3 +201,3 @@ | ||
_get(Object.getPrototypeOf(Pie.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Pie.__proto__ || Object.getPrototypeOf(Pie)).apply(this, arguments)); | ||
} | ||
@@ -217,7 +208,7 @@ | ||
value: function render() { | ||
var _this2 = this; | ||
var _this4 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this2.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref2) { | ||
return _this4.chart_instance = _ref2 && _ref2.chart_instance; | ||
}, | ||
@@ -230,7 +221,5 @@ type: 'pie' | ||
return Pie; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Pie = Pie; | ||
var Line = (function (_React$Component3) { | ||
var Line = exports.Line = function (_React$Component3) { | ||
_inherits(Line, _React$Component3); | ||
@@ -241,3 +230,3 @@ | ||
_get(Object.getPrototypeOf(Line.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Line.__proto__ || Object.getPrototypeOf(Line)).apply(this, arguments)); | ||
} | ||
@@ -248,7 +237,7 @@ | ||
value: function render() { | ||
var _this3 = this; | ||
var _this6 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this3.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref3) { | ||
return _this6.chart_instance = _ref3 && _ref3.chart_instance; | ||
}, | ||
@@ -261,7 +250,5 @@ type: 'line' | ||
return Line; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Line = Line; | ||
var Bar = (function (_React$Component4) { | ||
var Bar = exports.Bar = function (_React$Component4) { | ||
_inherits(Bar, _React$Component4); | ||
@@ -272,3 +259,3 @@ | ||
_get(Object.getPrototypeOf(Bar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Bar.__proto__ || Object.getPrototypeOf(Bar)).apply(this, arguments)); | ||
} | ||
@@ -279,7 +266,7 @@ | ||
value: function render() { | ||
var _this4 = this; | ||
var _this8 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this4.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref4) { | ||
return _this8.chart_instance = _ref4 && _ref4.chart_instance; | ||
}, | ||
@@ -292,7 +279,5 @@ type: 'bar' | ||
return Bar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Bar = Bar; | ||
var HorizontalBar = (function (_React$Component5) { | ||
var HorizontalBar = exports.HorizontalBar = function (_React$Component5) { | ||
_inherits(HorizontalBar, _React$Component5); | ||
@@ -303,3 +288,3 @@ | ||
_get(Object.getPrototypeOf(HorizontalBar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (HorizontalBar.__proto__ || Object.getPrototypeOf(HorizontalBar)).apply(this, arguments)); | ||
} | ||
@@ -310,7 +295,7 @@ | ||
value: function render() { | ||
var _this5 = this; | ||
var _this10 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this5.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref5) { | ||
return _this10.chart_instance = _ref5 && _ref5.chart_instance; | ||
}, | ||
@@ -323,7 +308,5 @@ type: 'horizontalBar' | ||
return HorizontalBar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.HorizontalBar = HorizontalBar; | ||
var Radar = (function (_React$Component6) { | ||
var Radar = exports.Radar = function (_React$Component6) { | ||
_inherits(Radar, _React$Component6); | ||
@@ -334,3 +317,3 @@ | ||
_get(Object.getPrototypeOf(Radar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Radar.__proto__ || Object.getPrototypeOf(Radar)).apply(this, arguments)); | ||
} | ||
@@ -341,7 +324,7 @@ | ||
value: function render() { | ||
var _this6 = this; | ||
var _this12 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this6.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref6) { | ||
return _this12.chart_instance = _ref6 && _ref6.chart_instance; | ||
}, | ||
@@ -354,7 +337,5 @@ type: 'radar' | ||
return Radar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Radar = Radar; | ||
var Polar = (function (_React$Component7) { | ||
var Polar = exports.Polar = function (_React$Component7) { | ||
_inherits(Polar, _React$Component7); | ||
@@ -365,3 +346,3 @@ | ||
_get(Object.getPrototypeOf(Polar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Polar.__proto__ || Object.getPrototypeOf(Polar)).apply(this, arguments)); | ||
} | ||
@@ -372,7 +353,7 @@ | ||
value: function render() { | ||
var _this7 = this; | ||
var _this14 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this7.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref7) { | ||
return _this14.chart_instance = _ref7 && _ref7.chart_instance; | ||
}, | ||
@@ -385,6 +366,4 @@ type: 'polarArea' | ||
return Polar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Polar = Polar; | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
@@ -394,5 +373,8 @@ },{"./utils/deepEqual":2,"chart.js":undefined,"react-dom":undefined}],2:[function(require,module,exports){ | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -417,3 +399,3 @@ | ||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
@@ -444,6 +426,5 @@ } | ||
exports['default'] = deepEqual; | ||
module.exports = exports['default']; | ||
exports.default = deepEqual; | ||
},{}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,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.Chart=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 p=new Error("Cannot find module '"+a+"'");throw p.code="MODULE_NOT_FOUND",p}var s=n[a]={exports:{}};e[a][0].call(s.exports,function(t){var n=e[a][1][t];return o(n?n:t)},s,s.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e,n){(function(e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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});var a=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),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),u=function(t,e,n){for(var r=!0;r;){var o=t,i=e,a=n;r=!1,null===o&&(o=Function.prototype);var u=Object.getOwnPropertyDescriptor(o,i);if(void 0!==u){if("value"in u)return u.value;var c=u.get;if(void 0===c)return;return c.call(a)}var p=Object.getPrototypeOf(o);if(null===p)return;t=p,e=i,n=a,r=!0,u=p=void 0}},c=Object.assign||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},p="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,s=r(p),f=t("react-dom"),l=r(f),h=t("chart.js"),d=r(h),y=t("./utils/deepEqual"),v=r(y),b=s["default"].createClass({displayName:"ChartComponent",propTypes:{data:p.PropTypes.object.isRequired,height:p.PropTypes.number,legend:p.PropTypes.object,onElementsClick:p.PropTypes.func,options:p.PropTypes.object,redraw:p.PropTypes.bool,type:p.PropTypes.oneOf(["doughnut","pie","line","bar","horizontalBar","radar","polarArea"]),width:p.PropTypes.number},getDefaultProps:function(){return{legend:{display:!0,position:"bottom"},type:"doughnut",height:150,width:300,redraw:!1}},componentWillMount:function(){this.chart_instance=void 0},componentDidMount:function(){this.renderChart()},componentDidUpdate:function(){this.props.redraw?(this.chart_instance.destroy(),this.renderChart()):this.updateChart()},_objectWithoutProperties:function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},shouldComponentUpdate:function(t,e){var n=["id","width","height","onElementsClick"],r=this._objectWithoutProperties(t,n),o=this._objectWithoutProperties(this.props,n);return!(0,v["default"])(r,o,{strict:!0})},componentWillUnmount:function(){this.chart_instance.destroy()},updateChart:function(){var t=this.props,e=t.data,n=t.options;this.chart_instance&&(n&&(this.chart_instance.options=d["default"].helpers.configMerge(this.chart_instance.options,n)),this.chart_instance.config.data=c({},this.chart_instance.config.data,e),this.chart_instance.update())},renderChart:function(){var t=this.props,e=t.data,n=t.options,r=(t.legend,t.type),o=l["default"].findDOMNode(this);this.chart_instance=new d["default"](o,{type:r,data:e,options:n})},handleOnClick:function(t){var e=this.chart_instance.getElementsAtEvent(t);if(e.length){var n=this.props.onElementsClick;n(e)}},render:function(){var t=this.props,e=t.height,n=t.width,r=t.onElementsClick;return s["default"].createElement("canvas",{height:e,width:n,onClick:"function"==typeof r?this.handleOnClick:null})}});n["default"]=b;var O=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"doughnut"}))}}]),e}(s["default"].Component);n.Doughnut=O;var m=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"pie"}))}}]),e}(s["default"].Component);n.Pie=m;var g=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"line"}))}}]),e}(s["default"].Component);n.Line=g;var _=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bar"}))}}]),e}(s["default"].Component);n.Bar=_;var w=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"horizontalBar"}))}}]),e}(s["default"].Component);n.HorizontalBar=w;var P=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"radar"}))}}]),e}(s["default"].Component);n.Radar=P;var j=function(t){function e(){o(this,e),u(Object.getPrototypeOf(e.prototype),"constructor",this).apply(this,arguments)}return i(e,t),a(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"polarArea"}))}}]),e}(s["default"].Component);n.Polar=j}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils/deepEqual":2,"chart.js":void 0,"react-dom":void 0}],2:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty,o=function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e},i=function a(t,e){if(o(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;for(var n=Object.keys(t),i=0;i<n.length;i++)if(!r.call(e,n[i]))return!1;for(var u in t){if(!e.hasOwnProperty(u))return!1;if(!a(t[u],e[u]))return!1}return!0};n["default"]=i,e.exports=n["default"]},{}]},{},[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.Chart=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 f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[a]={exports:{}};e[a][0].call(s.exports,function(t){var n=e[a][1][t];return o(n?n:t)},s,s.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e,n){(function(e){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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 a(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.Polar=n.Radar=n.HorizontalBar=n.Bar=n.Line=n.Pie=n.Doughnut=void 0;var u=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),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),c=Object.assign||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},f="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,s=r(f),p=t("react-dom"),l=r(p),h=t("chart.js"),d=r(h),y=t("./utils/deepEqual"),_=r(y),b=s["default"].createClass({displayName:"ChartComponent",propTypes:{data:f.PropTypes.object.isRequired,height:f.PropTypes.number,legend:f.PropTypes.object,onElementsClick:f.PropTypes.func,options:f.PropTypes.object,redraw:f.PropTypes.bool,type:f.PropTypes.oneOf(["doughnut","pie","line","bar","horizontalBar","radar","polarArea"]),width:f.PropTypes.number},getDefaultProps:function(){return{legend:{display:!0,position:"bottom"},type:"doughnut",height:150,width:300,redraw:!1}},componentWillMount:function(){this.chart_instance=void 0},componentDidMount:function(){this.renderChart()},componentDidUpdate:function(){this.props.redraw?(this.chart_instance.destroy(),this.renderChart()):this.updateChart()},_objectWithoutProperties:function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n},shouldComponentUpdate:function(t,e){var n=["id","width","height","onElementsClick"],r=this._objectWithoutProperties(t,n),o=this._objectWithoutProperties(this.props,n);return!(0,_["default"])(r,o,{strict:!0})},componentWillUnmount:function(){this.chart_instance.destroy()},updateChart:function(){var t=this.props,e=t.data,n=t.options;this.chart_instance&&(n&&(this.chart_instance.options=d["default"].helpers.configMerge(this.chart_instance.options,n)),this.chart_instance.config.data=c({},this.chart_instance.config.data,e),this.chart_instance.update())},renderChart:function(){var t=this.props,e=t.data,n=t.options,r=(t.legend,t.type),o=l["default"].findDOMNode(this);this.chart_instance=new d["default"](o,{type:r,data:e,options:n})},handleOnClick:function(t){var e=this.chart_instance.getElementsAtEvent(t);if(e.length){var n=this.props.onElementsClick;n(e)}},render:function(){var t=this.props,e=t.height,n=t.width,r=t.onElementsClick;return s["default"].createElement("canvas",{height:e,width:n,onClick:"function"==typeof r?this.handleOnClick:null})}});n["default"]=b;n.Doughnut=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"doughnut"}))}}]),e}(s["default"].Component),n.Pie=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"pie"}))}}]),e}(s["default"].Component),n.Line=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"line"}))}}]),e}(s["default"].Component),n.Bar=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"bar"}))}}]),e}(s["default"].Component),n.HorizontalBar=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"horizontalBar"}))}}]),e}(s["default"].Component),n.Radar=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"radar"}))}}]),e}(s["default"].Component),n.Polar=function(t){function e(){return o(this,e),i(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),u(e,[{key:"render",value:function(){var t=this;return s["default"].createElement(b,c({},this.props,{ref:function(e){return t.chart_instance=e&&e.chart_instance},type:"polarArea"}))}}]),e}(s["default"].Component)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils/deepEqual":2,"chart.js":void 0,"react-dom":void 0}],2:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},o=Object.prototype.hasOwnProperty,i=function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e},a=function u(t,e){if(i(t,e))return!0;if("object"!==("undefined"==typeof t?"undefined":r(t))||null===t||"object"!==("undefined"==typeof e?"undefined":r(e))||null===e)return!1;for(var n=Object.keys(t),a=0;a<n.length;a++)if(!o.call(e,n[a]))return!1;for(var c in t){if(!e.hasOwnProperty(c))return!1;if(!u(t[c],e[c]))return!1}return!0};n["default"]=a},{}]},{},[1])(1)}); |
167
lib/Chart.js
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Polar = exports.Radar = exports.HorizontalBar = exports.Bar = exports.Line = exports.Pie = exports.Doughnut = undefined; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _react = require('react'); | ||
@@ -27,12 +20,20 @@ | ||
var _chartJs = require('chart.js'); | ||
var _chart = require('chart.js'); | ||
var _chartJs2 = _interopRequireDefault(_chartJs); | ||
var _chart2 = _interopRequireDefault(_chart); | ||
var _utilsDeepEqual = require('./utils/deepEqual'); | ||
var _deepEqual = require('./utils/deepEqual'); | ||
var _utilsDeepEqual2 = _interopRequireDefault(_utilsDeepEqual); | ||
var _deepEqual2 = _interopRequireDefault(_deepEqual); | ||
var ChartComponent = _react2['default'].createClass({ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var ChartComponent = _react2.default.createClass({ | ||
displayName: 'ChartComponent', | ||
@@ -63,11 +64,8 @@ | ||
}, | ||
componentWillMount: function componentWillMount() { | ||
this.chart_instance = undefined; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
this.renderChart(); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
@@ -81,3 +79,2 @@ if (this.props.redraw) { | ||
}, | ||
_objectWithoutProperties: function _objectWithoutProperties(obj, keys) { | ||
@@ -92,3 +89,2 @@ var target = {}; | ||
}, | ||
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { | ||
@@ -98,9 +94,7 @@ var ignoredProperties = ['id', 'width', 'height', 'onElementsClick']; | ||
var compareNow = this._objectWithoutProperties(this.props, ignoredProperties); | ||
return !(0, _utilsDeepEqual2['default'])(compareNext, compareNow, { strict: true }); | ||
return !(0, _deepEqual2.default)(compareNext, compareNow, { strict: true }); | ||
}, | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.chart_instance.destroy(); | ||
}, | ||
updateChart: function updateChart() { | ||
@@ -111,6 +105,7 @@ var _props = this.props; | ||
if (!this.chart_instance) return; | ||
if (options) { | ||
this.chart_instance.options = _chartJs2['default'].helpers.configMerge(this.chart_instance.options, options); | ||
this.chart_instance.options = _chart2.default.helpers.configMerge(this.chart_instance.options, options); | ||
} | ||
@@ -122,3 +117,2 @@ | ||
}, | ||
renderChart: function renderChart() { | ||
@@ -131,5 +125,5 @@ var _props2 = this.props; | ||
var node = _reactDom2['default'].findDOMNode(this); | ||
var node = _reactDom2.default.findDOMNode(this); | ||
this.chart_instance = new _chartJs2['default'](node, { | ||
this.chart_instance = new _chart2.default(node, { | ||
type: type, | ||
@@ -140,3 +134,2 @@ data: data, | ||
}, | ||
handleOnClick: function handleOnClick(evt) { | ||
@@ -150,3 +143,2 @@ var elems = this.chart_instance.getElementsAtEvent(evt); | ||
}, | ||
render: function render() { | ||
@@ -158,3 +150,4 @@ var _props3 = this.props; | ||
return _react2['default'].createElement('canvas', { | ||
return _react2.default.createElement('canvas', { | ||
height: height, | ||
@@ -167,5 +160,5 @@ width: width, | ||
exports['default'] = ChartComponent; | ||
exports.default = ChartComponent; | ||
var Doughnut = (function (_React$Component) { | ||
var Doughnut = exports.Doughnut = function (_React$Component) { | ||
_inherits(Doughnut, _React$Component); | ||
@@ -176,3 +169,3 @@ | ||
_get(Object.getPrototypeOf(Doughnut.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Doughnut.__proto__ || Object.getPrototypeOf(Doughnut)).apply(this, arguments)); | ||
} | ||
@@ -183,7 +176,7 @@ | ||
value: function render() { | ||
var _this = this; | ||
var _this2 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref) { | ||
return _this2.chart_instance = _ref && _ref.chart_instance; | ||
}, | ||
@@ -196,7 +189,5 @@ type: 'doughnut' | ||
return Doughnut; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Doughnut = Doughnut; | ||
var Pie = (function (_React$Component2) { | ||
var Pie = exports.Pie = function (_React$Component2) { | ||
_inherits(Pie, _React$Component2); | ||
@@ -207,3 +198,3 @@ | ||
_get(Object.getPrototypeOf(Pie.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Pie.__proto__ || Object.getPrototypeOf(Pie)).apply(this, arguments)); | ||
} | ||
@@ -214,7 +205,7 @@ | ||
value: function render() { | ||
var _this2 = this; | ||
var _this4 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this2.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref2) { | ||
return _this4.chart_instance = _ref2 && _ref2.chart_instance; | ||
}, | ||
@@ -227,7 +218,5 @@ type: 'pie' | ||
return Pie; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Pie = Pie; | ||
var Line = (function (_React$Component3) { | ||
var Line = exports.Line = function (_React$Component3) { | ||
_inherits(Line, _React$Component3); | ||
@@ -238,3 +227,3 @@ | ||
_get(Object.getPrototypeOf(Line.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Line.__proto__ || Object.getPrototypeOf(Line)).apply(this, arguments)); | ||
} | ||
@@ -245,7 +234,7 @@ | ||
value: function render() { | ||
var _this3 = this; | ||
var _this6 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this3.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref3) { | ||
return _this6.chart_instance = _ref3 && _ref3.chart_instance; | ||
}, | ||
@@ -258,7 +247,5 @@ type: 'line' | ||
return Line; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Line = Line; | ||
var Bar = (function (_React$Component4) { | ||
var Bar = exports.Bar = function (_React$Component4) { | ||
_inherits(Bar, _React$Component4); | ||
@@ -269,3 +256,3 @@ | ||
_get(Object.getPrototypeOf(Bar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Bar.__proto__ || Object.getPrototypeOf(Bar)).apply(this, arguments)); | ||
} | ||
@@ -276,7 +263,7 @@ | ||
value: function render() { | ||
var _this4 = this; | ||
var _this8 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this4.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref4) { | ||
return _this8.chart_instance = _ref4 && _ref4.chart_instance; | ||
}, | ||
@@ -289,7 +276,5 @@ type: 'bar' | ||
return Bar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Bar = Bar; | ||
var HorizontalBar = (function (_React$Component5) { | ||
var HorizontalBar = exports.HorizontalBar = function (_React$Component5) { | ||
_inherits(HorizontalBar, _React$Component5); | ||
@@ -300,3 +285,3 @@ | ||
_get(Object.getPrototypeOf(HorizontalBar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (HorizontalBar.__proto__ || Object.getPrototypeOf(HorizontalBar)).apply(this, arguments)); | ||
} | ||
@@ -307,7 +292,7 @@ | ||
value: function render() { | ||
var _this5 = this; | ||
var _this10 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this5.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref5) { | ||
return _this10.chart_instance = _ref5 && _ref5.chart_instance; | ||
}, | ||
@@ -320,7 +305,5 @@ type: 'horizontalBar' | ||
return HorizontalBar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.HorizontalBar = HorizontalBar; | ||
var Radar = (function (_React$Component6) { | ||
var Radar = exports.Radar = function (_React$Component6) { | ||
_inherits(Radar, _React$Component6); | ||
@@ -331,3 +314,3 @@ | ||
_get(Object.getPrototypeOf(Radar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Radar.__proto__ || Object.getPrototypeOf(Radar)).apply(this, arguments)); | ||
} | ||
@@ -338,7 +321,7 @@ | ||
value: function render() { | ||
var _this6 = this; | ||
var _this12 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this6.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref6) { | ||
return _this12.chart_instance = _ref6 && _ref6.chart_instance; | ||
}, | ||
@@ -351,7 +334,5 @@ type: 'radar' | ||
return Radar; | ||
})(_react2['default'].Component); | ||
}(_react2.default.Component); | ||
exports.Radar = Radar; | ||
var Polar = (function (_React$Component7) { | ||
var Polar = exports.Polar = function (_React$Component7) { | ||
_inherits(Polar, _React$Component7); | ||
@@ -362,3 +343,3 @@ | ||
_get(Object.getPrototypeOf(Polar.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, (Polar.__proto__ || Object.getPrototypeOf(Polar)).apply(this, arguments)); | ||
} | ||
@@ -369,7 +350,7 @@ | ||
value: function render() { | ||
var _this7 = this; | ||
var _this14 = this; | ||
return _react2['default'].createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function (ref) { | ||
return _this7.chart_instance = ref && ref.chart_instance; | ||
return _react2.default.createElement(ChartComponent, _extends({}, this.props, { | ||
ref: function ref(_ref7) { | ||
return _this14.chart_instance = _ref7 && _ref7.chart_instance; | ||
}, | ||
@@ -382,4 +363,2 @@ type: 'polarArea' | ||
return Polar; | ||
})(_react2['default'].Component); | ||
exports.Polar = Polar; | ||
}(_react2.default.Component); |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -25,3 +28,3 @@ | ||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
@@ -52,3 +55,2 @@ } | ||
exports['default'] = deepEqual; | ||
module.exports = exports['default']; | ||
exports.default = deepEqual; |
{ | ||
"name": "react-chartjs-2", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "react-chartjs-2", | ||
@@ -20,8 +20,15 @@ "main": "lib/Chart.js", | ||
"babel-eslint": "^4.1.3", | ||
"babel-jest": "^14.1.0", | ||
"babel-preset-es2015": "^6.13.2", | ||
"babel-preset-react": "^6.11.1", | ||
"babel-preset-stage-1": "^6.13.0", | ||
"babelify": "^7.3.0", | ||
"brfs": "^1.4.3", | ||
"eslint": "^1.6.0", | ||
"eslint-plugin-react": "^3.5.1", | ||
"gulp": "^3.9.0", | ||
"react": "^0.14.0", | ||
"react-component-gulp-tasks": "^0.7.6", | ||
"react-dom": "^0.14.0" | ||
"jest": "^14.1.0", | ||
"react": "^0.14 || ^15.0.0-rc || ^15.0", | ||
"react-component-gulp-tasks": "git+https://github.com/gor181/react-component-gulp-tasks.git", | ||
"react-dom": "^0.14 || ^15.0.0-rc || ^15.0" | ||
}, | ||
@@ -42,5 +49,8 @@ "peerDependencies": { | ||
"start": "gulp dev", | ||
"test": "echo \"no tests yet\" && exit 0", | ||
"test": "jest", | ||
"watch": "gulp watch:lib" | ||
}, | ||
"jest": { | ||
"automock": false | ||
}, | ||
"keywords": [ | ||
@@ -47,0 +57,0 @@ "react", |
@@ -0,1 +1,3 @@ | ||
[![build status](https://travis-ci.org/gor181/react-chartjs-2.svg?branch=master)](https://travis-ci.org/gor181/react-chartjs-2) | ||
# react-chartjs-2 | ||
@@ -48,2 +50,16 @@ | ||
### Custom size | ||
In order for Chart.js to obey the custom size you need to set `maintainAspectRatio` to false, example: | ||
``` | ||
<Bar | ||
data={data} | ||
width={100} | ||
height={50} | ||
options={{ | ||
maintainAspectRatio: false | ||
}} | ||
/> | ||
``` | ||
### Chart instance | ||
@@ -50,0 +66,0 @@ Chart instance can be accessed by placing a ref to the element as: |
Sorry, the diff of this file is not supported yet
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4301868
70024
1
105
14
25
12
1