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