Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【完善】ECharts-JSX 重写地图图表 #101

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions source/page/Map/component/EChartsMap.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'echarts-jsx/dist/renderers/SVG';
import 'echarts-jsx/dist/components/geo';

import { DataObject } from 'dom-renderer';
import { EChartsOption, EChartsType, init, registerMap } from 'echarts';
import { observable } from 'mobx';
Expand Down Expand Up @@ -117,14 +120,21 @@ export class EChartsMap
properties.name = long2short(properties.name);

registerMap(mapName, data);

chart.setOption(chartOptions);


this.renderChart(chartOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSX 渲染方法应由组件引擎调用,而不是组件作者直接调用。

this.adjustLabel();

chart.hideLoading();
}

renderChart(chartOptions: EChartsOption) {
return (
<ec-svg-renderer >
<ec-geo
map={this.mapName}
data={chartOptions.options[0].series[0]?.data}
/>
</ec-svg-renderer>
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renderChart(chartOptions: EChartsOption) {
return (
<ec-svg-renderer >
<ec-geo
map={this.mapName}
data={chartOptions.options[0].series[0]?.data}
/>
</ec-svg-renderer>
);
}
render() {
const { options } = this.chartOptions;
return (
<ec-svg-renderer>
<ec-geo
map={this.mapName}
data={options[0].series[0]?.data}
/>
</ec-svg-renderer>
);
}

updateChartData = (newData: Province[]) =>
this.chart.setOption({
series: [
Expand Down
Loading