UNPKG

react-meteo-chart

Version:

pre alpha of meteo chart

462 lines (365 loc) 14.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FullPluvioLegend = exports.PluvioLegend24h = exports.PluvioLegend6h = exports.PluvioLegend3h = exports.PluvioLegend1h = exports.COLORS = void 0; var _react = _interopRequireWildcard(require("react")); var _reactVis = require("react-vis"); var _GridDates = require("../GridDates"); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var COLORS = { Sum24hColor: "#1111ff", Sum24hStrokeColor: "#000000", Sum6hColor: "#7777ff", Sum6hStrokeColor: "#000000", Sum3hColor: "#bbbbff", Sum3hStrokeColor: "#000000", Sum1hColor: "#eeeeff", Sum1hStrokeColor: "#000000" // temperatureColor: "#dce775", // barometricTendencyColor: "#1f6025", // precipitationColor: "#40bfb7", // normalizedPressureColor: "#342d86", // pressureColor: "#822d86" }; exports.COLORS = COLORS; var ITEMS = [{ title: "Сумма за час", color: "".concat(COLORS.Sum1hColor), strokeWidth: 10 }, { title: "Сумма за 3 часа", color: "".concat(COLORS.Sum3hColor), strokeWidth: 10 }, { title: "Сумма за 6 часов", color: "".concat(COLORS.Sum6hColor), strokeWidth: 10 }, { title: "Дневная Сумма", color: "".concat(COLORS.Sum24hColor), strokeWidth: 10 }]; var PluvioLegend1h = /*#__PURE__*/ function (_Component) { _inherits(PluvioLegend1h, _Component); function PluvioLegend1h() { var _getPrototypeOf2; var _this; _classCallCheck(this, PluvioLegend1h); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PluvioLegend1h)).call.apply(_getPrototypeOf2, [this].concat(args))); _defineProperty(_assertThisInitialized(_this), "state", { hsum: true, hsum3: true, hsum6: true, hsum24: true }); return _this; } _createClass(PluvioLegend1h, [{ key: "render", value: function render() { var _this2 = this; var hsum = this.state.hsum; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", orientation: isAdmin ? "vertical" : "horizontal", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 150 : true, items: [ITEMS[0]], onItemClick: function onItemClick(e) { switch (e.title) { case "Сумма за час": _this2.setState({ hsum: !hsum }); setVal(hsum, "hsum"); break; default: console.log("Unknown item"); break; } } }); } }]); return PluvioLegend1h; }(_react.Component); exports.PluvioLegend1h = PluvioLegend1h; var PluvioLegend3h = /*#__PURE__*/ function (_Component2) { _inherits(PluvioLegend3h, _Component2); function PluvioLegend3h() { var _getPrototypeOf3; var _this3; _classCallCheck(this, PluvioLegend3h); for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } _this3 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(PluvioLegend3h)).call.apply(_getPrototypeOf3, [this].concat(args))); _defineProperty(_assertThisInitialized(_this3), "state", { hsum: true, hsum3: true, hsum6: true, hsum24: true }); return _this3; } _createClass(PluvioLegend3h, [{ key: "render", value: function render() { var _this4 = this; var hsum3 = this.state.hsum3; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", orientation: isAdmin ? "vertical" : "horizontal", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 150 : true, items: [ITEMS[1]], onItemClick: function onItemClick(e) { switch (e.title) { case "Сумма за 3 часа": _this4.setState({ hsum3: !hsum3 }); setVal(hsum3, "hsum3"); break; default: console.log("Unknown item"); break; } } }); } }]); return PluvioLegend3h; }(_react.Component); exports.PluvioLegend3h = PluvioLegend3h; var PluvioLegend6h = /*#__PURE__*/ function (_Component3) { _inherits(PluvioLegend6h, _Component3); function PluvioLegend6h() { var _getPrototypeOf4; var _this5; _classCallCheck(this, PluvioLegend6h); for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } _this5 = _possibleConstructorReturn(this, (_getPrototypeOf4 = _getPrototypeOf(PluvioLegend6h)).call.apply(_getPrototypeOf4, [this].concat(args))); _defineProperty(_assertThisInitialized(_this5), "state", { hsum: true, hsum3: true, hsum6: true, hsum24: true }); return _this5; } _createClass(PluvioLegend6h, [{ key: "render", value: function render() { var _this6 = this; var hsum6 = this.state.hsum6; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", orientation: isAdmin ? "vertical" : "horizontal", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 150 : true, items: [ITEMS[2]], onItemClick: function onItemClick(e) { switch (e.title) { case "Сумма за 6 часов": _this6.setState({ hsum6: !hsum6 }); setVal(hsum6, "hsum6"); break; default: console.log("Unknown item"); break; } } }); } }]); return PluvioLegend6h; }(_react.Component); exports.PluvioLegend6h = PluvioLegend6h; var PluvioLegend24h = /*#__PURE__*/ function (_Component4) { _inherits(PluvioLegend24h, _Component4); function PluvioLegend24h() { var _getPrototypeOf5; var _this7; _classCallCheck(this, PluvioLegend24h); for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } _this7 = _possibleConstructorReturn(this, (_getPrototypeOf5 = _getPrototypeOf(PluvioLegend24h)).call.apply(_getPrototypeOf5, [this].concat(args))); _defineProperty(_assertThisInitialized(_this7), "state", { hsum: true, hsum3: true, hsum6: true, hsum24: true }); return _this7; } _createClass(PluvioLegend24h, [{ key: "render", value: function render() { var _this8 = this; var hsum24 = this.state.hsum24; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legendpr", orientation: isAdmin ? "vertical" : "horizontal", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 150 : true, items: [ITEMS[3]], onItemClick: function onItemClick(e) { switch (e.title) { case "Дневная Сумма": _this8.setState({ hsum24: !hsum24 }); setVal(hsum24, "hsum24"); break; default: console.log("Unknown item"); break; } } }); } }]); return PluvioLegend24h; }(_react.Component); exports.PluvioLegend24h = PluvioLegend24h; var PluvioLegend24hM = /*#__PURE__*/ function (_Component5) { _inherits(PluvioLegend24hM, _Component5); function PluvioLegend24hM() { var _getPrototypeOf6; var _this9; _classCallCheck(this, PluvioLegend24hM); for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } _this9 = _possibleConstructorReturn(this, (_getPrototypeOf6 = _getPrototypeOf(PluvioLegend24hM)).call.apply(_getPrototypeOf6, [this].concat(args))); _defineProperty(_assertThisInitialized(_this9), "state", { hsum: true, hsum3: true, hsum6: true, hsum24: true }); return _this9; } _createClass(PluvioLegend24hM, [{ key: "render", value: function render() { var _this10 = this, _React$createElement; var hsum24 = this.state.hsum24; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, (_React$createElement = { className: "legend", orientation: "horizontal", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 150 : true, items: [ITEMS[3]] }, _defineProperty(_React$createElement, "orientation", isAdmin ? "vertical" : "horizontal"), _defineProperty(_React$createElement, "onItemClick", function onItemClick(e) { switch (e.title) { case "Дневная Сумма": _this10.setState({ hsum24: !hsum24 }); setVal(hsum24, "hsum24"); break; default: console.log("Unknown item"); break; } }), _React$createElement)); } }]); return PluvioLegend24hM; }(_react.Component); var FullPluvioLegend = /*#__PURE__*/ function (_Component6) { _inherits(FullPluvioLegend, _Component6); function FullPluvioLegend() { var _getPrototypeOf7; var _this11; _classCallCheck(this, FullPluvioLegend); for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { args[_key6] = arguments[_key6]; } _this11 = _possibleConstructorReturn(this, (_getPrototypeOf7 = _getPrototypeOf(FullPluvioLegend)).call.apply(_getPrototypeOf7, [this].concat(args))); _defineProperty(_assertThisInitialized(_this11), "state", { dailySum: true }); return _this11; } _createClass(FullPluvioLegend, [{ key: "render", value: function render() { var dailySum = this.state.dailySum; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement("div", { style: { display: "flex", flexWrap: "wrap", justifyContent: "center", marginLeft: "100px" } }, " ", _react["default"].createElement(PluvioLegend1h, { setVal: setVal }), " ", _react["default"].createElement(PluvioLegend3h, { setVal: setVal }), " ", _react["default"].createElement(PluvioLegend6h, { setVal: setVal, isAdmin: false }), _react["default"].createElement(PluvioLegend24hM, { setVal: setVal })); } }]); return FullPluvioLegend; }(_react.Component); exports.FullPluvioLegend = FullPluvioLegend;