@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
80 lines (79 loc) • 4.45 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;
};
import * as React from 'react';
import classnames from 'classnames';
import { chunk } from 'lodash';
import { observer } from 'mobx-react';
import { Carousel } from 'antd';
import storeWrapper from '../components/StoreWrapper';
import errorBoundary from '../../../hocs/errorBoundary';
import StatusPanelStore from './store';
import * as styles from './style.mless';
var StatusPanelChart = /** @class */ (function (_super) {
__extends(StatusPanelChart, _super);
function StatusPanelChart() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.store = _this.props.store;
return _this;
}
StatusPanelChart.prototype.render = function () {
var _this = this;
var _a = this.store, series = _a.series, titleStyle = _a.titleStyle, chunkSize = _a.chunkSize, autoplay = _a.autoplay, carouselSpeed = _a.carouselSpeed, showLabel = _a.showLabel, chartCanClick = _a.chartCanClick;
var panels = series.map(function (item) {
var key = item.key, titles = item.titles, contents = item.contents, originRow = item.originRow, panelStyle = item.panelStyle;
var titleNodes = titles.map(function (title, index) {
return (React.createElement("div", { key: "title-" + index, style: titleStyle, className: "single-line", title: title }, title));
});
var contentNodes = contents.map(function (content, index) {
var text = showLabel
? content.label + ":" + content.value
: "" + content.value;
return (React.createElement("div", { key: "content-" + index, style: content.contentStyle, className: "single-line", title: text }, text));
});
return (React.createElement("div", { key: key, className: classnames(styles.item), style: __assign(__assign({}, panelStyle), { cursor: chartCanClick ? 'pointer' : 'default' }), onClick: function () {
return _this.store.handleDrillDown({ titles: titles, contents: contents, originRow: originRow });
} },
React.createElement("div", { className: styles.content },
titleNodes,
React.createElement("div", { className: styles.separator }),
contentNodes)));
});
return (React.createElement("div", { className: styles.root },
React.createElement(Carousel, { autoplay: autoplay, autoplaySpeed: carouselSpeed }, chunk(panels, chunkSize).map(function (panels, index) {
return (React.createElement("div", { key: index, className: styles.page }, panels));
}))));
};
StatusPanelChart = __decorate([
observer
], StatusPanelChart);
return StatusPanelChart;
}(React.Component));
export default errorBoundary(storeWrapper(StatusPanelChart, StatusPanelStore));