UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

91 lines (90 loc) 5.42 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 __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 { get } from 'lodash'; import { Collapse } from 'antd'; import { observer } from 'mobx-react'; import BasicComponent from '../../Base/BasicComponent'; import { Form } from '../../Common'; import { formatString } from '../../../services/language'; import { BaseLocale } from '../../../constants/language/base/type'; import { OtherLocale } from '../../../constants/language/other/type'; import LevelConfiger from './LevelConfiger'; import RuleConfiger from './RuleConfiger'; import StyleElement from './StyleElement'; import DataElement from '../Metrics/component/DataElement'; import { computed } from 'mobx'; var Panel = Collapse.Panel; var Item = Form.Item; var StatusPanelChartConfigForm = /** @class */ (function (_super) { __extends(StatusPanelChartConfigForm, _super); function StatusPanelChartConfigForm() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(StatusPanelChartConfigForm.prototype, "levels", { get: function () { var _a = this.props, chartStyleService = _a.chartStyleService, themeOption = _a.themeService.themeOption; var levels = chartStyleService.levels; var statusPanel = get(themeOption, 'statusPanel'); var color = get(statusPanel, 'color'); var defaultColor = color && color.length ? color : themeOption.color; levels.forEach(function (t, i) { if (!t.color) { t.color = defaultColor[i]; } }); return levels.filter(function (level) { return !!level.name; }); }, enumerable: false, configurable: true }); StatusPanelChartConfigForm.prototype.render = function () { var _a = this.props, chartStyleService = _a.chartStyleService, dataset = _a.dataset, themeOption = _a.themeService.themeOption; var statusPanel = get(themeOption, 'statusPanel'); if (!chartStyleService.width && !chartStyleService.height) { chartStyleService.setOptInit(get(statusPanel, ['itemStyle', 'width']), get(statusPanel, ['itemStyle', 'height']), get(statusPanel, ['title', 'fontSize']), get(statusPanel, ['itemStyle', 'fontSize']), get(statusPanel, ['itemStyle', 'fontColor'])); } return (React.createElement(Form, { styleService: chartStyleService }, React.createElement(Collapse, { defaultActiveKey: ['1'], bordered: false, accordion: true }, React.createElement(Panel, { header: formatString(BaseLocale.title_data), key: "1" }, React.createElement(DataElement, { getPopupContainer: this.getRootDOM, chartStyleService: chartStyleService, dataset: dataset })), React.createElement(Panel, { header: formatString(OtherLocale.status.status), key: "2" }, React.createElement(Item, { label: OtherLocale.status.setting, explain: OtherLocale.status.explain, field: "levels" }, React.createElement(LevelConfiger, { getPopupContainer: this.getRootDOM }))), React.createElement(Panel, { header: formatString(OtherLocale.status.rule_status), key: "3" }, React.createElement(Item, { field: "rules", wrapperCol: { span: 24 } }, React.createElement(RuleConfiger, { levels: this.levels, fields: dataset.fields, getPopupContainer: this.getRootDOM }))), React.createElement(Panel, { header: formatString(BaseLocale.chart_style), key: "4" }, React.createElement(StyleElement, { chartStyleService: chartStyleService, themeOption: themeOption }))))); }; __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], StatusPanelChartConfigForm.prototype, "levels", null); StatusPanelChartConfigForm = __decorate([ observer ], StatusPanelChartConfigForm); return StatusPanelChartConfigForm; }(BasicComponent)); export default StatusPanelChartConfigForm;