UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

135 lines (134 loc) 7.04 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 { computed } from 'mobx'; import { observer } from 'mobx-react'; import { get } from 'lodash'; import bind from '../../../utils/bind'; import Item from '../../../components/Common/Form/Item'; import { Selector } from '../../../components/Common'; import { xLabelRotations, xLabelShowModes, xValueLabelShowModes } from '../../ChartStyleConfig/constants'; import SolidRadioItem from '../SolidRadioItem'; import NameItem from '../NameItem'; import BasicComponent from '../BasicComponent'; import errorBoundary from '../../../hocs/errorBoundary'; import { BaseLocale } from '../../../constants/language/base/type'; import { ChartType } from '../../../constants/chart-style'; import { formatString } from '../../../services'; import { getAxisType } from '../YScantterPanelContent/transform'; import AxisTypePanel from '../AxisTypePanel'; var formItemLayout = { labelCol: { span: 7 }, wrapperCol: { span: 17 } }; var XPanelContent = /** @class */ (function (_super) { __extends(XPanelContent, _super); function XPanelContent() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(XPanelContent.prototype, "chartStyleService", { get: function () { return this.props.chartStyleService; }, enumerable: false, configurable: true }); Object.defineProperty(XPanelContent.prototype, "labelModes", { get: function () { var type = this.chartStyleService.mainAxis.type; return type === "category" /* Category */ ? xLabelShowModes : xValueLabelShowModes; }, enumerable: false, configurable: true }); XPanelContent.prototype.handleXNameChange = function (e) { var setName = this.chartStyleService.mainAxis.setName; if (setName) { setName(e.target.value); } }; XPanelContent.prototype.handleOnChange = function (value) { var dataset = this.props.dataset; var chartType = this.chartStyleService.chartType; var _a = this.chartStyleService.mainAxis, setField = _a.setField, setAxisType = _a.setAxisType; setField(value); if (chartType === ChartType.Bubble || chartType === ChartType.Scatter) { var field = dataset.fields.find(function (f) { return f.key === value; }); var fieldType = get(field, 'fieldType'); setAxisType(getAxisType(fieldType)); } }; XPanelContent.prototype.render = function () { var dataset = this.props.dataset; var _a = this.chartStyleService.mainAxis, labelRotation = _a.labelRotation, labelShowMode = _a.labelShowMode, name = _a.name, nameMode = _a.nameMode, field = _a.field, setLabelRotation = _a.setLabelRotation, setLabelShowMode = _a.setLabelShowMode, setNameMode = _a.setNameMode; return (React.createElement("div", { ref: this.setRootRef }, React.createElement(Item, __assign({ label: BaseLocale.field }, formItemLayout), React.createElement(Selector, { showSearch: true, allowClear: true, value: field, options: dataset.fields.map(function (f) { return f.key; }), onChange: this.handleOnChange })), React.createElement(NameItem, __assign({ label: BaseLocale.name, name: name, nameMode: nameMode, setNameMode: setNameMode, handleNameChange: this.handleXNameChange }, formItemLayout)), React.createElement(AxisTypePanel, __assign({ axis: this.chartStyleService.mainAxis }, formItemLayout)), React.createElement(SolidRadioItem, __assign({ label: BaseLocale.x.label_show, value: labelShowMode, options: this.labelModes, explain: React.createElement("span", null, React.createElement("div", null, formatString(BaseLocale.x.show_explain1)), React.createElement("div", null, formatString(BaseLocale.x.show_explain2)), React.createElement("div", null, formatString(BaseLocale.x.show_explain3))), onChange: setLabelShowMode, getPopupContainer: this.getRootDOM }, formItemLayout)), React.createElement(SolidRadioItem, __assign({ label: BaseLocale.x.label_rotation, options: xLabelRotations, value: labelRotation, onChange: setLabelRotation }, formItemLayout)))); }; __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], XPanelContent.prototype, "chartStyleService", null); __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], XPanelContent.prototype, "labelModes", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], XPanelContent.prototype, "handleXNameChange", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], XPanelContent.prototype, "handleOnChange", null); XPanelContent = __decorate([ observer ], XPanelContent); return XPanelContent; }(BasicComponent)); export { XPanelContent }; export default errorBoundary(XPanelContent);