UNPKG

butterfly-chart-react

Version:

Butterfly Chart Component for React

91 lines (73 loc) 3.78 kB
'use strict'; exports.__esModule = true; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _BarChart = require('../BarChart/BarChart.js'); var _BarChart2 = _interopRequireDefault(_BarChart); require('./ButterflyChart.css'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 ButterflyChart = function (_Component) { _inherits(ButterflyChart, _Component); function ButterflyChart() { _classCallCheck(this, ButterflyChart); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } ButterflyChart.prototype.render = function render() { var time_periods = []; return _react2.default.createElement( 'div', { className: 'ChartAreaContainer Card--style' }, _react2.default.createElement( 'div', { className: 'ChartAreaContainer-dimention' }, this.props.title ), _react2.default.createElement( 'div', { className: 'ChartAreaContainer-leftLabel' }, this.props.option_select_1 ), _react2.default.createElement( 'div', { className: 'ChartAreaContainer-rightLabel' }, this.props.option_select_2 ), _react2.default.createElement(_BarChart2.default, { data: this.props.data_option_1, option_title: this.props.option_select_1, graph: 'Graph1', graphBar: 'Graph1-bar', highest_value: this.props.highest_value, barColor: this.props.barColor_1 }), _react2.default.createElement( 'div', { className: 'TimePeriods' }, this.props.data_option_1 && this.props.data_option_2 && this.props.data_option_1.forEach(function (element) { !time_periods.includes(element.time_period) && time_periods.push(element.time_period); }), time_periods.map(function (time_period) { return _react2.default.createElement( 'div', null, time_period ); }) ), _react2.default.createElement(_BarChart2.default, { data: this.props.data_option_2, option_title: this.props.option_select_2, graph: 'Graph2', graphBar: 'Graph2-bar', highest_value: this.props.highest_value, barColor: this.props.barColor_2 }) ); }; return ButterflyChart; }(_react.Component); exports.default = ButterflyChart; module.exports = exports['default'];