PDA

View Full Version : Time axis in line chart



blade226
6 Dec 2012, 1:28 AM
Hi,
i have an problem in updating from ext 4.0 to ext 4.1.1a.

In a line chart is not displayed the bottom time axis

in ext 4.0 works it perfect:

here is a part of the store:


[{'id':20,'sprenger':357,'ba':347,'sopart':402,'datum':'2011-09-15'},
{'id':21,'sprenger':200,'ba':211,'sopart':242,'datum':'2011-10-13'},
{'id':22,'sprenger':205,'ba':196,'sopart':250,'datum':'2011-11-15'},
{'id':23,'sprenger':159,'ba':150,'sopart':186,'datum':'2011-12-15'},


here the chart:


var dia = Ext.create ('Ext.chart.Chart', {
xtype: 'chart',
id: 'chartCmp',
width: 800,
height: 450,
store: mystore334,
legend: {
position: 'right'
},
axes: [
{
title: 'Anzahl',
type: 'Numeric',
position: 'left',
fields: ['sprenger','ba','sopart'],
grid: true,
}
,
{
title: 'Meldemonat',
type: 'time',
position: 'bottom',
fields: ['datum'],
dateFormat:'m.Y',
grid: true,
label: {
rotate: {
degrees: 270
}
}
}
],
series: [
{
type: 'line',
axis: 'left',
xField: 'datum',
yField: 'sprenger',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('sprenger'));
}}
},
{
type: 'line',
axis: 'left',
xField: 'datum',
yField: 'ba',
fill: true,
highlight: {
size: 7,
radius: 7
},
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('ba'));
}}
},
{
type: 'line',
axis: 'left',
xField: 'datum',
yField: 'sopart',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('sopart'));
}}
}

]

});


I can't use fromDate, because i don't know when the time axis must start.
In bottom line he displayed me Nan.0NaN. The load time is much longer, or the browser wants to abort the script. When he loads the store, the browser also displayed Nan.0NaN.
I search in the forum, but i only find the hint with fromDate. When i use fromDate (for test) then he loads very long and displayed the lines right, but the bottom line is always wrong.

Someone an idea?

mitchellsimoens
8 Dec 2012, 6:24 AM
Using this code I see both axis:


Ext.create('Ext.chart.Chart', {
xtype : 'chart',
renderTo : document.body,
width : 800,
height : 450,
store : {
fields : ['id', 'sprenger', 'ba', 'sopart',
{
name : 'datum',
type : 'date',
dateFormat : 'Y-m-d'
}
],
data : [
{'id' : 20, 'sprenger' : 357, 'ba' : 347, 'sopart' : 402, 'datum' : '2011-09-15'},
{'id' : 21, 'sprenger' : 200, 'ba' : 211, 'sopart' : 242, 'datum' : '2011-10-13'},
{'id' : 22, 'sprenger' : 205, 'ba' : 196, 'sopart' : 250, 'datum' : '2011-11-15'},
{'id' : 23, 'sprenger' : 159, 'ba' : 150, 'sopart' : 186, 'datum' : '2011-12-15'}
]
},
legend : {
position : 'right'
},
axes : [
{
title : 'Anzahl',
type : 'Numeric',
position : 'left',
fields : ['sprenger', 'ba', 'sopart'],
grid : true
},
{
title : 'Meldemonat',
type : 'time',
position : 'bottom',
fields : ['datum'],
dateFormat : 'm.Y',
grid : true,
label : {
rotate : {
degrees : 270
}
}
}
],
series : [
{
type : 'line',
axis : 'left',
xField : 'datum',
yField : 'sprenger',
tips : {
trackMouse : true,
width : 40,
height : 25,
renderer : function (storeItem, item) {
this.setTitle(storeItem.get('sprenger'));
}}
},
{
type : 'line',
axis : 'left',
xField : 'datum',
yField : 'ba',
fill : true,
highlight : {
size : 7,
radius : 7
},
tips : {
trackMouse : true,
width : 40,
height : 25,
renderer : function (storeItem, item) {
this.setTitle(storeItem.get('ba'));
}}
},
{
type : 'line',
axis : 'left',
xField : 'datum',
yField : 'sopart',
tips : {
trackMouse : true,
width : 40,
height : 25,
renderer : function (storeItem, item) {
this.setTitle(storeItem.get('sopart'));
}
}
}
]
});

Looking like there is an error in 4.1.1 showing the dates in the bottom axis which looks to be fixed in 4.1.3