diff --git a/dist/react-chartjs-2.js b/dist/react-chartjs-2.js index 3129b8999..0861e59eb 100644 --- a/dist/react-chartjs-2.js +++ b/dist/react-chartjs-2.js @@ -100,8 +100,6 @@ var ChartComponent = _react2['default'].createClass({ }, updateChart: function updateChart() { - var _this = this; - var _props = this.props; var data = _props.data; var options = _props.options; @@ -109,12 +107,10 @@ var ChartComponent = _react2['default'].createClass({ if (!this.chart_instance) return; if (options) { - _chartJs2['default'].helpers.configMerge(this.chart_instance.options, options); + this.chart_instance.options = _chartJs2['default'].helpers.configMerge(this.chart_instance.options, options); } - data.datasets.forEach(function (dataset, index) { - _this.chart_instance.data.datasets[index] = dataset; - }); + this.chart_instance.config.data = _extends({}, this.chart_instance.config.data, data); this.chart_instance.update(); }, diff --git a/dist/react-chartjs-2.min.js b/dist/react-chartjs-2.min.js index 332f09068..51d61f154 100644 --- a/dist/react-chartjs-2.min.js +++ b/dist/react-chartjs-2.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Chart=e()}}(function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(i)return i(a,!0);var d=new Error("Cannot find module '"+a+"'");throw d.code="MODULE_NOT_FOUND",d}var s=n[a]={exports:{}};t[a][0].call(s.exports,function(e){var n=t[a][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},shouldComponentUpdate:function(e,t){var n=this._objectWithoutProperties(e,["id","width","height"]),r=this._objectWithoutProperties(this.props,["id","width","height"]);return!(0,b["default"])(n,r,{strict:!0})},componentWillUnmount:function(){this.chart_instance.destroy()},updateChart:function(){var e=this,t=this.props,n=t.data,r=t.options;this.chart_instance&&(r&&v["default"].helpers.configMerge(this.chart_instance.options,r),n.datasets.forEach(function(t,n){e.chart_instance.data.datasets[n]=t}),this.chart_instance.update())},renderChart:function(){var e=this.props,t=e.data,n=e.options,r=(e.legend,e.type),o=y["default"].findDOMNode(this);this.chart_instance=new v["default"](o,{type:r,data:t,options:n})},handleOnClick:function(e){var t=this.chart_instance.getElementsAtEvent(e);if(t.length){var n=this.props.onElementsClick;n(t)}},render:function(){var e=this.props,t=e.height,n=e.width,r=e.onElementsClick;return p["default"].createElement("canvas",{height:t,width:n,onClick:"function"==typeof r?this.handleOnClick:null})}});n["default"]=g}).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(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty,o=function(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t},i=function a(e,t){if(o(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;for(var n=Object.keys(e),i=0;i=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},shouldComponentUpdate:function(e,t){var n=this._objectWithoutProperties(e,["id","width","height"]),r=this._objectWithoutProperties(this.props,["id","width","height"]);return!(0,w["default"])(n,r,{strict:!0})},componentWillUnmount:function(){this.chart_instance.destroy()},updateChart:function(){var e=this.props,t=e.data,n=e.options;this.chart_instance&&(n&&(this.chart_instance.options=v["default"].helpers.configMerge(this.chart_instance.options,n)),this.chart_instance.config.data=s({},this.chart_instance.config.data,t),this.chart_instance.update())},renderChart:function(){var e=this.props,t=e.data,n=e.options,r=(e.legend,e.type),o=y["default"].findDOMNode(this);this.chart_instance=new v["default"](o,{type:r,data:t,options:n})},handleOnClick:function(e){var t=this.chart_instance.getElementsAtEvent(e);if(t.length){var n=this.props.onElementsClick;n(t)}},render:function(){var e=this.props,t=e.height,n=e.width,r=e.onElementsClick;return l["default"].createElement("canvas",{height:t,width:n,onClick:"function"==typeof r?this.handleOnClick:null})}});n["default"]=b}).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(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty,o=function(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t},i=function a(e,t){if(o(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;for(var n=Object.keys(e),i=0;i { - this.chart_instance.data.datasets[index] = dataset; - }); + this.chart_instance.config.data = { + ...this.chart_instance.config.data, + ...data + }; this.chart_instance.update(); },