suremicro edited a comment 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-516168019
 
 
   I see now what I was missing - the layout seems to be pixel co-ordinates 
with the height neing a negative value, which is why the clipRectByRect doesn't 
work (the grid is all positive).
   
   I've added a simple co-ordinate limiting logic so the bars do keep within 
the grid boundary when zooming and scrolling, however at the moment it does 
leave the labels 'stuck' to the axis lines.
   
   Although not perfect it does look better than at present - thanks to 
Jonathan for the info.
   ```
   
               function chartLayout(ec) {
   
                   ec.eachSeries(seriesComponent => {
   
                       var data = seriesComponent.getData();
   
                       data.each(idx => {
   
                           var layout = data.getItemLayout(idx);
   
                           if (layout) {
   
                               var rect = 
seriesComponent.coordinateSystem.grid.getRect();
                               
                               if (layout.x < rect.x) {
                                   layout.width = layout.width - (rect.x - 
layout.x);
                                   layout.x = rect.x;
                               }
   
                               if (layout.x + layout.width > rect.x + 
rect.width) {
                                   layout.width = rect.x + rect.width - 
layout.x;
                               }
   
                               if (layout.width < 0) layout.width = 0;
   
                               if (layout.y > rect.y + rect.height) {
                                   layout.height = layout.height - (rect.y + 
rect.height - layout.y);
                                   layout.y = rect.y + rect.height;
                               }
   
                               var absY = (rect.y + rect.height) - layout.y;
   
                               if (absY + Math.abs(layout.height) + 65 > rect.y 
+ rect.height) {
                                   layout.height = -(rect.y + rect.height - 65 
- absY);
                               }
   
                               if (layout.height > 0) layout.height = 0;
   
                           }
                       });
                   });
               }
   ```

----------------------------------------------------------------
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