Closed arashdalir closed 3 years ago
This is perhaps not the best way to achieve this, but you could theoretically do something like the following:
let topPixel = myChart.getOption().grid[0].top;
let coord=myChart.convertFromPixel({seriesIndex:0},[0,topPixel]);
console.log(coord[1]);
This example gets the top pixel coordinate from the desired grid and converts then this pixel to the corresponding series y-coordinate. Since we are converting PIXELS to coords, I do not know how accurate this is for your use-case...
@sxmpasch well, this doesn't exactly work correctly. I tried the code with different charts we have. as long as I don't define the top value for the grid, this appears to work. but in many cases I have predefined percentage values for top to position the grid's location, for example '25%' or so on. I haven't found a way to convert them info coordinates properly. any suggestions?
@arashdalir - ok, percentage to absolute pixel. You just have to calculate this against the total height of the echarts instance:
let topPixel=myChart.getOption().grid[1].top
if (topPixel.indexOf('%')>=0) {
topPixel=topPixel.substr(0,topPixel.length-1);
topPixel=parseInt(topPixel)/100*myChart.getHeight();
}
console.log(topPixel)
let coord=myChart.convertFromPixel({seriesIndex:0},[0,topPixel]);
console.log(coord[1]);
thanks @sxmpasch. tbh didn't notice the getHeight()
function and didn't know exactly how the convertFromPixel
works. this is working for now, I have not checked all the chart types in our system though; would report back if there are any other issues.
@arashdalir - ok, percentage to absolute pixel. You just have to calculate this against the total height of the echarts instance:
let topPixel=myChart.getOption().grid[1].top if (topPixel.indexOf('%')>=0) { topPixel=topPixel.substr(0,topPixel.length-1); topPixel=parseInt(topPixel)/100*myChart.getHeight(); } console.log(topPixel) let coord=myChart.convertFromPixel({seriesIndex:0},[0,topPixel]); console.log(coord[1]);
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
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!
General Questions
In this issue, I have provided information with:
Issue Type
Issue Details
right now, it's not possible to programmatically check what the maximum label value for
yAxis
is (at least there is no documentation showing how to get it. as shown in the following example, we are trying to determine if some points of different series overlap, and if so, we want to use a biggersymbolSize
to indicate that 2 points overlap. to do so, the functiondynamicSymbolSize
in my example is created. it works by normalizing the values defined as aseriesGroup
by determining what the highest value of their correspondingyAxis
is. this would have worked/will work ONLY IFyAxis.max
is already predefined or by coincident, if the highest value is also the highest axisLabel. otherwise the normalization doesn't work as wished.if you check my example, the part marked with
//TODO
is where I need a function likeyAxis.getMaxLabel()
or whatever it's called/is going to be called; or a property which delivers the set value.Expected Behavior
the function
yAxis.getMaxLabel()
(or the property...) should deliver the maximum value used for labelingyAxis
.Current Behavior
I have not found any function/property that does this.
Online Example
https://jsfiddle.net/byn4eLvp/2/
Topics
Anything Else We Need to Know
Ahm, I don't think so, please ask if you need...
Environment