You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2022/11/04 21:59:31 UTC

[GitHub] [echarts] Creatium opened a new issue, #17874: Allow percentages in label width parameter

Creatium opened a new issue, #17874:
URL: https://github.com/apache/echarts/issues/17874

   ### What problem does this feature solve?
   
   Right now label settings allow only fixed pixels number for the width parameter. In cases where chart width is varying (and that is probably most of the cases), it should be possible to allow labels have a full width "100%" setting. 
   
   What I am trying to achieve for my chart is having horizontal bar chart with labels above the bar itself. On the left it should show the data index name, on the right - the value. But since I don't know the final width of the chart, I am unable to "push" the right part of label to be truly on the right side.
   
   ### What does the proposed API look like?
   
   series -> label -> width - allow "100%" setting, not just pure number value.


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [echarts] plainheart commented on issue #17874: Allow percentages in label width parameter

Posted by GitBox <gi...@apache.org>.
plainheart commented on issue #17874:
URL: https://github.com/apache/echarts/issues/17874#issuecomment-1304750075

   Maybe you can try to use the [`labelLayout`](https://echarts.apache.org/option.html#series-bar.labelLayout) callback function to get the chart width and use it to calculate the position of the label.
   Like this,
   
   ```js
   labelLayout(params) {
     // get chart width
     const chartWidth = myChart.getWidth();
     // ...
     return {
       // ...
     }
   }
   ```


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [echarts] urgrund commented on issue #17874: Allow percentages in label width parameter

Posted by GitBox <gi...@apache.org>.
urgrund commented on issue #17874:
URL: https://github.com/apache/echarts/issues/17874#issuecomment-1304772962

   I think this is important feature and would be valuable if this extended to font-sizes as well 
   
   We're able to define bar/pie elements with percentages,  but our labels don't follow.   This makes it cumbersome having to write per-chart instance differences in to adjust the font size _(which in the end is just eyeballing)_ .
   
   If the font size supported typical CSS _(%, px, em, vw)_ values that might help the charts be more responsive and scalable to pages that want to reuse the same chart in different scales or just simply have their charts follow font rules used elsewhere in the site.
   
   ![image](https://user-images.githubusercontent.com/13104208/200166517-21ae75a8-6131-4790-9194-5c6cb258358f.png)
   


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


[GitHub] [echarts] Creatium commented on issue #17874: Allow percentages in label width parameter

Posted by GitBox <gi...@apache.org>.
Creatium commented on issue #17874:
URL: https://github.com/apache/echarts/issues/17874#issuecomment-1305643598

   Solved my problem by setting width param in label setting of series to this:
   `width: chart.value?.$el.clientWidth - 30,`
   
   30 being the margin of charts (can be changed in grid setting of chart options).


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

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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