
[英]<tspan> text </tspan> how to remove text if id or class is not defined?
[英]How to split long text in Ext.draw.Text using tspan
我使用Ext.draw.Text ...为Ext图表创建了自定义图例面板。在我的应用程序中,图例可能包含很长的自定义文本。 因此,我需要使用固定长度来拆分它们。 一种方法是使用Javascript拆分文本并为文本的每个部分创建文本精灵。
还有其他方法可以在Ext.draw.Text中拆分文本吗?
码:
Ext.create('Ext.draw.Component', {
renderTo: Ext.getBody(),
width: 800,
height: 200,
items: [{
type: 'rect',
fill: 'red',
width: 12,
height: 12,
x: 5,
y: 10
},{
type: "text",
text: "This is a long text.. Can i split this into two tspan",
fill: "green",
width: 12,
height: 12,
font: "18px monospace",
x: 25,
y: 15
}]
});
提前致谢。
通过在文本content('\\ n')中插入Ext.draw.text
,我成功地为Ext.draw.text
生成了多个tspan。 JSFiddle
Ext.create('Ext.draw.Component', {
renderTo: Ext.getBody(),
width: 800,
height: 200,
items: [{
type: 'rect',
fill: 'red',
width: 12,
height: 12,
x: 5,
y: 10
},{
type: "text",
text: "This is a long text.. \n Can i split this into two tspan", //Added new line character
fill: "green",
width: 12,
height: 12,
font: "18px monospace",
x: 25,
y: 15
}]
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.