Skip to content

Commit 46e3f50

Browse files
authored
Merge pull request #19 from sghosh9/feature/all-events
add event props to config object
2 parents 1e4c17e + b5beb54 commit 46e3f50

File tree

4 files changed

+40
-31
lines changed

4 files changed

+40
-31
lines changed

dist/react-fusioncharts.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ return /******/ (function(modules) { // webpackBootstrap
108108

109109
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; }
110110

111-
var staticEvents = ['ready', 'beforeinitialize', 'initialized'];
112-
113111
var ReactFC = function (_React$Component) {
114112
_inherits(ReactFC, _React$Component);
115113

@@ -338,22 +336,27 @@ return /******/ (function(modules) { // webpackBootstrap
338336
var _this4 = this;
339337

340338
var currentOptions = this.resolveChartOptions(this.props);
339+
var events = {};
340+
341341
currentOptions.renderAt = this.containerId;
342342

343-
this.chartObj = new this.FusionCharts(currentOptions);
344343
Object.keys(this.props).forEach(function (value) {
345344
var event = value.match(/^fcEvent-.*/i);
346-
347345
if (event && typeof _this4.props[value] === 'function') {
348346
var eventName = value.replace(/^fcEvent-/i, '');
349-
350-
if (staticEvents.indexOf(eventName.toLowerCase()) > -1) {
351-
_this4.FusionCharts.addEventListener(eventName, _this4.props[value]);
352-
} else {
353-
_this4.chartObj.addEventListener(eventName, _this4.props[value]);
354-
}
347+
events[eventName] = _this4.props[value];
355348
}
356349
});
350+
351+
if (Object.keys(events).length > 0) {
352+
if (currentOptions.events === undefined) {
353+
currentOptions.events = events;
354+
} else {
355+
currentOptions.events = Object.assign(currentOptions.events, events);
356+
}
357+
}
358+
359+
this.chartObj = new this.FusionCharts(currentOptions);
357360
this.chartObj.render();
358361
this.oldOptions = currentOptions;
359362

0 commit comments

Comments
 (0)