echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Unable to access 'getModel' function in typescript

Open RavalikaP opened this issue 3 years ago • 3 comments

Version

5.2.2

Link to Minimal Reproduction

No response

Steps to Reproduce

  1. Create any chart
  2. on the chart finish event . I am trying to access chart.getModel().getComponent('grid')
  3. So while running the application we are getting below issue

Property 'getModel' is private and only accessible within class 'ECharts'.

Current Behavior

It is working as expected but need to make the getModel function as public

Expected Behavior

It is working as expected but need to make the getModel function as public

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

If any workaround is there to get the component other than getModel function

RavalikaP avatar Feb 09 '22 04:02 RavalikaP

getModel is not ready to be public yet because it will expose too much internal abstraction. We only suggest using this method when it's the only workaround to solve the issue and you can accept the missing doc and potential breaking change of this method in the future.

pissang avatar Feb 09 '22 04:02 pissang

Please close this issue if you don't have further questions. Thanks! @RavalikaP

Ovilia avatar Feb 10 '22 02:02 Ovilia

@pissang

  • I'm a bit confused, getModel() appears frequently, both in the documentation and in git. For example, https://echarts.apache.org/en/faq.html#baidu-map and https://github.com/apache/echarts/tree/5.3.3/extension-src/bmap both mention chart.getModel().getComponent('bmap').getBMap();, which specifically accesses the private method. If this is not allowed to be used directly, should we update the documentation?

linghengqian avatar Sep 16 '22 06:09 linghengqian

@pissang @Ovilia but if not using getModel(), how can I get the component value when zooming in and zooming out?

bbcfive avatar Nov 26 '22 05:11 bbcfive

You should listen to datazoom event.

Ovilia avatar Dec 01 '22 02:12 Ovilia