MCPcopy
hub / github.com/baidu/amis / renderChart

Method renderChart

packages/amis/src/renderers/Chart.tsx:559–618  ·  view source on GitHub ↗
(config?: object, data?: any)

Source from the content-addressed store, hash-verified

557 }
558
559 renderChart(config?: object, data?: any) {
560 config && (this.pending = config);
561 data && (this.pendingCtx = data);
562
563 if (!this.echarts) {
564 return;
565 }
566
567 const store = this.props.store;
568 let onDataFilter = this.props.onDataFilter;
569 const dataFilter = this.props.dataFilter;
570
571 if (!onDataFilter && typeof dataFilter === 'string') {
572 onDataFilter = new Function(
573 'config',
574 'echarts',
575 'data',
576 dataFilter
577 ) as any;
578 }
579
580 config = config || this.pending;
581 data = data || this.pendingCtx || this.props.data;
582
583 if (typeof config === 'string') {
584 config = new Function('return ' + config)();
585 }
586 try {
587 onDataFilter &&
588 (config =
589 onDataFilter(config, (window as any).echarts, data) || config);
590 } catch (e) {
591 console.warn(e);
592 }
593
594 if (config) {
595 try {
596 if (!this.props.disableDataMapping) {
597 config = dataMapping(
598 config,
599 data,
600 (key: string, value: any) =>
601 typeof value === 'function' ||
602 (typeof value === 'string' && value.startsWith('function'))
603 );
604 }
605
606 recoverFunctionType(config!);
607
608 if (isAlive(store) && store.loading) {
609 this.echarts?.showLoading();
610 } else {
611 this.echarts?.hideLoading();
612 }
613 this.reloadEcharts(config);
614 } catch (e) {
615 console.warn(e);
616 }

Callers 6

constructorMethod · 0.95
componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95
refFnMethod · 0.95
reloadMethod · 0.95
setDataMethod · 0.80

Calls 3

reloadEchartsMethod · 0.95
dataMappingFunction · 0.90
recoverFunctionTypeFunction · 0.85

Tested by

no test coverage detected