Skip to content

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

@gy1016

Description

@gy1016

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docDocument or Website related issues.staleInactive for a long time. Will be closed in 7 days.waiting-for: author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions