highcharts-react-official
Version:
Official minimal [Highcharts](https://www.highcharts.com/) wrapper for React.
186 lines (161 loc) • 7.74 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("React"));
else if(typeof define === 'function' && define.amd)
define(["React"], factory);
else if(typeof exports === 'object')
exports["HighchartsReact"] = factory(require("React"));
else
root["HighchartsReact"] = factory(root["React"]);
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; };
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 _react = __webpack_require__(1);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
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 HighchartsReact = function (_React$PureComponent) {
_inherits(HighchartsReact, _React$PureComponent);
function HighchartsReact(props) {
_classCallCheck(this, HighchartsReact);
var _this = _possibleConstructorReturn(this, (HighchartsReact.__proto__ || Object.getPrototypeOf(HighchartsReact)).call(this, props));
_this.container = _react2.default.createRef();
return _this;
}
_createClass(HighchartsReact, [{
key: "createChart",
value: function createChart() {
var props = this.props;
var H = props.highcharts || window.Highcharts;
var constructorType = props.constructorType || "chart";
if (!H) {
console.warn('The "highcharts" property was not passed.');
} else if (!H[constructorType]) {
console.warn('The "constructorType" property is incorrect or some ' + 'required module is not imported.');
} else if (!props.options) {
console.warn('The "options" property was not passed.');
} else {
// Create a chart
this.chart = H[constructorType](this.container.current, props.options, props.callback ? props.callback : undefined);
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.createChart();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate() {
var props = this.props;
if (props.allowChartUpdate !== false) {
if (!props.immutable && this.chart) {
var _chart;
(_chart = this.chart).update.apply(_chart, [props.options].concat(_toConsumableArray(props.updateArgs || [true, true])));
} else {
this.createChart();
}
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
// Destroy chart
if (this.chart) {
this.chart.destroy();
this.chart = null;
}
}
}, {
key: "render",
value: function render() {
// Create container for the chart
return _react2.default.createElement("div", _extends({}, this.props.containerProps, { ref: this.container }));
}
}]);
return HighchartsReact;
}(_react2.default.PureComponent);
exports.default = HighchartsReact;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
/***/ })
/******/ ]);
});
//# sourceMappingURL=highcharts-react.js.map