UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

112 lines (111 loc) 6.97 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 { InputNumber } from '@qn-pandora/pandora-component'; import { TowDimensionLocale } from '../../../constants/language/two_dimension/type'; import { BaseLocale } from '../../../constants/language/base/type'; import { ChartTypeLocale } from '../../../constants/language/chart_type/type'; import { showBarLabelOptions, stackOptions } from '../../../constants/bar-style'; import { formatString } from '../../../services/language'; import bind from '../../../utils/bind'; import errorBoundary from '../../../hocs/errorBoundary'; import { lineOptions, valueLabelOptions, pointOptions } from '../../../constants/line-style'; import { enableOptions } from '../../ChartStyleConfig/constants'; import { EPoint } from '../../../constants'; import { SolidRadioItem } from '../../Base'; import { Form, Selector } from '../../Common'; import * as styles from './style.mless'; var CombinationStylePanel = /** @class */ (function (_super) { __extends(CombinationStylePanel, _super); function CombinationStylePanel() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(CombinationStylePanel.prototype, "pointType", { get: function () { var _a = this.props, point = _a.chartStyleService.crossAxis1.lineDataConfig.point, line = _a.themeOption.line; return point.type || get(line, 'symbol'); }, enumerable: false, configurable: true }); CombinationStylePanel.prototype.handlePointChange = function (value, key) { var _a; var _b = this.props.chartStyleService.crossAxis1, point = _b.lineDataConfig.point, setLinePoint = _b.setLinePoint; setLinePoint(__assign(__assign({}, point), (_a = {}, _a[key] = value, _a))); }; CombinationStylePanel.prototype.render = function () { var _this = this; var _a = this.props, themeOption = _a.themeOption, chartStyleService = _a.chartStyleService; var showBarLabel = chartStyleService.showBarLabel, setShowBarLabel = chartStyleService.setShowBarLabel, _b = chartStyleService.crossAxis1, _c = _b.lineDataConfig, point = _c.point, smoothLine = _c.smoothLine, _d = _c.markPointType, markPointType = _d === void 0 ? 'hide' : _d, setLineSmooth = _b.setLineSmooth, setLineMarkPoint = _b.setLineMarkPoint, showToolBox = chartStyleService.showToolBox, setShowToolBox = chartStyleService.setShowToolBox, stack = chartStyleService.stack, setStack = chartStyleService.setStack; var line = themeOption.line; return (React.createElement(React.Fragment, null, React.createElement("div", { className: styles.title }, formatString(ChartTypeLocale.bar)), React.createElement(SolidRadioItem, { label: TowDimensionLocale.bar.valueLabelShow.title, options: showBarLabelOptions, value: showBarLabel, onChange: setShowBarLabel }), React.createElement(SolidRadioItem, { label: BaseLocale.stack, options: stackOptions, value: stack, onChange: setStack }), React.createElement("div", { className: styles.title }, formatString(ChartTypeLocale.line)), React.createElement(SolidRadioItem, { label: TowDimensionLocale.line.line_style.title, options: lineOptions, value: smoothLine, onChange: setLineSmooth }), React.createElement(Form.Item, { label: formatString(BaseLocale.point.title) }, React.createElement(Form.RowContainer, { sizes: [12, 12], gutter: 8 }, React.createElement(Selector, { value: this.pointType, onChange: function (value) { _this.handlePointChange(value, 'type'); }, options: pointOptions }), React.createElement(InputNumber, { min: point.type === EPoint.None ? 0 : 1, value: point.size === 0 || point.size ? point.size : get(line, 'symbolSize'), onChange: function (value) { _this.handlePointChange(value, 'size'); }, addonAfter: 'px' }))), this.pointType !== EPoint.None && (React.createElement(SolidRadioItem, { label: TowDimensionLocale.line.valueLabelShow.title, options: valueLabelOptions, value: markPointType, onChange: setLineMarkPoint })), React.createElement(SolidRadioItem, { label: TowDimensionLocale.data_zoom.zoom, options: enableOptions, value: showToolBox, onChange: setShowToolBox }))); }; __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], CombinationStylePanel.prototype, "pointType", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object, String]), __metadata("design:returntype", void 0) ], CombinationStylePanel.prototype, "handlePointChange", null); CombinationStylePanel = __decorate([ observer ], CombinationStylePanel); return CombinationStylePanel; }(React.Component)); export { CombinationStylePanel }; export default errorBoundary(CombinationStylePanel);