@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
142 lines (141 loc) • 8.79 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 __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 { Collapse } from 'antd';
import { observer } from 'mobx-react';
import { computed } from 'mobx';
import { get } from 'lodash';
import { LegendColorPanel, BaseLineItem } from '@qn-pandora/pandora-app-component';
import { TowDimensionLocale } from '../../../constants/language/two_dimension/type';
import { BaseLocale } from '../../../constants/language/base/type';
import { formatString } from '../../../services/language';
import bind from '../../../utils/bind';
import errorBoundary from '../../../hocs/errorBoundary';
import { ChartType } from '../../../constants/chart-style';
import { IAxisTypePanelProperty } from '../../../components/Base/AxisTypePanel';
import { LegendPanel, XPanelContent, YPanelContent, ColorPanel,
// BaseLineItem,
MetricItem } from '../../Base';
import { Form } from '../../Common';
import { getColors } from '../transform';
import StyleElement from './StyleElement';
var Panel = Collapse.Panel;
var Desc = LegendColorPanel.Desc;
var LineChartConfigForm = /** @class */ (function (_super) {
__extends(LineChartConfigForm, _super);
function LineChartConfigForm() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(LineChartConfigForm.prototype, "colors", {
get: function () {
var _a = this.props, mergeDataset = _a.mergeDataset, chartStyleService = _a.chartStyleService, themeService = _a.themeService;
return getColors(themeService.themeOption, mergeDataset, chartStyleService);
},
enumerable: false,
configurable: true
});
Object.defineProperty(LineChartConfigForm.prototype, "isPercentageChart", {
get: function () {
var chartType = this.props.chartStyleService.chartType;
return (chartType === ChartType.PercentageLine ||
chartType === ChartType.PercentageArea);
},
enumerable: false,
configurable: true
});
Object.defineProperty(LineChartConfigForm.prototype, "yShowProperty", {
get: function () {
var showProperty = {};
if (this.isPercentageChart) {
showProperty[IAxisTypePanelProperty.Unit] = false;
}
return showProperty;
},
enumerable: false,
configurable: true
});
LineChartConfigForm.prototype.handlePointChange = function (value, key) {
var _a;
var _b = this.props.chartStyleService, point = _b.point, setPoint = _b.setPoint;
setPoint(__assign(__assign({}, point), (_a = {}, _a[key] = value, _a)));
};
LineChartConfigForm.prototype.render = function () {
var _a = this.props, chartStyleService = _a.chartStyleService, dataset = _a.dataset, themeOption = _a.themeService.themeOption;
var line = themeOption.line;
var _b = chartStyleService.colors, fields = _b.fields, setFields = _b.setFields, _c = chartStyleService.legend, position = _c.position, legendDisplayMode = _c.legendDisplayMode, setLegendDisplayMode = _c.setLegendDisplayMode, setPosition = _c.setPosition, hideChartLegend = _c.hideChartLegend, setHideChartLegend = _c.setHideChartLegend, hideBaseLineLegend = _c.hideBaseLineLegend, setHideBaseLineLegend = _c.setHideBaseLineLegend, sort = _c.sort, setSort = _c.setSort, width = _c.width, setWidth = _c.setWidth, setDisplayColors = chartStyleService.setDisplayColors, colorMode = chartStyleService.colorMode, setColorMode = chartStyleService.setColorMode, chartType = chartStyleService.chartType, baseLine = chartStyleService.baseLine, setBaseLine = chartStyleService.setBaseLine;
return (React.createElement(Form, { styleService: chartStyleService },
React.createElement(Collapse, { defaultActiveKey: ['1'], bordered: false, accordion: true },
React.createElement(Panel, { header: formatString(BaseLocale.title_x), key: "1" },
React.createElement(XPanelContent, { chartStyleService: chartStyleService, dataset: dataset })),
React.createElement(Panel, { header: formatString(BaseLocale.title_y), key: "2" },
React.createElement(YPanelContent, { dataset: dataset, crossAxis: chartStyleService.crossAxis1, chartType: chartStyleService.chartType, showLineYEmptyValueMode: true, showProperty: this.yShowProperty })),
React.createElement(Panel, { header: React.createElement(Desc, { title: formatString(TowDimensionLocale.desc_line) }), key: "3" },
React.createElement(MetricItem, { label: BaseLocale.field, explain: "", onChange: setFields, metricOptions: dataset.fields.map(function (f) { return f.key; }), metrics: fields, isMultipleMode: true })),
React.createElement(Panel, { header: formatString(BaseLocale.base_line), key: "4" },
React.createElement(BaseLineItem, { defaultColor: get(line, 'thresholdColor')[0], chartType: chartType, dataset: dataset, value: baseLine, onChange: setBaseLine })),
React.createElement(Panel, { header: formatString(BaseLocale.title_legend), key: "5" },
React.createElement(LegendPanel, { position: position, setPosition: setPosition, legendDisplayMode: legendDisplayMode, setLegendDisplayMode: setLegendDisplayMode, hideChartLegend: hideChartLegend, setHideChartLegend: setHideChartLegend, hideBaseLineLegend: hideBaseLineLegend, setHideBaseLineLegend: setHideBaseLineLegend, sort: sort, setSort: setSort, width: width, setWidth: setWidth })),
React.createElement(Panel, { header: formatString(BaseLocale.chart_style), key: "style" },
React.createElement(StyleElement, { themeOption: themeOption, chartStyleService: chartStyleService })),
React.createElement(Panel, { header: formatString(BaseLocale.color), key: "6" },
React.createElement(ColorPanel, { colors: this.colors, setColors: setDisplayColors, colorMode: colorMode, setColorMode: setColorMode })))));
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LineChartConfigForm.prototype, "colors", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LineChartConfigForm.prototype, "isPercentageChart", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LineChartConfigForm.prototype, "yShowProperty", null);
__decorate([
bind,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], LineChartConfigForm.prototype, "handlePointChange", null);
LineChartConfigForm = __decorate([
observer
], LineChartConfigForm);
return LineChartConfigForm;
}(React.Component));
export { LineChartConfigForm };
export default errorBoundary(LineChartConfigForm);