UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

98 lines 4.15 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2007-2020 GoodData Corporation var isEqual = require("lodash/isEqual"); var noop = require("lodash/noop"); var React = require("react"); var chartPlugins_1 = require("./highcharts/chartPlugins"); var highchartsEntryPoint_1 = require("./highcharts/highchartsEntryPoint"); var HighchartsMore = require("highcharts/highcharts-more"); // tslint:disable-line var drillmodule = require("highcharts/modules/drilldown"); // tslint:disable-line var treemapModule = require("highcharts/modules/treemap"); // tslint:disable-line var bulletModule = require("highcharts/modules/bullet"); // tslint:disable-line var funnelModule = require("highcharts/modules/funnel"); // tslint:disable-line var heatmap = require("highcharts/modules/heatmap"); // tslint:disable-line var patternFill = require("highcharts/modules/pattern-fill"); // tslint:disable-line var groupedCategories = require("highcharts-grouped-categories"); // tslint:disable-line drillmodule(highchartsEntryPoint_1.default); treemapModule(highchartsEntryPoint_1.default); bulletModule(highchartsEntryPoint_1.default); funnelModule(highchartsEntryPoint_1.default); heatmap(highchartsEntryPoint_1.default); HighchartsMore(highchartsEntryPoint_1.default); patternFill(highchartsEntryPoint_1.default); groupedCategories(highchartsEntryPoint_1.default); chartPlugins_1.initChartPlugins(highchartsEntryPoint_1.default); var Chart = /** @class */ (function (_super) { __extends(Chart, _super); function Chart(props) { var _this = _super.call(this, props) || this; _this.setChartRef = _this.setChartRef.bind(_this); return _this; } Chart.prototype.componentDidMount = function () { this.createChart(this.props.config); }; Chart.prototype.shouldComponentUpdate = function (nextProps) { if (isEqual(this.props.config, nextProps.config)) { return false; } return true; }; Chart.prototype.componentDidUpdate = function () { this.createChart(this.props.config); }; Chart.prototype.componentWillUnmount = function () { this.chart.destroy(); }; Chart.prototype.setChartRef = function (ref) { this.chartRef = ref; }; Chart.prototype.getHighchartRef = function () { return this.chartRef; }; Chart.prototype.getChart = function () { if (!this.chart) { throw new Error("getChart() should not be called before the component is mounted"); } return this.chart; }; Chart.prototype.createChart = function (config) { var chartConfig = config.chart; this.chart = new highchartsEntryPoint_1.default.Chart(__assign({}, config, { chart: __assign({}, chartConfig, { renderTo: this.chartRef }) }), this.props.callback); }; Chart.prototype.render = function () { return React.createElement("div", __assign({}, this.props.domProps, { ref: this.setChartRef })); }; Chart.defaultProps = { callback: noop, domProps: {}, }; return Chart; }(React.Component)); exports.default = Chart; //# sourceMappingURL=Chart.js.map