echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Bug] 属性“getModel”为私有属性,只能在类“ECharts”中访问。ts(2341)

Open gy1016 opened this issue 3 years ago • 4 comments

Version

5.4.1

Link to Minimal Reproduction

No response

Steps to Reproduce

useEffect(() => { const dom = document.getElementById("container")!; const myChart = echarts.init(dom, undefined, { renderer: "canvas", useDirtyRect: false, });

const heatPoints: any[] = [];

fetch("http://127.0.0.1:9999/query") .then((res) => res.json()) .then(({ data }) => { for (let point of data) heatPoints.push([point.lng, point.lat, point.heat]); myChart.setOption({ animation: false, bmap: { center: [120.13066322374, 30.240018034923], zoom: 14, roam: true, }, visualMap: { show: false, top: "top", min: 0, max: 5, seriesIndex: 0, calculable: true, inRange: { color: ["blue", "blue", "green", "yellow", "red"], }, }, series: [ { type: "heatmap", coordinateSystem: "bmap", data: heatPoints, pointSize: 5, blurSize: 6, }, ], }); // [Bug] 属性“getModel”为私有属性,只能在类“ECharts”中访问。ts(2341) const bmap = myChart.getModel().getComponent("bmap").getBMap(); }); }, []);

Current Behavior

按照下面官网的这个例子,使用TS+React复现的时候,TS提示getModel是private方法 https://echarts.apache.org/examples/zh/editor.html?c=heatmap-bmap&version=5.4.1

Expected Behavior

getModel应该能够在myChart上使用

Environment

No response

Any additional comments?

No response

gy1016 avatar Feb 23 '23 08:02 gy1016

@gy1016 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Bug] The property "getModel" is private and can only be accessed in the class "ECharts". ts(2341)

echarts-bot[bot] avatar Feb 23 '23 08:02 echarts-bot[bot]

getModel 方法确实没准备暴露给开发者,应该是 BMap 的相关文档应该更新,as any 可以解决这个报错吗?可以的话能麻烦给 bmap/README.md 提个 PR 修复一下文档吗?

Ovilia avatar Mar 01 '23 06:03 Ovilia

getModel 方法确实没准备暴露给开发者,应该是 BMap 的相关文档应该更新,as any 可以解决这个报错吗?可以的话能麻烦给 bmap/README.md 提个 PR 修复一下文档吗?

image 可以解决这个报错。没有暴露 getModel 的话,那有其他办法能获取 bmap 实例吗?感觉这个操作还是挺常见的

daolanfler avatar Jun 14 '23 09:06 daolanfler

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] avatar Jun 13 '25 21:06 github-actions[bot]

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

github-actions[bot] avatar Jun 21 '25 21:06 github-actions[bot]