@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
123 lines (122 loc) • 7.72 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 { Collapse } from 'antd';
import { observer } from 'mobx-react';
import { computed } from 'mobx';
import { get } from 'lodash';
import { ColorPicker } from '@qn-pandora/pandora-app-component';
import BasicComponent from '../../../components/Base/BasicComponent';
import { Form } from '../../Common';
import { RelationBucketItem, MetricItem, UnitItem, NumberItem, SolidRadioItem } from '../../../components/Base';
import errorBoundary from '../../../hocs/errorBoundary';
import { formatString } from '../../../services/language';
import { BaseLocale } from '../../../constants/language/base/type';
import { UnitLocale } from '../../../constants/language/unit/type';
import { RelationLocale } from '../../../constants/language/relation/type';
import { MapLocale } from '../../../constants/language/map/type';
import GradientColorPanel from '../../../components/Base/GradientColorPanel';
import { ChartType } from '../../../constants';
import { geoLevelOptions } from '../Map/constants';
import StyleElement from './StyleElement';
var Panel = Collapse.Panel;
var Item = Form.Item;
var MigrationStyleConfigForm = /** @class */ (function (_super) {
__extends(MigrationStyleConfigForm, _super);
function MigrationStyleConfigForm() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MigrationStyleConfigForm.prototype, "defaultColors", {
get: function () {
var themeOption = this.props.themeService.themeOption;
return get(themeOption, ['effectScatter', 'color']) || themeOption.color;
},
enumerable: false,
configurable: true
});
Object.defineProperty(MigrationStyleConfigForm.prototype, "fieldsSelectOptions", {
get: function () {
var dataset = this.props.dataset;
return dataset.fields.map(function (e) { return ({
text: e.name,
value: e.key
}); });
},
enumerable: false,
configurable: true
});
Object.defineProperty(MigrationStyleConfigForm.prototype, "gradientColors", {
get: function () {
var _a = this.props, themeOption = _a.themeService.themeOption, chartStyleService = _a.chartStyleService;
var gradientColor = chartStyleService.gradientColor;
return gradientColor.length > 0
? gradientColor
: get(themeOption, ['effectScatter', 'selectColors']);
},
enumerable: false,
configurable: true
});
MigrationStyleConfigForm.prototype.render = function () {
var chartStyleService = this.props.chartStyleService;
var _a = chartStyleService, currentBuckets = _a.currentBuckets, setCurrentBuckets = _a.setCurrentBuckets, currentMetrics = _a.currentMetrics, setCurrentMetrics = _a.setCurrentMetrics, unit = _a.unit, setUnit = _a.setUnit, inflowColor = _a.inflowColor, setInflowColor = _a.setInflowColor, outflowColor = _a.outflowColor, setOutflowColor = _a.setOutflowColor, setGradientColor = _a.setGradientColor, setColorType = _a.setColorType, colorType = _a.colorType, precision = _a.precision, setPrecision = _a.setPrecision, geoLevel = _a.geoLevel, setGeoLevel = _a.setGeoLevel, chartType = _a.chartType;
return (React.createElement(Form, null,
React.createElement(Collapse, { defaultActiveKey: ['1'], bordered: false, accordion: true },
React.createElement(Panel, { key: "1", header: formatString(BaseLocale.title_data) },
chartType === ChartType.MigrationChina && (React.createElement(SolidRadioItem, { label: MapLocale.geo_level.title, options: geoLevelOptions, value: geoLevel, onChange: setGeoLevel })),
React.createElement(RelationBucketItem, { value: currentBuckets, onChange: setCurrentBuckets, options: this.fieldsSelectOptions, getPopupContainer: this.getRootDOM }),
React.createElement(MetricItem, { label: BaseLocale.metric, metricOptions: this.fieldsSelectOptions, metrics: currentMetrics, getPopupContainer: this.getRootDOM, onChange: setCurrentMetrics, allowClear: true }),
React.createElement(UnitItem, { label: UnitLocale.title, value: unit, onChange: setUnit }),
React.createElement(NumberItem, { label: BaseLocale.precision, value: precision, onChange: setPrecision })),
React.createElement(Panel, { header: formatString(BaseLocale.chart_style), key: "2" },
React.createElement(StyleElement, { chartStyleService: chartStyleService })),
React.createElement(Panel, { key: "3", header: formatString(BaseLocale.color) },
React.createElement(Item, { label: RelationLocale.start },
React.createElement(ColorPicker, { value: outflowColor || this.defaultColors[1], onChange: setOutflowColor })),
React.createElement(Item, { label: RelationLocale.end },
React.createElement(ColorPicker, { value: inflowColor || this.defaultColors[0], onChange: setInflowColor })),
React.createElement(Item, { label: RelationLocale.map_color },
React.createElement("div", { style: { marginLeft: '20px' } },
React.createElement(GradientColorPanel, { colors: this.gradientColors, setColors: setGradientColor, colorType: colorType, setColorType: setColorType, getPopupContainer: this.getRootDOM })))))));
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MigrationStyleConfigForm.prototype, "defaultColors", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MigrationStyleConfigForm.prototype, "fieldsSelectOptions", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MigrationStyleConfigForm.prototype, "gradientColors", null);
MigrationStyleConfigForm = __decorate([
observer
], MigrationStyleConfigForm);
return MigrationStyleConfigForm;
}(BasicComponent));
export { MigrationStyleConfigForm };
export default errorBoundary(MigrationStyleConfigForm);