PDA

View Full Version : help! chart will not render



carrier24sg
30 Nov 2010, 10:12 PM
Hi guys,

My chart hosted in a panel, which is in a tabbed panel layout, will not load when datastore.load is called!

I have this error message in firefox:


Error calling method on NPObject!
this.swf.setDataProvider(dataProvider);

Does anyone have any idea?

Animal
1 Dec 2010, 12:18 AM
Check this is accessible: http://dev.sencha.com/deploy/ext/docs/?class=Ext.chart.Chart&member=CHART_URL

By default it is http://yui.yahooapis.com/2.8.0/build/charts/assets/charts.swf

You should download that file and place it into your web app and access it locally,by setting Ext.chart.Chart.CHART_URL accordingly.

carrier24sg
1 Dec 2010, 1:27 AM
Hi animal,

edited my question. Basically my chart does not draw when jsonstore.load() is called.


Check this is accessible: http://dev.sencha.com/deploy/ext/docs/?class=Ext.chart.Chart&member=CHART_URL

By default it is http://yui.yahooapis.com/2.8.0/build/charts/assets/charts.swf

You should download that file and place it into your web app and access it locally,by setting Ext.chart.Chart.CHART_URL accordingly.


I am still having the same problem despite setting it to
Ext.chart.Chart.CHART_URL = "/site_media/ext-3.3.0/resources/charts.swf"; Strangely, I have other charts on the same page and they all work except one.

carrier24sg
1 Dec 2010, 1:55 AM
my code:


function trendsPanel(){


this.trendsStore = new Ext.data.JsonStore({
url: '/topics/showtrackedtopics/',
root: 'results',
autoLoad: true,
fields:[{
name: 'topic_label'
}, {
name: 'model_id'
}, {
name: 'model_label'
}, {
name: 'start_track'
}, {
name: 'end_track'
}, {
name: 'topic_id'
}]
});

this.tb = new Ext.Toolbar({
items:[{
text: 'view trends',
scope:this,
handler:function(){
this.chartingStore.load({
params: {
option: 1,
topicId: 60,
view: 1,
threshold: 0.4
}
});
}
}]
});

this.trendsPanel = new Ext.grid.GridPanel({
title: 'Tracked Topics',
region: 'north',
store: this.trendsStore,
loadMask:true,
height: 200,
tbar:this.tb,
frame: true,
sm: new Ext.grid.RowSelectionModel(),
colModel: new Ext.grid.ColumnModel({
defaults: {
width: 100,
sortable: true
},

columns: //some columns here
}),
});


this.chartingStore = new Ext.data.JsonStore({
url: '/topics/viewtrend/',
// reader configs
root: 'results',
autoLoad:true,
fields: ['period ', 'average'],
baseParams:{
option: 1,
topicId: 60,
view: 1,
threshold: 0.4
}
});

this.chartPanel = new Ext.Panel({
region: 'center',
title: 'Trends',
items: [{
xtype:'linechart',
store:this.chartingStore,
xField:'period',
yField:'average',
}]

});

this.panelTrends = new Ext.Panel({
title: 'Topics to Trends',
layout: 'border',
items: [this.trendsPanel, this.chartPanel],
});
}

Animal
1 Dec 2010, 2:18 AM
Is the Store loading?

carrier24sg
1 Dec 2010, 2:23 AM
Is the Store loading?

yep store is loading. response below:


{"results": [{"average": 1, "period": "2009-04-06"}, {"average": 1, "period": "2009-04-13"}, {"average": 1, "period": "2009-04-20"}, {"average": 1, "period": "2009-05-11"}, {"average": 1, "period": "2009-05-18"}, {"average": 9, "period": "2009-06-01"}, {"average": 17, "period": "2009-06-08"}, {"average": 17, "period": "2009-06-15"}, {"average": 126, "period": "2009-06-22"}, {"average": 59, "period": "2009-06-29"}, {"average": 1, "period": "2009-07-13"}]}

Animal
1 Dec 2010, 4:59 AM
Have you examined the Store with Firebug to check?

carrier24sg
1 Dec 2010, 7:46 AM
Hi animal, I did check with firebug. store is loading.

carrier24sg
1 Dec 2010, 7:14 PM
wow i realize i solve this problem by placing the few lines of code for the panel, the store and chart in another script and calling the objects from my current script.

Can someone please enlighten me why this happen.