jonavila commented on issue #8841: min/max on yAxis for bar charts, makes the 
bars go outside limits
URL: 
https://github.com/apache/incubator-echarts/issues/8841#issuecomment-517322955
 
 
   @suremicro Here you go: 
https://codesandbox.io/s/echarts-showhide-labels-in-bars-jr1ks
   
   I've adapted an example from one of my use cases, but I've simplified it a 
bit to only account for vertical bars with 90 rotated labels. 
   
   Here's the gist of it:
   1. For each series, we loop through the data and get the bar layout.
   2. For each of the bars, we define the label text. In my case, it's a 
combination of series name and value.
   3. We then grab the itemLabelModel. This is the object with label options. I 
wanted to show/hide labels for each bars as opposed to doing it at the series 
level.
   4. We merge seriesLabel options into itemLabel options just in case you have 
defined some of the config at the series level.
   5. We obtain text rectangle for each label (the bounding box of the text)
   6. Finally, we compare it against the bar layout. When rotated 90 degress, 
you want to compare the label height with the bar width and the label width 
with the bar height.
   
   In the demo, I'm showing the labels on hover so that you can see them 
overflow the bars.
   Please resize the window in the sandbox so that you can see lables show/hide

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to