将字换行样式应用于extjs图表标签

编程入门 行业动态 更新时间:2024-10-26 04:32:14
本文介绍了将字换行样式应用于extjs图表标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在做extjs图表。当轴标签具有大文本时,在图表的边缘处,文本被切断。如何换行长标签?有什么建议么? 这是我的代码:

如果您有极长的标签,即使使用自动换行仍然会被截断,您可以在n个字符后截断标签。 Ext有一个很酷的 ellipsis function for that

renderer:function(v){v = Ext.util.Format (v,80); // truncate after 80 characters return v.replace(/((?: \w +){5})/ gi,$ 1\\\); }

I'm working on extjs chart. when the axis labels have big texts, at the edges of the Chart the texts are cut off. How to word wrap long labels? Any suggestions? Here is my code: fiddle.sencha/#fiddle/15ef

解决方案

adding newlines every n words should do the trick. Try adding a renderer to your axes label. Implemented in fiddle and it isn't cutting off anymore

renderer: function(v) { return v.replace(/((?:\w+ ){5})/gi, "$1\n"); //newline every 5th word }

If you have extremely long labels that still cut off even with word wrap, you could truncate the labels after n characters. Ext has a cool ellipsis function for that

renderer: function(v) { v = Ext.util.Format.ellipsis(v,80); //truncate after 80 characters return v.replace(/((?:\w+ ){5})/gi, "$1\n"); }

更多推荐

将字换行样式应用于extjs图表标签

本文发布于:2023-07-13 03:14:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1099768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用于   图表   样式   换行   标签

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!