Sencha Touch 2 pie chart not displaying - sencha-touch-2

I am attempting to follow this example for creating a pie chart.
I added some simple code to create and dock a toolbar to the top of the view but still using the code from the example linked above. Doing this made the chart not display. I just get a blank page.
My code is pasted below:
Ext.define('RevivalTimes.view.Chart', {
extend: 'Ext.chart.PolarChart',
xtype: 'chart',
requires: [
'Ext.chart.series.Pie',
'Ext.chart.interactions.Rotate'
],
config: {
title: 'Statistics',
iconCls: 'settings',
layout: 'fit',
/**************** This toolbar causes the second error - disappearing chart **************/
items: [{
docked: 'top',
xtype: 'toolbar',
title: 'Statistics Chart',
items :[
{
align : 'left',
name : 'nav_btn',
iconCls : 'list',
iconMask: true,
ui : 'plain',
},
{
align : 'right',
name : 'user_btn',
iconCls : 'user',
iconMask: true,
ui : 'plain',
}
]
}],
/**********************************************************************/
animate: true,
interactions: ['rotate'],
colors: ['#115fa6', '#94ae0a', '#a61120', '#ff8809', '#ffd13e'],
store: {
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
data: [
{name: 'metric one', data1: 10, data2: 12, data3: 14, data4: 8, data5: 13},
{name: 'metric two', data1: 7, data2: 8, data3: 16, data4: 10, data5: 3},
{name: 'metric three', data1: 5, data2: 2, data3: 14, data4: 12, data5: 7},
{name: 'metric four', data1: 2, data2: 14, data3: 6, data4: 1, data5: 23},
{name: 'metric five', data1: 27, data2: 38, data3: 36, data4: 13, data5: 33}
]
},
series: [{
type: 'pie',
label: {
field: 'name',
display: 'rotate'
},
xField: 'data3',
donut: 30
}]
} //config
});
When I visit the chart view, I get the following error:
Uncaught TypeError: Object [object Object] has no method 'renderFrame'
UPDATE:
I should explain I am not using the default tabbar for navigation. I implemented a slide navigation by following this tutorial.
I am using the following controller code to switch views:
Ext.define('RevivalTimes.controller.Navigation', {
extend: 'Ext.app.Controller',
config: {
refs: {
main: 'main',
navigation : 'navigation',
},
control: {
"button[name='nav_btn']": {
tap: 'toggleNav'
},
navigation : {
itemtap : function(list, index, target, record){
this.toggleNav();
// console.debug('LIST: ' + list);
// console.log('INDEX: ' + index);
// console.error('TARGET: ' + target.toSource());
// console.warn('RECORD: ' + record);
// JSON.stringify(target);
switch(index){
case 0:
this.getMain().setActiveItem(0);
break;
case 1:
this.getMain().setActiveItem({xtype:'messagesview'});
break;
case 2:
this.getMain().setActiveItem({xtype:'articleslistview'});
break;
case 3:
this.getMain().setActiveItem({xtype:'categoriesview'});
break;
case 4:
// this.getMain().setActiveItem({xtype:'chart'});
this.getMain().setActiveItem({xtype:'chartcontainer'});
break;
default:
break;
}
}
}
}
},
toggleNav: function(){
// console.log('responding!');
var me = this;
mainEl = me.getMain().element;
if (mainEl.hasCls('out')) {
mainEl.removeCls('out').addCls('in');
me.getMain().setMasked(false);
} else {
mainEl.removeCls('in').addCls('out');
me.getMain().setMasked(true);
}
}
});
When I select the last option on my slide navigation, the view changes successfully but the pie chart fails to load as explained above.

Try this:-
Ext.define('RevivalTimes.view.Main', {
extend: 'Ext.Container',
xtype: 'main',
config: {
layout: 'fit',
items: [{
docked: 'top',
xtype: 'toolbar',
title: 'Statistics Chart',
items :[
{
align : 'left',
name : 'nav_btn',
iconCls : 'list',
iconMask: true,
ui : 'plain'
},
{
align : 'right',
name : 'user_btn',
iconCls : 'user',
iconMask: true,
ui : 'plain'
}
]
},{
xtype: 'chart'
}]
}
});

Related

sencha 2.3 beta - Touch Grid is not working at run-time using sencha Architect v3.0

When running the app.html, after publishing it using sencha architect 3.0, it shows the below error. In complie time am able to see the values populated in this Grid.
But the link seems to be empty in order to fetch the Grid.js for the new 2.3 beta version....
Please let me know any other way to resolve this error.
Error:
Failed to load resource: the server responded with a status of 404 (Not Found)http://sc13-live.sencha.com/touch/touch-2.3.0/src/grid/Grid.js?_dc=1378814671364
// #require #packageOverrides
Ext.Loader.setConfig({
});
Ext.application({
models: [
'MyModel'
],
stores: [
'MyDirectStore'
],
views: [
'MyGrid'
],
name: 'MyApp',
launch: function() {
Ext.create('MyApp.view.MyGrid', {fullscreen: true});
}
});
Ext.define('MyApp.view.MyGrid', {
extend: 'Ext.grid.Grid',
config: {
height: 297,
width: 444,
store: 'MyDirectStore',
title: 'Grid-5Cols',
columns: [
{
xtype: 'column',
width: 85,
dataIndex: 'no',
text: 'EmpNo'
},
{
xtype: 'column',
width: 89,
dataIndex: 'name',
text: 'EName'
},
{
xtype: 'column',
width: 86,
dataIndex: 'sal1',
text: 'Sal1'
},
{
xtype: 'column',
width: 86,
dataIndex: 'sal2',
text: 'Sal2'
},
{
xtype: 'column',
width: 80,
dataIndex: 'sal3',
text: 'Sal3'
}
]
}
});
Ext.define('MyApp.store.MyDirectStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyModel'
],
config: {
data: [
[
'1',
'AceSupplies',
'05',
'1000',
'10'
],
[
'2',
'BestGoods',
'11',
'2000',
'20'
],
[
'3',
'First Choice',
'20',
'3000',
'30'
]
],
model: 'MyApp.model.MyModel',
storeId: 'MyDirectStore',
proxy: {
type: 'direct',
reader: {
type: 'json'
}
}
}
});
Ext.define('MyApp.model.MyModel', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'no',
type: 'int'
},
{
name: 'name',
type: 'string'
},
{
name: 'sal1',
type: 'float'
},
{
name: 'sal2',
type: 'float'
},
{
name: 'sal3',
type: 'float'
}
]
}
});
The new Sencha Touch Grid is not included with standard Sencha Touch, please see below:
Please note that the new Touch Grid component is not a part of Sencha
Touch and is only available as part of Sencha Complete or Sencha Touch
Bundle.
Source: http://www.sencha.com/products/touch/

getting index value 0 from dataview any list itemtap from sencha touch

I am unable to get index value form the dataview:
{
xtype: 'list',
itemId: 'catList',
store: 'CategoryStore',
scrollable: false,
layout: 'fit',
itemHeight: 20,
itemTpl: [
'<div>',
'<tpl for="data">',
'<span >{category_name}</span> ',
'</tpl>',
'</div>'],
listeners: {
'itemtap': function(list, index, target, record, e, eOpts){
console.log(record.get('cat_id'));
}
}
}
Edited:
If i put data static on store it works fine but it does not work while getting data from server:
it works like as displayed on list:
{
xtype: 'list',
itemId: 'catList',
scrollable: false,
data: [
{ category_name: 'A', cat_id: 1},
{ category_name: 'B', cat_id: 2},
{ category_name: 'C', cat_id: 3},
{ category_name: 'D', cat_id: 4},
{ category_name: 'E', cat_id: 5},
],
loadingText: "Loading Words...",
emptyText: '<div>{message}</div>',
autoLoad:true,
itemTpl:[
'<tpl for=".">',
'<span >{category_name}</span> ',
'</tpl>',
]
},
Here, I tap many times on different row but only gets index 0, why is this? why am i not getting different index value while tapping different row of list item;
My JSON
I tried and working perfectly for me, Let me share what i did.
Model
Ext.define('Myapp.model.Category', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'cat_id', type: 'integer' },
{ name: 'category_name', type: 'string' },
{ name: 'created_date', type: 'string' },
{ name: 'order', type: 'integer' },
{ name: 'status', type: 'integer' },
{ name: 'deleted', type: 'integer' },
{ name: 'type', type: 'integer' }
]
}
});
Store
Ext.define('Myapp.store.Category', {
extend: 'Ext.data.Store',
requires: [
'Myapp.model.Category'
],
config: {
storeId: 'category',
model: "Myapp.model.Category",
proxy: {
type: "ajax",
url : "http://alucio.com.np/trunk/dev/sillydic/admin/api/word/categories/SDSILLYTOKEN/650773253e7f157a93c53d47a866204dedc7c363?_dc=1376475408437&page=1&start=0&limit=25",
reader: {
type: "json",
rootProperty: "data"
}
},
autoLoad: true
}
});
List
{
xtype: 'list',
itemId: 'catList',
store: Ext.create('Myapp.store.Category'),
layout: 'fit',
itemHeight: 20,
itemTpl: [
'<div>',
'{category_name}',
'</div>'],
listeners: {
itemtap: function(list, index, target, record, e, eOpts){
console.log(record.get('cat_id'));
}
}
}
Output
As you can see itemtap function also printing correct cat_id
UPDATE
Based on your comment
{
xtype :'panel',
items : [{
xtype : 'toolbar',
itemId: 'categoryName' // Give itemId
},
{
xtype: 'list',
itemId: 'catList',
height : '100%',
store: Ext.create('GoodNews.store.Category'),
layout: 'fit',
itemHeight: 20,
itemTpl: [
'<div>',
'{category_name}',
'</div>'],
listeners: {
itemtap: function(list, index, target, record, e, eOpts){
var catId = record.get('cat_id');
var categoryName = record.get('category_name');
// Set the title like this
this.getParent().getComponent('categoryName').setTitle(categoryName);
}
}
}]
}
I don't really know what's wrong with your code as I tested it and it worked fine. However, a few things are wrong.
You do not need the for loop in your itemTpl as "itemTpl" is already
iterating in you data array for you. You would need it if you were
using just "tpl".
Avoid to have your listeners in your view. Instead,
get a reference to your list in your controller, and set the
listeners there. This is bad practise and it breaks the NVC pattern.
Here is a small version that works on my te4st application:
{
xtype: 'list',
itemId: 'catList',
scrollable: false,
data: [
{ category_name: 'A', cat_id: 1},
{ category_name: 'B', cat_id: 2},
{ category_name: 'C', cat_id: 3},
{ category_name: 'D', cat_id: 4},
{ category_name: 'E', cat_id: 5},
],
loadingText: "Loading Words...",
emptyText: '<div>{message}</div>',
autoLoad:true,
itemTpl: '{category_name}',
listeners: {
'itemtap': function(list, index, target, record, e, eOpts){
//TODO: whatever..
}
}
}

Change form panel title sencha touch

I need to change my title inside a formpanel
Here is my code
view.js
Ext.define('bluebutton.view.BlueButton.Loyalty', {
extend: 'Ext.Container',
xtype: 'loyaltycard',
requires: [
'bluebutton.view.BlueButton.TransactionList',
'bluebutton.view.BlueButton.MemberPopUp',
'bluebutton.view.BlueButton.MemberDetail',
'bluebutton.view.BlueButton.CouponMain',
'bluebutton.store.BlueButton.MemberList',
'bluebutton.store.BlueButton.CouponList',
'Ext.ux.keypad.Keypad',
'Ext.Img',
'Ext.carousel.Carousel'
],
config: {
// iconCls: 'add_black',
// title :'Loyalty Point',
styleHtmlContent: true,
cls: 'styledContent',
//
layout: 'hbox',
border: 3,
ui: 'round',
defaults: {
margin : '10 10 10 10',
padding : 10
},
items :[
{
flex: 1,
xtype :'formpanel',
id:'loyaltyform',
items :[
{
xtype: 'fieldset',
cls :'containerRadious' ,
title: 'Welcome, new member ~<i><u>Kenny</u></i>',
defaults: {
labelWidth: '35%',
style: 'font-size:1.0em'
},
items: [
{
xtype: 'image',
src: 'resources/images/user3.png',
height: 100,
margin:20
},
{
xtype: 'textfield',
name : 'Name',
label: 'Name',
value :'Kenny Chow',
readOnly: true
},
{
xtype: 'textfield',
name : 'Age',
label: 'Age',
value :'20',
readOnly: true
},
{
xtype: 'textfield',
name : 'Point',
label: 'Point Available',
value :'50',
id :'point',
readOnly: true
},
{
xtype: 'textfield',
name : 'lastVisited',
label: 'Last Visited',
id :'lastVisited',
value :'27/12/2012 11:53 AM',
readOnly: true
},
{
xtype:'button',
text: 'Scan',
width : '100%',
id: 'btnScan',
},
]
}
]
},
{
flex: 2,
xtype :'carousel',
cls :'containerRadious' ,
items :[
{
xtype :'keypad',
layout: {
type: 'hbox',
pack: 'center'
},
},
{
xtype:'couponlistcard'
}
]
}
],
}
});
Controller
onbtnAddClick: function (e) {
var loyaltyform = Ext.getCmp('loyaltyform');
var pointAvalaible = Ext.getCmp('point').getValue();
var keyPadValue = Ext.getCmp('keypad_value').getValue();
var consumerID = Ext.getCmp('keypad_value').getValue();
Ext.getCmp('loyaltyform').setTitle('Changed Title');;
}
but i get this error.
**Uncaught TypeError: Object [object Object] has no method 'setTitle'**
Anyone face this problem before? please help
The reason you get the error is because a formpanel has no method setTitle(). To change the title you have to call the setTitle() method of your fieldset, which is inside your formpanel. So give you fieldset an ID and use this:
Ext.getCmp('yourFieldsetID').setTitle('Changed Title');
Check the methods you can use for a panel en fieldset in the Sencha docs:
http://docs.sencha.com/touch/2-1/#!/api/Ext.form.Panel
http://docs.sencha.com/touch/2-1/#!/api/Ext.form.FieldSet
Good luck!

Sencha Touch 2 add two list vertically?

I want to have a panel with two lists vertically shown.
The below code :
Ext.define('CD.abc.Profile', {
extend: 'Ext.Panel',
layout: 'fit',
fullscreen: true,
config: {
layout: 'vbox',
items: [
{
xtype: 'mylist1'
},
{
xtype: 'mylist2'
}
]
}
});
But the item dont show, page is appearing blank. I can find the elements in the dom structure but they remain invisible in the view.
Can any one help me regarding this?
Try this. Its working for me.
Ext.define('CD.abc.Profile', {
extend: 'Ext.Panel',
config: {
layout:'vbox',
items: [
{
xtype: 'mylist1', // x-type of your list1 view
flex:1
},
{
xtype: 'mylist2', // x-type of your list2 view
flex:1
}
]
}
});
pass the flex property as 1
flex: 1
Try this work's for me:
Ext.define('Sencha.view.Blog', {
extend: 'Ext.Panel',
xtype:'blogpage',
config:{
layout:'fit',
width:'100%',
height:'100%',
title: 'Blog',
iconCls: 'star',
style:'background-color: red;',
items:[
{
xtype:'list',
id:'thelist',
style:'background-color: blue;',
height:'100%', width:'20%',left:0,
store: {
fields: ['name', 'number'],
sorters: 'name',
data: [
{name: 'Shawshank Redemption', number: 5},
{name: 'SuperBad', number: 3},
{name: 'God Father', number: 5},
{name: 'Forest Gump', number: 4.5},
{name: 'A Beautiful Mind', number: 5},
]
},
itemTpl: '{name}'
},
{
xtype:'list',
id:'thelist1',
style:'background-color: blue;',
height:'100%', width:'20%',right:0,
store: {
fields: ['name', 'number'],
sorters: 'name',
data: [
{name: 'Shawshank Redemption', number: 5},
{name: 'SuperBad', number: 3},
{name: 'God Father', number: 5},
{name: 'Forest Gump', number: 4.5},
{name: 'A Beautiful Mind', number: 5},
]
},
itemTpl: '{name}'
}
]
}});

Extjs 4 portlet on load collapsed not working properly

I am using ExtJS portal code in my application
I want to make portlet in collapsed state at the time of loading the page. So I have done something like
items: [{
id: 'portlet-1',
title: 'Grid Portlet Texsds',
tools: this.getTools(),
height:200,
**collapsed:true,**
autoScroll :true,
items: Ext.create('Ext.app.GridPortlet'),
listeners: {
'close': Ext.bind(this.onPortletClose, this),
'endDrag': Ext.bind(this.onPortletDrag, this),
'resize' :Ext.bind(this.onPortletResize, this)
}
}
I have made collapsed property to true. But because of this when I am trying to expand the portlet [after page load] I can see blank Grid.Plz. refer the attached image.
What is the problem ? do I need to do refresh or something ? because when I set collapsed to false I can see the grid.
Please suggest what is missing here.
This is a code for the getTools: function(){
{
type: 'Minimize',
handler: function(e,target,panelHeader,tool){
//panelHeader.ownerCt.toggleCollapse();
if (panelHeader.ownerCt.collapsed)
{
panelHeader.ownerCt.expand();
}
else {
panelHeader.ownerCt.collapse();
}
}
}
for the first time when the portlet get load it is in collapsed state, Now when I click on cross icon not [the "^" for expand icons ] I can see the Blank grid.
Hope this time I am able to explain well.
I took the Ext JS 4 example portal app and added your code (without the asterisks) to portlet-1. It is properly collapsed on load and expands to show the grid.
I don't think there is anything wrong with the code you've posted. Perhaps you've changed the layout or layout properties of the surrounding container and that is affecting your portlet.
Here is my complete portal.js:
Ext.define('Ext.app.Portal', {
extend: 'Ext.container.Viewport',
//requires: [ 'Ext.diag.layout.ContextItem', 'Ext.diag.layout.Context' ],
uses: ['Ext.app.PortalPanel', 'Ext.app.PortalColumn', 'Ext.app.GridPortlet', 'Ext.app.ChartPortlet'],
getTools: function(){
return [{
xtype: 'tool',
type: 'gear',
handler: function(e, target, panelHeader, tool){
var portlet = panelHeader.ownerCt;
portlet.setLoading('Loading...');
Ext.defer(function() {
portlet.setLoading(false);
}, 2000);
}
}];
},
initComponent: function(){
var content = '<div class="portlet-content">'+Ext.example.shortBogusMarkup+'</div>';
Ext.apply(this, {
id: 'app-viewport',
layout: {
type: 'border',
padding: '0 5 5 5' // pad the layout from the window edges
},
items: [{
id: 'app-header',
xtype: 'box',
region: 'north',
height: 40,
html: 'Ext Portal'
},{
xtype: 'container',
region: 'center',
layout: 'border',
items: [{
id: 'app-options',
title: 'Options',
region: 'west',
animCollapse: true,
width: 200,
minWidth: 150,
maxWidth: 400,
split: true,
collapsible: true,
layout:{
type: 'accordion',
animate: true
},
items: [{
html: content,
title:'Navigation',
autoScroll: true,
border: false,
iconCls: 'nav'
},{
title:'Settings',
html: content,
border: false,
autoScroll: true,
iconCls: 'settings'
}]
},{
id: 'app-portal',
xtype: 'portalpanel',
region: 'center',
items: [{
id: 'col-1',
items: [{
id: 'portlet-1',
title: 'Grid Portlet',
tools: this.getTools(),
collapsed: true,
height: 200,
autoscroll: true,
items: Ext.create('Ext.app.GridPortlet'),
listeners: {
'close': Ext.bind(this.onPortletClose, this)
}
},{
id: 'portlet-2',
title: 'Portlet 2',
tools: this.getTools(),
html: content,
listeners: {
'close': Ext.bind(this.onPortletClose, this)
}
}]
},{
id: 'col-2',
items: [{
id: 'portlet-3',
title: 'Portlet 3',
tools: this.getTools(),
html: '<div class="portlet-content">'+Ext.example.bogusMarkup+'</div>',
listeners: {
'close': Ext.bind(this.onPortletClose, this)
}
}]
},{
id: 'col-3',
items: [{
id: 'portlet-4',
title: 'Stock Portlet',
tools: this.getTools(),
items: Ext.create('Ext.app.ChartPortlet'),
listeners: {
'close': Ext.bind(this.onPortletClose, this)
}
}]
}]
}]
}]
});
this.callParent(arguments);
},
onPortletClose: function(portlet) {
this.showMsg('"' + portlet.title + '" was removed');
},
showMsg: function(msg) {
var el = Ext.get('app-msg'),
msgId = Ext.id();
this.msgId = msgId;
el.update(msg).show();
Ext.defer(this.clearMsg, 3000, this, [msgId]);
},
clearMsg: function(msgId) {
if (msgId === this.msgId) {
Ext.get('app-msg').hide();
}
}
});