I am unable to render google pie chart in my border layout of the interface. Though the pie chart works fine on separate html page.
The div is as follows:
The javascript code looks like this:
{
title: 'View Interactive Reports',
ContentEl: "pChartMap",
plain: true,
bodyStyle: 'padding:5px',
border: false,
autoScroll: true
}
I am not sure about the ContentEl thing. It works fine, if there is simple text there but since the google chart is based on google visualisation api and an AJAX call where there is a function call as:
google.setOnLoadCallback(createChart);
Any ideas how to render this will be appreciated.
Cheers
Ali
Have you check this? http://www.sencha.com/blog/2008/10/13/google-visualization/
Sadly the example page is broken, but is just because the sencha site has not the 2.2 source of ExtJS anymore; or at least not there where the sample expect it; but if you download the page and use ExtJS 2.3.0 it will work.
Anyway, you only need to download this js: http://dev.sencha.com/playpen/google-visualization/GVisualizationPanel.js
And then just use the Ext.ux.GVisualizationPanel. Here is an example I tested:
Ext.onReady(function() {
var lineChartDs = new Ext.data.SimpleStore({
fields: [
{name: 'yr', type: 'string'}
,{name: 'sales', type: 'int'}
,{name: 'expenses', type: 'int'}
],
data: [['2004',1000,400],['2005',1170,460],['2006',860,580],['2007',1030,540]]
});
var lineChart = new Ext.ux.GVisualizationPanel({
id: 'lineChart',
visualizationPkg: 'linechart',
title: 'Company Performance Sample',
store: lineChartDs,
columns: [
{dataIndex: 'yr', label: 'Year'}
,{dataIndex: 'sales', label: 'Sales'}
,{dataIndex: 'expenses', label: 'Expenses'}
]
})
new Ext.Viewport({
layout: 'fit',
items: [lineChart]
});
});
Related
I am new to EXTJS. I am developing application using EXTJS 4.2. I have grid that shows list of Unix server details. I have 2 JS one is serverdetails.js that shows all the servers in the grid and another one is pie.js that shows pie chart. My requirement is when I select server from the grid that is in ServerDetails.js and click on button it goes to dao layer to get server details, Now this server details I have to passed on to Pie chart Js Ext.data.Store object. How do I pass these server details to Pie chart JS?
Below is my code.
On the grid I have dashboard button that shows the pie chart for selected row in the grid. below is the code for that.
showDashBoard : function(button) {
var grid = Ext.ComponentQuery.query('serverdetailslist')[0];
var sm = grid.getSelectionModel();
var rs = sm.getSelection();
if (!rs.length) {
Ext.Msg.alert('Info', 'No Server Details Selected');
return;
}else{
dashBoardServerDetail = rs[0].getData();
var url = '/TechnologyTrackPortal/dashboard/loadDashBoard.action';
Ext.Ajax.request({
url : url,
method : 'POST',
jsonData: dashBoardServerDetail,
success: function(response){
var iResult = response.responseText;
Ext.create('resources.script.Pie');
}
});
}
}
response.responseText give me data in jason format. Now how do I pass this jason dat to pie.js file. Below is my pie.js file
Ext.onReady(function () {
Ext.define('DashBoardModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'title', type: 'string'},
{name: 'size', type: 'string'}
]
});
var store = Ext.create('Ext.data.Store', {
storeId : 'DashBoardStoreId',
model : 'DashBoardModel',
fields : ['title', 'size'],
autoLoad: false,
autoSync: true
});
var chart = Ext.create('Ext.chart.Chart', {
alias : 'widget.dashBoardPieChart',
title : 'Technology Portal',
store : store,
theme: 'Base:gradients',
legend: {
position: 'bottom'
},
series: [
{
type: 'pie',
angleField: 'size',
showInLegend: true,
label: {
field: 'title',
display: 'outside',
font: '12px Arial',
calloutLine: true
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'title',
display: 'rotate',
contrast: true,
font: '18px Arial'
},
tips: {
trackMouse: true,
width: 120,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('title') + ': ' + storeItem.get('size') + '%');
}
}
}
]
});
var panel1= Ext.create('widget.panel', {
// extend : 'widget.panel',
width: 800,
height: 600,
title: 'Server',
alias : 'widget.dashBoardForm',
renderTo: Ext.getBody(),
layout: 'fit',
tbar: [{
text: 'Save Chart',
handler: function() {
Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){
if(choice == 'yes'){
chart.save({
type: 'image/png'
});
}
});
}
}],
items: chart
});
I hope I am clear with my points.
Thanks
Sach
You need to see this as one app, one memoryspace, that the code is separated in two .js files makes not much difference, they both have to be loaded in your main html, asp, php or whatever. In that memoryspace you can reference each others variables and objects if they were declared before. The easiest way to accomplish what you ask is to have one store and use that for both views. So load the data in the store in your ServerDetails.js and have the chart use this same store.
I have some ExtJs apps that do that but they are for version 3.3.1 and not at my disposal for the moment. Hope this helps.
Så i have noticed a very annoying bug in Sencha Touch. When i try to add the paging plugin to my dataview the "load more" text is placed above the items, not below like i want it to. It works with the standard listview.
I found another thread asking me to add "inifinte:true" to my dataview, but that did not help. Nor did "bottom:0" or "docked:'bottom'" options. Here is my code:
{
xtype: 'dataview',
plugins: {
type: 'listpaging',
loadMoreText: 'Indlæs flere..',
autoPaging: true
},
flex: 1,
cls: 'inspectionImages',
itemId: 'imageContainer',
padding: 10,
style: 'background: #F7F7F7; color: black',
emptyText: 'Der er ingen billeder på synet.',
itemTpl: ['...'],
loadingText: 'Henter billeder..',
store: 'Images'
}
Also here is an example sencha fiddle code - framework is 2.4.x:
Ext.application({
launch: function () {
var touchTeam = Ext.create('Ext.DataView', {
fullscreen: true,
plugins: {
type: 'listpaging',
loadMoreText: 'Indlæs flere..',
autoPaging: true
},
store: {
fields: ['name', 'age'],
data: [{
name: 'Jamie',
age: 100
}, {
name: 'Rob',
age: 21
}, {
name: 'Tommy',
age: 24
}, {
name: 'Jacky',
age: 24
}, {
name: 'Ed',
age: 26
}]
},
itemTpl: '<div>{name} is {age} years old</div>'
});
touchTeam.getStore().add({
name: 'Abe Elias',
age: 33
});
touchTeam.getStore().getAt(0).set('age', 42);
} // launch
}); // application()
I have checked with the Ext.dataview.dataview in the sencha touch documentation, and this shows similar behaviour when adding the paging plugin so i know that this is probably not my own fault. I really would like the loadinText to be placed in the bottom of the dataview. Any suggestions would highly be appreciated!
The List Paging Plugin is Developed for Lists.
If you are using it for the DataView then The Load more Text Will appear at the Top.
I have faced the same Problem.I have Gone Through the List paging Plugin Js.
Then Got Solution By just Changing the Css Property..
Inspect the "loading-spinner" CLass and change the Style to: style="font-size: 180%; margin: 10px auto;position:absolute; bottom: 0px; left: 50%
and Inspect the Class -"list-paging-msg" And change the style to style="position:absolute; bottom: 0px; left: 50%;"
This is a bug in Sencha Touch. Mitchell Simoens has told here that it is meant for List only but I believe this should also support the dataview as it is light compared to list.
In sencha forum solutions , you can see they have changed the xtype from dataview to list. I also had same problem and I did the same. But you can do some addition if you want the look and feel of dataview instead of list.
disableSelection: true,
pressedCls: '',
I hope this helps you. Let me know if you need anything else.
I have found the solution after gone through the code of List paging Plugin, Ext.dataview.DataView and Ext.dataview.List.
Initialize list paging plugin after dataview initialized, then the "load more component" position will be right.
Ext.define('MyDataView', {
extend: 'Ext.dataview.DataView',
config: {
/* do not set here
plugins: [{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}, {
xclass: 'Ext.plugin.PullRefresh'
}]
*/
},
initialize: function() {
var me = this;
me.callParent();
// Initialize plugin here, so the listpaging component will append after dataview container
me.setPlugins([{
xclass: 'Ext.plugin.ListPaging',
autoPaging: true
}, {
xclass: 'Ext.plugin.PullRefresh'
}]);
}
}
As it turns out the pagingplugin were not meant for Dataview. It can be used though. In the end i ended up just manually moving the "load more" text in the DOM at the end of each load of the plugin. To ensure no listeners were lost i used the appendchild JS function and applying some custom css. Now everything works as expected.
I would like to have a small mp3 played every time a new panel is shown in the carousel. I used the audio xtype with autoplay but this results in an cacophony of sounds on startup. The problem occurs on all devices (simulators, Chrome, ipad and nexus7). Now, I use a button that activates the sound but I would like it to autoplay when it is needed (on active panel). It "sounds" so simple but I can't get it to work. Any help is appreciated.
This is one carousel item (with a button):
{
layout: {
type: 'vbox',
align: 'stretch',
},
items: [
{
flex:4,
xtype: 'image',
src: 'resources/images/hond.png',
},
{
xtype: 'button',
text: 'Play',
iconCls: 'arrow_right',
cls: 'knopsound',
handler: function() {
Ext.getCmp('hond').toggle();
this.setText(Ext.getCmp('hond').isPlaying() ? 'Pause' : 'Play');
}
},
{
xtype: 'audio',
url: 'resources/images/hond.mp3',
id: 'hond',
loop: false,
enableControls: false,
hidden:true
},
{
flex:3,
xtype: 'video',
url: 'resources/images/test.mp4',
posterUrl: 'resources/images/bekijkgebaar.png',
cls: 'videoplayknop',
autoResume: true,
autoPause: true,
enableControls: false,
}]},
You should leverage the activeitemchange(carousel, newItem, oldItem) event on the carousel to play the sound.
I would just store the url of the sound to play in a custom property of the panel. To do that you could extend Ext.Panel and add a custom property in configuration so you'd get getters and setters for that property. Or you could just have an array of sound urls and call the carousel's getActiveIndex() to play the right sound.
Once you got the url you would play it using a dummy hidden component:
Something like:
document.getElementById("dummy").innerHTML=
'<embed src="' + soundurl + '" hidden="true" autostart="true" loop="false" />';
Or if you are developing a native app using Cordova:
var media = new Media(url, onSuccess, onFailure);
media.play({ playAudioWhenScreenIsLocked : false });
I try to create treepicker but i can't done with that http://jsfiddle.net/UKFVd/
Here is my code
var Panel = Ext.create('Ext.panel.Panel', {
bodyPadding: 5,
width: 300,
height: 100,
title: 'Filters',
items: [ {
xtype: 'treepicker',
name: 'list_id',
fieldLabel: 'Task List',
labelWidth: 60,
displayField: 'text',
store: store
}],
renderTo: Ext.getBody()
});
i check error is TypeError: k is undefined How to working with treepicker thanks
You need to include:
Ext.ux.TreePicker
if you have not.
The code in the fiddle you posted is perfectly fine, however, on the left side under External Resources, add the full URL path to TreePicker.js, and try again, and it will work.
Here is a working fiddle rev: http://jsfiddle.net/UKFVd/6/
Tree picker is not an out of box component that ships with extjs, you have to add it to your web page as an additional resource.
here is a page showing examples:
http://extjs.dariofilkovic.com/
here is my tab's code containing the pie chart
{
xtype: 'container',
title: 'Chart',
iconCls: 'chart',
itemId: 'chart_Tab',
layout: {
type: 'fit'
},
items: [
{
xtype: 'polar',
autoDestroy: false,
colors: [
'#115fa6',
'#94ae0a',
'#a61120',
'#ff8809',
'#ffd13e',
'#a61187',
'#24ad9a',
'#7c7474',
'#a66111'
],
store: 'elementstore',
series: [
{
type: 'pie',
xField: 'numValue'
}
],
interactions: [
{
type: 'rotate'
}
]
}
]
},
Problem is, it does show anything, but does not crash either...
I checked my store is full of model to display.
Here is the output of this chart... All there is is the ''gpl sencha generated label'' no chart at all... so im guessing something is wrong but I cant put my finger on it, + there is absolutly NO working exemple of that from the sencha team...
Still not working would someone has anny idea on why?
Try changing
store: 'elementstore',
To
`store: elementstore,`,
Charts files are not included with the free version of Sencha Touch, nor in the trial version.
If you run it in a local sever (app.html) and not index.html, you won't see anything.