PDA

View Full Version : Another chart problem



blade226
19 Oct 2012, 3:17 AM
Hi,

i want to create a chart with 3 series. The Problem is now, that 1 of the 3 series has in the first values no values

for example:
1. series
34 - 56 - 110 -
2. series
18 - 77 - 99 -
3. series
- - 78 -

The 3. series is presented as a zero line. When i try to define the first values in 3. series as undefinied, the chart is not build.
I want to start the 3. series, when it has a right value.

scottmartin
22 Oct 2012, 8:23 AM
Is this what you were looking for?
http://jsfiddle.net/PnMnK/

Scott.

blade226
23 Oct 2012, 12:16 AM
Yes, but it doesn't work in my script:
Here ist the store from the php-script

[{"id":"32","sopart":32,"datum":"2012-07-12","alte_zielwerte":"undefined","neue_zielwerte":"undefined"},

{"id":"34","sopart":183,"datum":"2012-08-14","alte_zielwerte":"undefined","neue_zielwerte":"undefined"},
{"id":"35","sopart":105,"datum":"2012-09-13","alte_zielwerte":"undefined","neue_zielwerte":"210"},
{"id":"36","sopart":48,"datum":"2012-10-15","alte_zielwerte":"undefined","neue_zielwerte":"80"},
{"id":"37","sopart":7,"datum":"2012-11-14","alte_zielwerte":"undefined","neue_zielwerte":"56"}]

And here the code


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

fields:[
{name:'sopart',type:'int'},
{name:'datum',type:'date'},
{name:'alte_zielwerte',type:'int'},
{name:'neue_zielwerte',type:'int'}

]
,
proxy : {
type:"ajax",
url:"integrationen_team.php?pid="+sub+"&mon="+mon,
timeout: 600000,
reader:{
type:"json"
}
}
});
mystore3.on('beforeload', function() {
Ext.getBody().mask("Loading...", 'x-mask-loading');
});
mystore3.on('load', function() {
Ext.getBody().unmask();
});
var dia = Ext.create ('Ext.chart.Chart', {
xtype: 'chart',
id: 'chartCmp',
width: 300,
height: 200,
store: mystore3,

legend: {
position: 'right'
},
axes: [
{
title: 'Anzahl',
type: 'Numeric',
position: 'left',
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
minimum: 0,
//maximum: 20,
minorTickSteps: 1,
majorTickSteps : 10,
fields: ['sopart', 'alte_zielwerte', 'neue_zielwerte'],
grid: true


}
,
{
title: 'Meldemonat',
type: 'time',
position: 'bottom',
fields: ['datum'],
dateFormat:'m.Y',
grid: true

}

],
series: [

{
type: 'line',
axis: 'left',
smooth: true,
xField: 'datum',
yField: 'sopart',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('sopart'));
}}

},
{
type: 'line',
axis: 'left',
//fill: true,
smooth: true,
xField: 'datum',
yField: 'alte_zielwerte',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('alte_zielwerte'));
}}

},
{
type: 'line',
axis: 'left',
//fill: true,
smooth: true,
xField: 'datum',
yField: 'neue_zielwerte',
tips: {
trackMouse: true,
width: 40,
height: 25,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('neue_zielwerte'));
}}

}

]

});



The result is, that the browser shows not the chart.
What make i worng?

Farish
23 Oct 2012, 12:26 AM
the problem could be that the y axis is Numeric whereas the data has strings for alte_zielwerte and neue_zielwerte fields. Try using them without the quotation marks (") and see if that helps. In the link provided above, if I add quotation marks around the values for data1 and data2, the chart does not render correctly.

blade226
23 Oct 2012, 12:38 AM
Thanks, i tried it and it works. I created the store in the ext code without ". He build the chart correctly. Now i must find out, how to filter the " in the php command json_encode.

THX for helping!