I want to make a label in Line Chart on X axis, that shows summary for selected category. I want to format this, so under category name I have values. It works if I do:
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'));
still, label is going down, as I found, with each \r char. So if I have no \r it shows like it should, but if there is N '\r'-s then label itself will go down as there is N lines of text over it.
Also will be nice to find a way to format text (align)
EDIT:
I found a way to do this, by changing "drawVerticalLabels" function in axis config. Still, it's a bad way in my opinion.
I had to do something pretty similar I think. There's a screenshot of it on SO here.
I ended up doing it like an HTML template. I wasn't as familiar with the ExtJS framework as I am now so if I had to redo it I would probably use an xtemplate, but this worked out for me:
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>'
);
}
}
}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With