添加自定义 dataFilter
This commit is contained in:
parent
363814e0b4
commit
d212362e6e
|
@ -14,6 +14,7 @@ import {ScopedContext, IScopedContext} from '../Scoped';
|
|||
export interface ChartProps extends RendererProps {
|
||||
chartRef?: (echart: any) => void;
|
||||
onDataFilter?: (config: any) => any;
|
||||
dataFilter?: string;
|
||||
api?: Api;
|
||||
source?: string;
|
||||
config?: object;
|
||||
|
@ -193,13 +194,22 @@ export class Chart extends React.Component<ChartProps> {
|
|||
if (!this.echarts) {
|
||||
return;
|
||||
}
|
||||
const onDataFilter = this.props.onDataFilter;
|
||||
let onDataFilter = this.props.onDataFilter;
|
||||
const dataFilter = this.props.dataFilter;
|
||||
|
||||
if (!onDataFilter && typeof dataFilter === 'string') {
|
||||
onDataFilter = new Function('config', 'echarts', dataFilter) as any;
|
||||
}
|
||||
|
||||
config = config || this.pending;
|
||||
if (typeof config === 'string') {
|
||||
config = new Function('return ' + config)();
|
||||
}
|
||||
try {
|
||||
onDataFilter && (config = onDataFilter(config) || config);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
|
||||
if (config) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue