UNPKG

react-meteo-chart

Version:

pre alpha of meteo chart

719 lines (582 loc) 21.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PrecipLegendM = exports.PrecipLegend = exports.BarTendencyLegend = exports.PressureLegend = exports.TempLegend = exports.WindSpeedLegend = exports.FlexAmsLegend = exports.AmsLegend = 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 = { widSpeedColor: "#ae0b0b", temperatureColor: "#dce775", barometricTendencyColor: "#1f6025", precipitationColor: "#40bfb7", normalizedPressureColor: "#342d86", pressureColor: "#822d86" }; exports.COLORS = COLORS; var ITEMS = [{ title: "Скорость ветра, м/с", color: "".concat(COLORS.widSpeedColor), strokeWidth: 10 }, { title: "Температура, C°", color: "".concat(COLORS.temperatureColor), strokeWidth: 10 }, { title: "Барическая тенденция, гПа", color: "".concat(COLORS.barometricTendencyColor), strokeWidth: 10 }, { title: "Осадки, мм", color: "".concat(COLORS.precipitationColor), strokeWidth: 10 }, { title: "Приведенное давление, гПа", color: "".concat(COLORS.normalizedPressureColor), strokeWidth: 10 }, { title: "Давление, гПа", color: "".concat(COLORS.pressureColor), strokeWidth: 10 }]; var AmsLegend = /*#__PURE__*/ function (_Component) { _inherits(AmsLegend, _Component); function AmsLegend() { var _getPrototypeOf2; var _this; _classCallCheck(this, AmsLegend); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AmsLegend)).call.apply(_getPrototypeOf2, [this].concat(args))); _defineProperty(_assertThisInitialized(_this), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this; } _createClass(AmsLegend, [{ key: "render", value: function render() { var _this2 = this; var _this$state = this.state, wind = _this$state.wind, temp = _this$state.temp, tendency = _this$state.tendency, precipit = _this$state.precipit, normalPress = _this$state.normalPress, press = _this$state.press; var setVal = this.props.setVal; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", orientation: "horizontal" // width={850} // height={50} , items: ITEMS, onItemClick: function onItemClick(e) { switch (e.title) { case "Скорость ветра, м/с": _this2.setState({ wind: !wind }); setVal(wind, "wind"); break; case "Температура, C°": _this2.setState({ temp: !temp }); setVal(temp, "temp"); break; case "Барическая тенденция, гПа": _this2.setState({ tendency: !tendency }); setVal(tendency, "tendency"); break; case "Осадки, мм": _this2.setState({ precipit: !precipit }); setVal(precipit, "precipit"); break; case "Приведенное давление, гПа": _this2.setState({ normalPress: !normalPress }); setVal(normalPress, "normalPress"); break; case "Давление, гПа": _this2.setState({ press: !press }); setVal(press, "press"); break; default: console.log("Unknown item"); break; } } }); } }]); return AmsLegend; }(_react.Component); exports.AmsLegend = AmsLegend; var FlexAmsLegend = /*#__PURE__*/ function (_Component2) { _inherits(FlexAmsLegend, _Component2); function FlexAmsLegend() { var _getPrototypeOf3; var _this3; _classCallCheck(this, FlexAmsLegend); for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } _this3 = _possibleConstructorReturn(this, (_getPrototypeOf3 = _getPrototypeOf(FlexAmsLegend)).call.apply(_getPrototypeOf3, [this].concat(args))); _defineProperty(_assertThisInitialized(_this3), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this3; } _createClass(FlexAmsLegend, [{ key: "render", value: function render() { var setVal = this.props.setVal; return _react["default"].createElement("div", { style: { display: "flex", flexWrap: "wrap", justifyContent: "center", zIndex: 152, marginLeft: "100px" } }, " ", _react["default"].createElement(WindSpeedLegend, { setVal: setVal, isAdmin: false }), " ", _react["default"].createElement(TempLegend, { setVal: setVal, isAdmin: false }), " ", _react["default"].createElement(PressureLegend, { setVal: setVal, isAdmin: false }), _react["default"].createElement(PrecipLegendM, { setVal: setVal, isAdmin: false })); } }]); return FlexAmsLegend; }(_react.Component); exports.FlexAmsLegend = FlexAmsLegend; var WindSpeedLegend = /*#__PURE__*/ function (_Component3) { _inherits(WindSpeedLegend, _Component3); function WindSpeedLegend() { var _getPrototypeOf4; var _this4; _classCallCheck(this, WindSpeedLegend); for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } _this4 = _possibleConstructorReturn(this, (_getPrototypeOf4 = _getPrototypeOf(WindSpeedLegend)).call.apply(_getPrototypeOf4, [this].concat(args))); _defineProperty(_assertThisInitialized(_this4), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this4; } _createClass(WindSpeedLegend, [{ key: "render", value: function render() { var _this5 = this; var _this$state2 = this.state, wind = _this$state2.wind, temp = _this$state2.temp, tendency = _this$state2.tendency, precipit = _this$state2.precipit, normalPress = _this$state2.normalPress, press = _this$state2.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend" // width={15} // height={25} , style: { fontSize: _GridDates.fontSize }, orientation: isAdmin ? "vertical" : "horizontal", width: isAdmin ? 190 : true, items: [ITEMS[0]], onItemClick: function onItemClick(e) { switch (e.title) { case "Скорость ветра, м/с": _this5.setState({ wind: !wind }); setVal(wind, "wind"); break; default: console.log("Unknown item"); break; } } }); } }]); return WindSpeedLegend; }(_react.Component); exports.WindSpeedLegend = WindSpeedLegend; var TempLegend = /*#__PURE__*/ function (_Component4) { _inherits(TempLegend, _Component4); function TempLegend() { var _getPrototypeOf5; var _this6; _classCallCheck(this, TempLegend); for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } _this6 = _possibleConstructorReturn(this, (_getPrototypeOf5 = _getPrototypeOf(TempLegend)).call.apply(_getPrototypeOf5, [this].concat(args))); _defineProperty(_assertThisInitialized(_this6), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this6; } _createClass(TempLegend, [{ key: "render", value: function render() { var _this7 = this; var _this$state3 = this.state, wind = _this$state3.wind, temp = _this$state3.temp, tendency = _this$state3.tendency, precipit = _this$state3.precipit, normalPress = _this$state3.normalPress, press = _this$state3.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", style: { fontSize: _GridDates.fontSize } // width={150} , items: [ITEMS[1]], orientation: isAdmin ? "vertical" : "horizontal", width: isAdmin ? 190 : true, onItemClick: function onItemClick(e) { switch (e.title) { case "Температура, C°": _this7.setState({ temp: !temp }); setVal(temp, "temp"); break; default: console.log("Unknown item"); break; } } }); } }]); return TempLegend; }(_react.Component); exports.TempLegend = TempLegend; var PressureLegend = /*#__PURE__*/ function (_Component5) { _inherits(PressureLegend, _Component5); function PressureLegend() { var _getPrototypeOf6; var _this8; _classCallCheck(this, PressureLegend); for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } _this8 = _possibleConstructorReturn(this, (_getPrototypeOf6 = _getPrototypeOf(PressureLegend)).call.apply(_getPrototypeOf6, [this].concat(args))); _defineProperty(_assertThisInitialized(_this8), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this8; } _createClass(PressureLegend, [{ key: "render", value: function render() { var _this9 = this; var _this$state4 = this.state, wind = _this$state4.wind, temp = _this$state4.temp, tendency = _this$state4.tendency, precipit = _this$state4.precipit, normalPress = _this$state4.normalPress, press = _this$state4.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", style: { fontSize: _GridDates.fontSize }, orientation: isAdmin ? "vertical" : "horizontal", width: isAdmin ? 190 : true // height={155} // width={150} , items: [ITEMS[4], ITEMS[5]], onItemClick: function onItemClick(e) { switch (e.title) { case "Приведенное давление, гПа": _this9.setState({ normalPress: !normalPress }); setVal(normalPress, "normalPress"); break; case "Давление, гПа": _this9.setState({ press: !press }); setVal(press, "press"); break; default: console.log("Unknown item"); break; } } }); } }]); return PressureLegend; }(_react.Component); exports.PressureLegend = PressureLegend; var BarTendencyLegend = /*#__PURE__*/ function (_Component6) { _inherits(BarTendencyLegend, _Component6); function BarTendencyLegend() { var _getPrototypeOf7; var _this10; _classCallCheck(this, BarTendencyLegend); for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { args[_key6] = arguments[_key6]; } _this10 = _possibleConstructorReturn(this, (_getPrototypeOf7 = _getPrototypeOf(BarTendencyLegend)).call.apply(_getPrototypeOf7, [this].concat(args))); _defineProperty(_assertThisInitialized(_this10), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this10; } _createClass(BarTendencyLegend, [{ key: "render", value: function render() { var _this11 = this; var _this$state5 = this.state, wind = _this$state5.wind, temp = _this$state5.temp, tendency = _this$state5.tendency, precipit = _this$state5.precipit, normalPress = _this$state5.normalPress, press = _this$state5.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", style: { fontSize: _GridDates.fontSize }, width: isAdmin ? 190 : true // width={190} , items: [ITEMS[2]], orientation: isAdmin ? "vertical" : "horizontal", onItemClick: function onItemClick(e) { switch (e.title) { case "Барическая тенденция, гПа": _this11.setState({ tendency: !tendency }); setVal(tendency, "tendency"); break; default: console.log("Unknown item"); break; } } }); } }]); return BarTendencyLegend; }(_react.Component); exports.BarTendencyLegend = BarTendencyLegend; var PrecipLegend = /*#__PURE__*/ function (_Component7) { _inherits(PrecipLegend, _Component7); function PrecipLegend() { var _getPrototypeOf8; var _this12; _classCallCheck(this, PrecipLegend); for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { args[_key7] = arguments[_key7]; } _this12 = _possibleConstructorReturn(this, (_getPrototypeOf8 = _getPrototypeOf(PrecipLegend)).call.apply(_getPrototypeOf8, [this].concat(args))); _defineProperty(_assertThisInitialized(_this12), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this12; } _createClass(PrecipLegend, [{ key: "render", value: function render() { var _this13 = this; var _this$state6 = this.state, wind = _this$state6.wind, temp = _this$state6.temp, tendency = _this$state6.tendency, precipit = _this$state6.precipit, normalPress = _this$state6.normalPress, press = _this$state6.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legendpr" // width={150} , width: isAdmin ? 190 : true, items: [ITEMS[3]], style: { paddingTop: "5px", fontSize: _GridDates.fontSize }, orientation: isAdmin ? "vertical" : "horizontal", onItemClick: function onItemClick(e) { switch (e.title) { case "Осадки, мм": _this13.setState({ precipit: !precipit }); setVal(precipit, "precipit"); break; default: console.log("Unknown item"); break; } } }); } }]); return PrecipLegend; }(_react.Component); exports.PrecipLegend = PrecipLegend; var PrecipLegendM = /*#__PURE__*/ function (_Component8) { _inherits(PrecipLegendM, _Component8); function PrecipLegendM() { var _getPrototypeOf9; var _this14; _classCallCheck(this, PrecipLegendM); for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { args[_key8] = arguments[_key8]; } _this14 = _possibleConstructorReturn(this, (_getPrototypeOf9 = _getPrototypeOf(PrecipLegendM)).call.apply(_getPrototypeOf9, [this].concat(args))); _defineProperty(_assertThisInitialized(_this14), "state", { wind: true, temp: true, tendency: true, precipit: true, normalPress: true, press: true }); return _this14; } _createClass(PrecipLegendM, [{ key: "render", value: function render() { var _this15 = this; var _this$state7 = this.state, wind = _this$state7.wind, temp = _this$state7.temp, tendency = _this$state7.tendency, precipit = _this$state7.precipit, normalPress = _this$state7.normalPress, press = _this$state7.press; var setVal = this.props.setVal; var isAdmin = this.props.isAdmin; return _react["default"].createElement(_reactVis.DiscreteColorLegend, { className: "legend", style: { fontSize: _GridDates.fontSize } // height={35} // width={150} , items: [ITEMS[3]], width: isAdmin ? 190 : true, orientation: isAdmin ? "vertical" : "horizontal", onItemClick: function onItemClick(e) { switch (e.title) { case "Осадки, мм": _this15.setState({ precipit: !precipit }); setVal(precipit, "precipit"); break; default: console.log("Unknown item"); break; } } }); } }]); return PrecipLegendM; }(_react.Component); exports.PrecipLegendM = PrecipLegendM;