1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/didiopensource-KnowStreaming

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
index.tsx 3.5 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
zengqiao Отправлено 4 лет назад c6e4b60
import { EChartOption } from 'echarts';
import { observer } from 'mobx-react';
import React from 'react';
import { curveInfo } from 'store/curve-info';
import { fullScreen } from 'store/full-screen';
import { getHight, EXPAND_GRID_HEIGHT, ICurve } from './config';
import './index.less';
import { Spin, Icon } from 'component/antd';
import LineChart, { hasData } from 'component/chart/line-chart';
export interface ICommonCurveProps {
options: ICurve;
parser?: (option: ICurve, data: any[]) => EChartOption;
}
@observer
export class CommonCurve extends React.Component<ICommonCurveProps> {
public componentDidMount() {
this.refresh(false);
}
public componentWillUnmount() {
const { path } = this.props.options;
curveInfo.setCurveData(path, null);
}
public refresh = (refresh?: boolean) => {
curveInfo.getCommonCurveData(this.props.options, this.props.parser, refresh);
}
public expand = () => {
const curveOption = this.getCurveData();
const options = Object.assign({}, curveOption, {
grid: {
...curveOption.grid,
height: EXPAND_GRID_HEIGHT,
},
});
const loading = this.getLoading();
fullScreen.show(this.renderCurve(options, loading, true));
}
public renderOpBtns = (options: EChartOption, expand = false) => {
const data = hasData(options);
return (
<div className="charts-op" key="op">
{!expand ? <Icon type="reload" onClick={() => this.refresh(true)} key="refresh" /> : null}
{data ? this.renderExpand(expand) : null}
</div>
);
}
public renderExpand = (expand = false) => {
if (expand) return <Icon type="close" onClick={fullScreen.close} key="close" />;
return <Icon type="fullscreen" className="ml-17" onClick={this.expand} key="full-screen" />;
}
public renderTitle = () => {
const { title } = this.props.options;
return (
<div className="charts-title" key="title">{title}</div>
);
}
public getCurveData = () => {
const { path } = this.props.options;
return curveInfo.curveData[path];
}
public getLoading = () => {
const { path } = this.props.options;
return curveInfo.curveLoading[path] || false;
}
public renderOthers = () => null as JSX.Element;
public renderNoData = (height?: number) => {
const style = { height: `${height}px`, lineHeight: `${height}px` };
return <div className="no-data-info" style={{ ...style }} key="noData">暂无数据</div>;
}
public renderLoading = (height?: number) => {
const style = { height: `${height}px`, lineHeight: `${height}px` };
return <div className="no-data-info" style={{ ...style }} key="loading"><Spin /></div>;
}
public renderEchart = (options: EChartOption, loading = false) => {
const height = getHight(options);
const data = hasData(options);
if (loading) return this.renderLoading(height);
if (!data) return this.renderNoData(height);
return <LineChart height={height} options={options} key="chart" />;
}
public renderCurve = (options: EChartOption, loading: boolean, expand = false) => {
const data = hasData(options);
return (
<div className="common-chart-wrapper" >
{this.renderTitle()}
{this.renderEchart(options, loading)}
{this.renderOpBtns(options, expand)}
{data ? this.renderOthers() : null}
</div>
);
}
public render() {
const options = this.getCurveData();
const loading = this.getLoading();
return (
<>
{this.renderCurve(options, loading)}
</>
);
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/didiopensource-KnowStreaming.git
git@gitlife.ru:oschina-mirror/didiopensource-KnowStreaming.git
oschina-mirror
didiopensource-KnowStreaming
didiopensource-KnowStreaming
v2.4.2