PDA

View Full Version : Chart problem



blade226
24 Sep 2012, 2:46 AM
Hello,

i want to display a chart with 3 lines.

var artikelGrid = Ext.create ('Ext.chart.Chart', {
width: 800,
height: 600,
store: mystore55,
legend: {
position: 'right'
},
axes: [
{
title: 'Anzahl',
type: 'Numeric',
position: 'left',
fields: ['xsozial','ba','sopart'],

minimum: 4500,
maximum: 6500,
minorTickSteps: 1,
majorTickSteps : 10,
grid: true,

}
,
{
title: 'Datum',
type: 'time',
position: 'bottom',
fields: ['datum'],
dateFormat:'m.Y'
}
],
series: [
{
type: 'line',
axis: 'left',
smooth: true,
xField: 'datum',
yField: 'xsozial',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('xsozial'));
}}


},
{
type: 'line',
axis: 'left',
xField: 'datum',
yField: 'ba',
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'));
}}

}

]

});


The problem is now, that 2 lines end before the third line end. So the 2 lines go to 0.

Is there a possibility, that the two lines stop before?

scottmartin
24 Sep 2012, 12:56 PM
You can use 'undefined' as a value to stop a line. If you want a gap, then you will need a new series.

Scott.

blade226
24 Sep 2012, 9:38 PM
Thanks, it works

blade226
24 Sep 2012, 11:52 PM
There is a small problem:

the undefiened variables are displayed outside the char. How can I stop this?

scottmartin
25 Sep 2012, 4:05 AM
Can you please explain.

Scott.

blade226
25 Sep 2012, 4:18 AM
Left of the graph is shown a point. Before i declared the undefinied variables no point was seen. After change there is a point38916

blade226
23 Oct 2012, 2:17 AM
I have found out the solution.

The json-string and the store definition was wrong.

the store:

var mystore556 = Ext.create('Ext.data.Store', {

fields:[
{name:'id',type:'int'},
{name:'xsozial',type:'int'},
{name:'ba',type:'int'},
{name:'sopart',type:'int'},
{name:'datum',type:'date'}
]
,
proxy : {
type:"ajax",
url:"includes/datengesamt2.php",
waitMsg: 'Loading...',
reader:{.....


the json string created with php command: json_encode:


.....
{"id":"39","xsozial":"undefined","ba":"undefined","sopart":5178,"datum":"2013-01-01"},
{"id":"40","xsozial":"undefined","ba":"undefined","sopart":5193,"datum":"2013-02-01"}]


Here the right way:
store:

var mystore556 = Ext.create('Ext.data.Store', {

fields:[
{name:'xsozial'},
{name:'ba'},
{name:'sopart'},
{name:'datum',type:'date'}
]
,
proxy : {
type:"ajax",
url:"includes/datengesamt2.php",
waitMsg: 'Loading...',
reader:{....


and the string without json_encode



.....
{'id':39,'xsozial':undefined,'ba':undefined,'sopart':5178,'datum':'2013-01-01'},
{'id':40,'xsozial':undefined,'ba':undefined,'sopart':5193,'datum':'2013-02-01'},]
And now it works