@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
90 lines (89 loc) • 5.31 kB
JavaScript
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 { includes, get } from 'lodash';
import { Collapse } from 'antd';
import { computed } from 'mobx';
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 errorBoundary from '../../../hocs/errorBoundary';
import bind from '../../../utils/bind';
import DataElement from '../Metrics/component/DataElement';
import ColorElement from './ColorElement';
import StyleElement from './StyleElement';
var Panel = Collapse.Panel;
var MetricPanelChartConfigForm = /** @class */ (function (_super) {
__extends(MetricPanelChartConfigForm, _super);
function MetricPanelChartConfigForm() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MetricPanelChartConfigForm.prototype, "currentMetricFields", {
get: function () {
var _a = this.props, dataset = _a.dataset, chartStyleService = _a.chartStyleService;
var currentMetrics = chartStyleService.currentMetrics;
return dataset.fields.filter(function (field) { return includes(currentMetrics, field.key); });
},
enumerable: false,
configurable: true
});
MetricPanelChartConfigForm.prototype.defaultSet = function () {
var _a = this.props, chartStyleService = _a.chartStyleService, 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', 'fontColor']));
}
};
MetricPanelChartConfigForm.prototype.render = function () {
var _a = this.props, chartStyleService = _a.chartStyleService, dataset = _a.dataset, themeOption = _a.themeService.themeOption;
var colors = chartStyleService.colors, setColors = chartStyleService.setColors;
this.defaultSet();
return (React.createElement(Form, { styleService: chartStyleService, ref: this.setRootRef },
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(BaseLocale.color), key: "2" },
React.createElement(ColorElement, { fields: this.currentMetricFields, value: colors, onChange: setColors, getPopupContainer: this.getRootDOM, themeOption: themeOption })),
React.createElement(Panel, { header: formatString(BaseLocale.chart_style), key: "3" },
React.createElement(StyleElement, { chartStyleService: chartStyleService, themeOption: themeOption, dataset: dataset, getPopupContainer: this.getRootDOM })))));
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MetricPanelChartConfigForm.prototype, "currentMetricFields", null);
__decorate([
bind,
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], MetricPanelChartConfigForm.prototype, "defaultSet", null);
MetricPanelChartConfigForm = __decorate([
observer
], MetricPanelChartConfigForm);
return MetricPanelChartConfigForm;
}(BasicComponent));
export { MetricPanelChartConfigForm };
export default errorBoundary(MetricPanelChartConfigForm);