UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

103 lines (102 loc) 5.95 kB
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 (Object.prototype.hasOwnProperty.call(b, 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); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import React from 'react'; import { observer } from 'mobx-react'; import { computed } from 'mobx'; import errorBoundary from '../../../../hocs/errorBoundary'; import BasicComponent from '../../../Base/BasicComponent'; import { SolidRadioItem, SingleTextSettings, NumberItem } from '../../../Base'; import { SingleLocale } from '../../../../constants/language/single/type'; import { BaseLocale } from '../../../../constants/language/base/type'; import bind from '../../../../utils/bind'; import { colorModeOptions, trendModeOptions } from '../constants'; import SingleEmptyValue from './SingleEmptyValue'; var SingleValueStyleElement = /** @class */ (function (_super) { __extends(SingleValueStyleElement, _super); function SingleValueStyleElement() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(SingleValueStyleElement.prototype, "prefixAndSuffix", { get: function () { var _a = this.props, _b = _a.chartStyleService, prefix = _b.prefix, suffix = _b.suffix, _c = _a.themeOption.gauge.singleValue, prefixStyle = _c.prefixStyle, suffixStyle = _c.suffixStyle; return { prefix: { value: prefix.value, font: __assign({}, prefix.font), defaultColor: prefixStyle.color, defaultFontSize: prefixStyle.fontSize }, suffix: { value: suffix.value, font: __assign({}, suffix.font), defaultColor: suffixStyle.color, defaultFontSize: suffixStyle.fontSize } }; }, enumerable: false, configurable: true }); SingleValueStyleElement.prototype.handleFontSizeChange = function (fontSize) { var _a = this.props.chartStyleService, titleDataFont = _a.titleDataFont, setTitleDataFont = _a.setTitleDataFont; setTitleDataFont(__assign(__assign({}, titleDataFont), { fontSize: fontSize })); }; SingleValueStyleElement.prototype.render = function () { var _a = this.props, chartStyleService = _a.chartStyleService, getPopupContainer = _a.getPopupContainer; var setPrefix = chartStyleService.setPrefix, setSuffix = chartStyleService.setSuffix, colorMode = chartStyleService.colorMode, setColorMode = chartStyleService.setColorMode, trendMode = chartStyleService.trendMode, setTrendMode = chartStyleService.setTrendMode, titleDataFont = chartStyleService.titleDataFont, gaugeEmptyValueMode = chartStyleService.gaugeEmptyValueMode, setGaugeEmptyValueMode = chartStyleService.setGaugeEmptyValueMode; return (React.createElement(React.Fragment, null, React.createElement(SolidRadioItem, { label: SingleLocale.value.color.title, value: colorMode, onChange: setColorMode, options: colorModeOptions }), React.createElement(SolidRadioItem, { label: SingleLocale.value.trend.title, value: trendMode, onChange: setTrendMode, options: trendModeOptions }), React.createElement(NumberItem, { label: BaseLocale.title.number, value: titleDataFont.fontSize || 40, onChange: this.handleFontSizeChange, min: 0, max: 100 }), React.createElement(SingleTextSettings, __assign({}, this.prefixAndSuffix, { getPopupContainer: getPopupContainer, setPrefix: setPrefix, setSuffix: setSuffix })), React.createElement(SingleEmptyValue, { value: gaugeEmptyValueMode, onChange: setGaugeEmptyValueMode }))); }; __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], SingleValueStyleElement.prototype, "prefixAndSuffix", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], SingleValueStyleElement.prototype, "handleFontSizeChange", null); SingleValueStyleElement = __decorate([ observer ], SingleValueStyleElement); return SingleValueStyleElement; }(BasicComponent)); export { SingleValueStyleElement }; export default errorBoundary(SingleValueStyleElement);