PDA

View Full Version : Numeric axis not showing the whole range



raskri
5 Jan 2012, 1:46 AM
If I use an Ext.chart.Panel with these values(see below), the chart does not show the whole range in the numeric axis. The lowest value is -5045 and highest is 1818.

The axis starts at -6000 cuts at 1200. How can i manage to show the whole range? I cannot set maximum and minimum, as they can be different other times. Any pointers here are appreciated!:D

Example data, which is put in myStore:


{"success":true,"result":{"readings":
[{"month":"1","year1":"968","year2":"1194","year3":"955"},
{"month":"2","year1":"910","year2":"974","year3":"879"},
{"month":"3","year1":"816","year2":"867","year3":"446"},
{"month":"4","year1":"674","year2":"675","year3":"148"},
{"month":"5","year1":"574","year2":"-5045","year3":"126"},
{"month":"6","year1":"444","year2":"433","year3":"104"},
{"month":"7","year1":"363","year2":"372","year3":"1818"},
{"month":"8","year1":"418","year2":"399","year3":"99"},
{"month":"9","year1":"487","year2":"233","year3":"89"},
{"month":"10","year1":"713","year2":"628","year3":"0"},
{"month":"11","year1":"777","year2":"832","year3":"0"},
{"month":"12","year1":"994","year2":"1093","year3":"0"}]}}




myStore = new Ext.data.JsonStore({
fields: ['month','year1','year2','year3'],
root: 'readings'
});


In this code:


var v = new Ext.chart.Panel({
items: {
store: myStore,
axes: [{
type: 'Numeric',
position: 'bottom',
fields: ['year1', 'year2', 'year3'],
title: 'Number of Hits'
},
{
type: 'Category',
position: 'left',
fields: ['month'],
title: 'Month of the Year'
}],
series: [{
type: 'bar',
xField: 'month',
yField: ['year1', 'year2', 'year3']
}]
}
});

30475

raskri
5 Jan 2012, 7:52 AM
Yes, so I spent 3 hours debugging..... gah!B)

In Ext.chart.series.Cartesian.getMinMaxYValues()

This:


function eachYValue(yValue, i) {
if (!me.isExcluded(i)) {
if (yValue > max) {
max = yValue;
}
if (yValue < min) {
min = yValue;
}
}
}



Was changed to, this:


function eachYValue(yValue, i) {
if (!me.isExcluded(i)) {
if (parseInt(yValue) > max) {
max = yValue;
}
if (parseInt(yValue) < min) {
min = yValue;
}
}
}


The max value was never set. Cast to int. Then it worked for me. I will settle for this little hack in an override. Is it a bug? Or am I doing something wrong in this case?~o)

Edit: If the stores fields are marked as type:'number', it works like a charm...:P

Naga
2 Feb 2012, 4:55 AM
I guess it will be solved by keeping this in your axis,


adjustMinimumByMajorUnit: true,
adjustMaximumByMinorUnit : true


Regards,
Nag.