gpt4 book ai didi

Extjs 折线图多线标签

转载 作者:行者123 更新时间:2023-12-02 03:49:54 25 4
gpt4 key购买 nike

我想在折线图中的 X 轴上制作一个标签,显示所选类别的摘要。我想格式化这个,所以在类别名称下我有值。如果我这样做,它会起作用:

return Ext.Date.format(v, 'M Y') + '\r' + 
(val.data.Budgeted==null?'':('$ '+Ext.util.Format.number(val.data.Budgeted, '0,000') + '\r')) +
(val.data.Actual==null?'':('$ '+Ext.util.Format.number(val.data.Actual, '0,000') + '\r'));

仍然,正如我发现的那样,每个\r 字符的标签都在下降。因此,如果我没有\r,它会按应有的方式显示,但如果有 N '\r'-s,则标签本身会下降,因为它上面有 N 行文本。

也很高兴找到一种方法来格式化文本(对齐)

编辑:
我找到了一种方法,通过更改轴配置中的“drawVerticalLabels”函数。不过,在我看来,这是一种糟糕的方式。

最佳答案

我认为我必须做一些非常相似的事情。 SO here 上有它的截图.

我最终把它当作 HTML 模板来做。我不像现在这样熟悉 ExtJS 框架,所以如果我必须重做它,我可能会使用 xtemplate,但这对我来说很有效:

series: [{
type: 'line',
title: 'This Year',
axis: 'left',
smooth: false,
xField: 'date_value',
yField: 'the_count',

// custom tips
tips: {
trackMouse: true,
width: 127,
height: 70,
hideDelay: 0,
dismissDelay: 0,
renderer: function(record) {
this.setTitle('<table width=115><tr><th><b>' +
record.get('date_value') +
':</b></th><td align=right>' +
record.get('the_count') +
'</td></tr><tr><th><b>Quota:</b></th><td align=right>' +
record.get('the_quota') +
'</td></tr><tr><th><b>Diff:</b></th><td align=right>' +
(record.get('the_quota') > record.get('the_count') ?
'-' + (record.get('the_quota') - record.get('the_count')) :
'+' + (record.get('the_count') - record.get('the_quota'))
) + '</td></tr></table>'
);
}
}
}]

关于Extjs 折线图多线标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14758541/

25 4 0