UNPKG

@gooddata/react-components

Version:

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

88 lines 4.56 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-2018 GoodData Corporation var React = require("react"); var invariant = require("invariant"); var isEqual = require("lodash/isEqual"); var noop = require("lodash/noop"); var isFunction = require("lodash/isFunction"); var omitBy = require("lodash/omitBy"); var highchartsEntryPoint_1 = require("./chart/highcharts/highchartsEntryPoint"); var common_1 = require("./utils/common"); var TableTransformation_1 = require("./table/TableTransformation"); var ChartTransformation_1 = require("./chart/ChartTransformation"); var Visualization = /** @class */ (function (_super) { __extends(Visualization, _super); function Visualization(props) { var _this = _super.call(this, props) || this; _this.setNumericSymbols(_this.props); return _this; } Visualization.prototype.componentWillReceiveProps = function (nextProps) { this.setNumericSymbols(nextProps); }; Visualization.prototype.shouldComponentUpdate = function (nextProps) { return !isEqual(omitBy(this.props, isFunction), omitBy(nextProps, isFunction)); }; Visualization.prototype.setNumericSymbols = function (props) { var numericSymbols = props.numericSymbols; if (numericSymbols && numericSymbols.length) { highchartsEntryPoint_1.default.setOptions({ lang: { numericSymbols: numericSymbols, }, }); } }; Visualization.prototype.render = function () { var visType = this.props.config.type; if (common_1.isTable(visType)) { return (React.createElement(TableTransformation_1.TableTransformation, __assign({}, this.props, { executionRequest: { execution: { afm: this.props.executionRequest.afm, resultSpec: this.props.executionRequest.resultSpec, }, } }))); } if (common_1.isChartSupported(visType)) { var _a = this.props, height = _a.height, width = _a.width, config = _a.config, executionRequest = _a.executionRequest, executionResponse = _a.executionResponse, executionResult = _a.executionResult, drillableItems = _a.drillableItems, onFiredDrillEvent = _a.onFiredDrillEvent, onDrill = _a.onDrill, afterRender = _a.afterRender, onDataTooLarge = _a.onDataTooLarge, onNegativeValues = _a.onNegativeValues, onLegendReady = _a.onLegendReady, locale = _a.locale, pushData = _a.pushData; return (React.createElement(ChartTransformation_1.default, { height: height, width: width, config: config, drillableItems: drillableItems, locale: locale, executionRequest: executionRequest, executionResponse: executionResponse, executionResult: executionResult, afterRender: afterRender, onFiredDrillEvent: onFiredDrillEvent, onDrill: onDrill, onDataTooLarge: onDataTooLarge, onNegativeValues: onNegativeValues, onLegendReady: onLegendReady, pushData: pushData, renderer: ChartTransformation_1.renderHighCharts })); } invariant(false, "Unknown visualization type: " + visType + ". Supported visualization types: " + common_1.stringifyChartTypes()); return null; }; Visualization.defaultProps = { locale: "en-US", numericSymbols: [], onFiredDrillEvent: function () { return true; }, onDrill: noop, afterRender: noop, }; return Visualization; }(React.Component)); exports.Visualization = Visualization; //# sourceMappingURL=Visualization.js.map