echarts
echarts copied to clipboard
Need x,y,Width,Height of the chart elements
What problem does this feature solve?
Need X, Y position along with Height and Weight of the chart elements like xAxis, yAxis, Grid, Legends. If we get this values we will append some graphic elements to it and apply some styling to it.
What does the proposed API look like?

There are no such APIs but you can get this information option.grid and option.legend from your input option.
@Ovilia but on option.legend and option.grid we are not getting the updated values. If it is updated then it will be easy to get it.
You may get such information via some internal APIs. Just FYI.
Grid
// if there are multiple grids, use `getComponent('grid', gridIndex)`
const gridRect = chart.getModel().getComponent('grid').coordinateSystem.getRect();
Axis
// if there are multiple axes, use `getComponent('xAxis', axisIndex)`
const xAxisModel = chart.getModel().getComponent('xAxis');
const xAxisView = chart.getViewOfComponentModel(xAxisModel);
const xAxisRect = xAxisView.group.getBoundingRect();
@plainheart , Thank you for the reply. can u please suggest me how to get the legends?
@RavalikaP It's similar to the above.
const legendModel = chart.getModel().getComponent('legend');
const legendView = chart.getViewOfComponentModel(legendModel);
const legendRect = legendView.group.getBoundingRect();
const [x, y] = legendView.group.transformCoordToGlobal(legendRect.x, legendRect.y);
const { width, height } = legendRect;
console.log(x, y, width, height);
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.
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!