You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/07/29 15:14:40 UTC

[GitHub] [incubator-echarts] jonavila commented on issue #8841: min/max on yAxis for bar charts, makes the bars go outside limits

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-516034572
 
 
   @suremicro No need to go the custom chart route. I've solved this using a similar solution to yours but instead of creating a custom chart, I update each bar's layout properties. You can update each bar's layout by registering a layout function before initializing your chart.
   
   Example:
   ```js
   echarts.registerLayout(myCustomLayoutFunction);
   echarts.init(myChartContainer);
   
   function myCustomLayoutFunction(ecModel) {
     ecModel.eachSeries(seriesComponent => {
       const data = seriesComponent.getData();
       data.each(idx => {
         const layout = data.getItemLayout(idx);
         
         if (layout) {
           const newLayout = echarts.graphic.clipRectByRect(
             layout,
             seriesComponent.coordinateSystem.grid.getRect(),
           );
   
           if (newLayout) {
             ({ x: layout.x, y: layout.y, width: layout.width, height: layout.height } = newLayout);
           }  
         }
       });
     }
   }
   ```
   
   I use this technique of registering layout functions for my charts quite often to do things like dynamically showing or hiding series labels depending if they fit. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org