Ext Js ChartsKitchenSink.view.charts.pie.Basic - extjs

I'm using this pie chart example in this link to display a pie chart.
How do I set the pie chart dynamically and refresh the pie chart?

To dynamically create chart:-
var chart = Ext.create('Ext.chart.Chart', {
xtype: 'chart',
animate: true,
store: store1,
shadow: true,
legend: {
position: 'right'
},
insetPadding: 60,
theme: 'Base:gradients',
series: [{
type: 'pie',
field: 'data1',
showInLegend: true,
donut: donut,
tips: {
trackMouse: true,
renderer: function(storeItem, item) {
//calculate percentage.
var total = 0;
store1.each(function(rec) {
total += rec.get('data1');
});
this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data1') / total * 100) + '%');
}
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'name',
display: 'rotate',
contrast: true,
font: '18px Arial'
}
}]
});
To refresh the chart you can use store.loadData method.
Reference url

For loading dynamic data in pie char store you can use reload(),loadData() and load() methods of store.
store.reload() example
store.reload({
params : {
userid : 1234
}
});
store.load() example
store.load({
scope: this,
callback: function(records, operation, success) {
// the Ext.data.operation.Operation object
// contains all of the details of the load operation
console.log(records);
}
});
If the callback scope does not need to be set, a function can simply be passed:
store.load(function(records, operation, success) {
console.log('loaded records');
});
store.loadData() example
var data= [{
os: 'Android',
data1: 68.3
},{
os: 'Others',
data1: 1.9
}];
store.loadData(data);
In this FIDDLE, I have created a demo. Hope this will help/guide you to achieve your requirement.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
/**
* Returns a random integer between min (inclusive) and max (inclusive)
* Using Math.round() will give you a non-uniform distribution!
*/
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function createDyanmicData(store) {
store.each(rec => {
rec.set('data1', getRandomInt(20, 100));
});
}
Ext.create({
xtype: 'polar',
tbar: ['->', {
text: 'Refresh Chart',
height: 35,
padding: 5,
margin:'0 10',
style: {
background: 'green'
},
handler: function () {
createDyanmicData(this.up('polar').getStore())
}
}],
title: 'Pie Chart Example',
renderTo: Ext.getBody(),
width: '100%',
height: window.innerHeight,
interactions: 'rotate',
store: {
fields: ['os', 'data1'],
data: [{
os: 'Android',
data1: 68.3
}, {
os: 'iOS',
data1: 17.9
}, {
os: 'Windows Phone',
data1: 10.2
}, {
os: 'BlackBerry',
data1: 1.7
}, {
os: 'Others',
data1: 1.9
}]
},
series: {
type: 'pie',
xField: 'data1',
label: {
field: 'os',
display: 'inside',
calloutLine: true
},
showInLegend: true,
highlight: true,
highlightCfg: {
fill: '#ccc',
'stroke-width': 10,
stroke: '#fff'
},
tips: {
trackMouse: true,
renderer: function (storeItem, item) {
this.setTitle(storeItem.get('os') + ': ' + storeItem.get('data1') + '%');
}
}
}
});
}
});

Related

Cannot bind filters on Ext.chart.CartesianChart

I am new to Ext JS working on Sencha 6.5(Ext js 6.2), while running my code I am getting error as :
Ext.mixin.Bindable.applyBind(): Cannot bind filters on Ext.chart.CartesianChart - missing a setFilters method.
The chart in tab1 works fine. Further what I am trying to do is, binding the selection from combo box in tab2 to cartesian chart in next tab, I am getting the error. Can any one help please, Thanks in advance, my code is :
Store : 2FAData.js
Ext.define('LICApp.store.2FAData', {
extend: 'Ext.data.Store',
alias: 'store.2fa-data',
storeId: 'myStore',
requires: [
'Ext.data.reader.Xml'
],
autoLoad: false, // Set it to false
fields: ['name','cnt', 'zone'],
proxy: {
type: 'rest',
cors: 'true',
url : 'http://localhost:8080/UserManagement/rest/BiodataController/bio',
method: 'POST',
reader: {
type: 'xml',
record: 'biodata',
rootProperty: 'biodatas'
}
}
});
Basic.js
Ext.define('LICApp.view.charts.bar3d.Basic', {
extend: 'Ext.tab.Panel',
xtype: 'bar-basic-3d',
controller: 'bar-basic-3d',
requires: [
'Ext.chart.theme.Muted',
'LICApp.store.2FAData',
'LICApp.store.Chartdata'
],
//width: 1300,
layout: 'anchor',
defaults: { anchor: '-30' },
referenceHolder: true,
viewModel: true,
config: {
value: false
},
items: [{
xtype: 'cartesian',
title: 'Consolidated View',
reference: 'chart',
theme: 'Muted',
width: '100%',
height: 700,
legend: {
docked: 'right'
},
animation: Ext.isIE8 ? false : {
easing: 'backOut',
duration: 500
},
store: {type: 'chartdata',autoLoad:true},
insetPadding: 40,
flipXY: true,
axes: [{
type: 'numeric3d',
position: 'bottom',
grid: true,
minimum: 0,
//maximum: 100,
//majorTickSteps: 10,
renderer: 'onAxisLabelRender1'
}, {
type: 'category3d',
position: 'left',
grid: true
}],
series: [{
type: 'bar3d',
fullStack: false,
title: [ 'Concurrencia Enabled', 'eFeap Enabled', 'Authorised Users', 'Biometric Enrolled Users', 'Total Devices Issued', 'Total No. of Employees'],
xField: 'zone',
yField: [ 'data1', 'data2', 'data3', 'data4', 'data5', 'data6'],
axis: 'bottom',
stacked: false,
highlight: true,
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender1'
}
}],
sprites: [{
type: 'text',
text: '2FA Biometric Progress - Zonewise comparison',
fontSize: 22,
width: 100,
height: 30,
x: 450, // the sprite x position
y: 20 // the sprite y position
},
{
type: 'text',
text: 'Source: 2FA Data Server',
fontSize: 10,
x: 12,
y: 695
}]
},
{
xtype: 'combobox',
title : 'Zone Selection',
reference: 'zone',
fieldLabel: 'Choose Zone',
store: {
type: 'chartdata',autoLoad:true
},
valueField: 'zone',
displayField: 'zone',
publishes: 'value',
typeAhead: true,
queryMode: 'local',
triggerAction: 'all',
emptyText: 'Select a Zone...',
selectOnFocus: true,
//width: 300,
indent: true,
renderTo: Ext.getBody(),
listeners: {
select: 'onZoneSelected'
}
},
{
xtype: 'cartesian',
itemId: 'zchart',
title: 'Zonewise View',
flipXY: true,
reference: 'chart',
width: '100%',
height: 500,
insetPadding: '40 40 30 40',
innerPadding: '3 0 0 0',
theme: {
type: 'muted'
},
store: {
type: '2fa-data', autoLoad :true
},
bind: {
visible: '{zone.value}',
filters: {
property: 'zone',
value: '{zone.value}'
}
},
animation: {
easing: 'easeOut',
duration: 500
},
interactions: ['itemhighlight'],
axes: [{
type: 'numeric3d',
renderer: 'onAxisLabelRender',
title: 'Number of Employees',
grid: {
odd: {
fillStyle: 'rgba(245, 245, 245, 1.0)'
},
even: {
fillStyle: 'rgba(255, 255, 255, 1.0)'
}
}
}, {
type: 'category3d',
position: 'left',
label: {
textAlign: 'right'
},
grid: true
}],
series: [{
type: 'bar3d',
xField: 'name',
yField: 'cnt',
style: {
minGapWidth: 10
},
highlight: true,
label: {
field: 'cnt',
display: 'insideEnd',
renderer: 'onSeriesLabelRender'
},
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender'
}
}],
sprites: [{
type: 'text',
text: '2FA Biometric - Zonewise Progress Chart',
fontSize: 22,
width: 100,
height: 30,
x: 40, // the sprite x position
y: 20 // the sprite y position
}, {
type: 'text',
text: 'Source: 2FA Data Server',
fontSize: 10,
x: 12,
y: 490
}]
}
]
});
BasicController.js
Ext.define('LICApp.view.charts.bar3d.BasicController', {
extend: 'Ext.app.ViewController',
alias: 'controller.bar-basic-3d',
onAxisLabelRender: function (axis, label, layoutContext) {
return Ext.util.Format.number(layoutContext.renderer(label) );
},
onSeriesLabelRender: function (v) {
return Ext.util.Format.number(v);
},
onSeriesTooltipRender: function (tooltip, record, item) {
var formatString = '0,000 ';
tooltip.setHtml(record.get('name') + ': ' +
Ext.util.Format.number(record.get('cnt'), formatString));
},
onPreview: function () {
if (Ext.isIE8) {
Ext.Msg.alert('Unsupported Operation', 'This operation requires a newer version of Internet Explorer.');
return;
}
var chart = this.lookupReference('chart');
chart.preview();
},
onItemSelected: function (sender, record) {
var zone = sender.getValue();
Ext.toast('You selected : ' + zone);
var store = Ext.getStore('myStore');
Ext.Ajax.request({
url: 'http://localhost:8080/UserManagement/rest/BiodataController/bio?zone='+zone,
timeout: 60000,
method: 'GET',
scope: this,
reader: {
type: 'xml',
record: 'biodata',
rootProperty: 'biodatas'
},
success: function(resp, request) {
var data = console.log(resp.responseText);
var myView = Ext.getCmp('zchart');
Ext.MessageBox.alert('Success', 'Data return from the server: '+ resp.responseText);
store.reLoad();//reload will be called, when AJAX call is successful.
/*
if ( window.DOMParser ) { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString( resp.responseText , "text/xml" );
} else { // IE
xml = new ActiveXObject( "Microsoft.XMLDOM" );
xml.async = "false";
xml.loadXML( resp.responseText );
}
*/
autoLoad:true;
//store.load(resp.responseText);
//console.log(myView);
//store.setData(resp.responseText);
},
failure: function(resp, opts) {
},
callback: function(options, success, resp) {
}
});
},
onCombo1Selected: function (sender, record) {
var zone = sender.getValue();
Ext.toast('You selected : ' + zone );
},
onCombo2Selected: function (sender, record) {
var divn = sender.getValue();
Ext.toast('You selected : ' + divn + '-' + record.get('donm'));
},
onCombo3Selected: function (sender, record) {
var bran = sender.getValue();
Ext.toast('You selected : ' + record.get('bran'));
},
onZoneSelected: function (sender, record) {
var zone = sender.getValue();
Ext.toast('You selected : ' + zone );
},
// Controller entries for stacked bar
onAxisLabelRender1: function (axis, label, layoutContext) {
// Custom renderer overrides the native axis label renderer.
// Since we don't want to do anything fancy with the value
// ourselves except appending a '%' sign, but at the same time
// don't want to loose the formatting done by the native renderer,
// we let the native renderer process the value first.
return layoutContext.renderer(label) ;
},
onSeriesTooltipRender1: function (tooltip, record, item) {
var fieldIndex = Ext.Array.indexOf(item.series.getYField(), item.field),
zone = item.series.getTitle()[fieldIndex];
tooltip.setHtml(zone + ' of ' + record.get('zone') + ': ' +
record.get(item.field) + ' out of ' + record.get('data6') + ' Total');
},
onColumnRender1: function (v) {
return v ;
}
// Ends here
});
This won't work the way you want it to.
The Cartesian Graph doesn't have it's own filtering mechanism and thus you can't trigger the filter via data binding. (Correct me if I'm wrong, but as far as I know, you can't set child elements' properties such as the store's filter property via data-binding)
You'll have to take the oldschool route and set the filters by hand in the ComboBox's Listener like this:
onZoneSelected: function (sender, record) {
var zone = sender.getValue();
Ext.toast('You selected : ' + zone );
var zchart = sender.up().getComponent('#zchart');
zchart.store.setFilters([{property: 'zone', value: zone}]);
},

HIghcharts - chart width not the size of the parent container

I am trying to figure out why I have that chart wider than the container. I noticed that if I remove the width completely for the first screenshot and then set width: 100% in the next. However, I am not able to force this styles and I think this is not the right way to go.
Here are the settings of my chart. Apart from that, I do not use any other css.
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container10',
type: 'line',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
spacingRight: 5,
height: 370,
width: 770
},
title: {
text: 'Database volume'
},
colors:['#229369', '#00526F'],
xAxis: {
categories: catValues
},
yAxis: [{
title: {
text: 'Table size in MB'
},
labels: {
style: {
color: '#229369'
}
}
},
{
title: {
text: 'Index size in MB'
},
labels: {
style: {
color: '#00526F'
}
},
opposite: true
}],
tooltip: {
valueSuffix: ' MB'
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [{
name: 'Table',
data: series1,
}, {
name: 'Index',
yAxis: 1,
data: series2
}]
});
I am not sure if this is the correct way of fixing that, but seems to work. I set the width of the container of the chart directive.
.chart-wrapper {
width: 99%;
}
Then in the directive code onDataLoaded or windowResized I call this:
function resize() {
height = chart.height;
width = $(".chart-wrapper").width();
chart.setSize(width, height, doAnimation = false);
}

i try to do the Spie example in Ext JS 5 but it didnt work

Here is my code i dont know why it didnt work ..the error in the console is
[W] [Ext.Loader] Synchronously loading 'widget.polar'; consider adding Ext.require('widget.polar') above Ext.onReady Util.js?_dc=1404383474396:692
GET http://localhost/widget/polar.js?_dc=1404383480019 404 (Not Found) bootstrap.js:558
Uncaught Error: [Ext.create] Unrecognized class name / alias: widget.polar ClassManager.js?_dc=1404383474396:1405
[E] [Ext.Loader] Some requested files failed to load. Util.js?_dc=1404383474396:692
Object
Util.js?_dc=1404383474396:698
console.trace() Util.js?_dc=1404383474396:704
log Util.js?_dc=1404383474396:704
Ext.apply.raise Error.js?_dc=1404383474396:186
Ext.apply.onLoadFailure Loader.js?_dc=1404383474396:649
(anonymous function) bootstrap.js:728
Uncaught Error: [Ext.Loader] Some requested files failed to load. Error.js?_dc=1404383474396:103
im just trying to create an Spie like in the example :http://dev.sencha.com/ext/5.0.0/examples/kitchensink/?charts=true#pie-custom
Ext.define('App.view.main.Main', {
extend: 'Ext.container.Container',
requires: 'App.view.main.TabPanel',
xtype: 'app-main',
controller: 'main',
viewModel: {
type: 'main'
},
layout: {
type: 'border'
},
items: [
{
region: 'center',
xtype: 'customtabpanel'
}]
});
and input it into my TAB .... i dunno why didnt work
app/view/main/TabPanel.js
Ext.define('App.view.main.TabPanel', {
extend: 'Ext.tab.Panel',
xtype: 'customtabpanel',
requires:['App.view.main.Pie'],
ui: 'navigation',
tabPosition: 'left',
tabRotation: 0,
tabBar: {
border: false
},
items: [{
title: 'Active Tab 1',
html: 'Active Link One',
xtype: 'pie-custom',
}, {
title: 'Active Tab 2',
html: 'Active Link Two'
}, {
title: 'Active Tab 3',
html: 'Active Link Three'
}, {
title: 'Active Tab 4',
html: 'Active Link Four'
}]
});
app/view/main/Pie.js
Ext.define('App.view.main.Pie', {
extend: 'Ext.Panel',
xtype: 'pie-custom',
// <example>
bodyStyle: 'background: transparent !important',
layout: {
type: 'vbox',
pack: 'center'
},
// </example>
width: 650,
initComponent: function() {
var me = this;
//<example>
me.tbar = [
'->',
{
text: 'Preview',
handler: function() {
me.down('polar').preview();
}
}
];
//</example>
me.items = [{
xtype: 'polar',
width: '100%',
height: 500,
store: {type: 'device-market-share'},
insetPadding: 30,
innerPadding: 20,
legend: {
docked: 'bottom'
},
interactions: ['rotate', 'itemhighlight'],
sprites: [{
type: 'text',
text: 'Pie Charts - Custom Slice Sizing',
font: '22px Helvetica',
width: 100,
height: 30,
x: 40, // the sprite x position
y: 20 // the sprite y position
}, {
type: 'text',
text: 'Data: IDC Predictions - 2017',
font: '10px Helvetica',
x: 12,
y: 425
}, {
type: 'text',
text: 'Source: Internet',
font: '10px Helvetica',
x: 12,
y: 435
}],
series: [{
type: 'pie',
animation: {easing: 'easeOut', duration: 500},
angleField: 'data1', // bind angle span to visits
lengthField: 'data2', // bind pie slice length to views
clockwise: false,
highlight: {
margin: 20
},
label: {
field: 'os', // bind label text to name
display: 'outside',
font: '14px Arial'
},
style: {
strokeStyle: 'white',
lineWidth: 1
},
tooltip: {
trackMouse: true,
renderer: function(storeItem, item) {
this.setHtml(storeItem.get('os') + ': ' + storeItem.get('data1') + '%');
}
}
}]
//<example>
}, {
style: 'padding-top: 10px;',
xtype: 'gridpanel',
columns : {
defaults: {
sortable: false,
menuDisabled: true
},
items: [
{ text: 'OS', dataIndex: 'os' },
{ text: 'Market Share', dataIndex: 'data1', width: 150, renderer: function(v) { return v + '%'; } },
{ text: 'Growth', dataIndex: 'data2', width: 150, renderer: function(v) { return v + '%'; } }
]
},
store: {type: 'device-market-share'},
width: '100%'
//</example>
}];
this.callParent();
}
});
can you help me out why is this error happen ???
Try to add "ext-charts" to "requires" section of your app.json in line 42

How to use SmartLegend on Sencha chart

I am researching how to use smart legend on sencha chart but legend not show multi columns
I am so stupid. Please help me .
Thank all
Nguyen
Ext.onReady(function () {
var panel, chart, legend,
store = Ext.create('Ext.data.Store', {
fields: [ 'name', 'data' ],
data: [
{ name: 'Field 0', data: Math.random() * 100 },
{ name: 'Field 1', data: Math.random() * 100 },
{ name: 'Field 2', data: Math.random() * 100 },
{ name: 'Field 3', data: Math.random() * 100 },
{ name: 'Field 4', data: Math.random() * 100 },
{ name: 'Field 5', data: Math.random() * 100 },
{ name: 'Field 6', data: Math.random() * 100 },
{ name: 'Field 7', data: Math.random() * 100 },
{ name: 'Field 8', data: Math.random() * 100 },
{ name: 'Field 9', data: Math.random() * 100 },
{ name: 'Field 10', data: Math.random() * 100 },
{ name: 'Field 11', data: Math.random() * 100 },
{ name: 'Field 12', data: Math.random() * 100 }
]
});
chart = Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
position: 'absolute',
id:'chart',
x: 100,
y: 100,
layout: 'fit',
width: 800,
height: 850,
animate: true,
store: store,
theme: 'Base:gradients',
animate: Ext.isIE ? false : true,
store: store,
shadow: Ext.isIE ? false : true,
legend: false,
series: [{
type: 'pie',
id : 'chart',
field: 'data',
showInLegend: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function(storeItem, item) {
// calculate and display percentage on hover
var total = 0;
store.each(function(rec) {
total += rec.get('data');
});
this.setTitle(storeItem.get('name') + ': ' + Math.round(storeItem.get('data') / total * 100) + '%');
}
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'name',
display: 'rotate',
contrast: true,
font: '18px Arial'
}
}]
});
//chart =this.down('chart'); //panel.down('chart');
legend = chart.legend = Ext.create('Ext.ux.chart.SmartLegend', {
position: 'right',
chart: chart,
rebuild: true,
boxStrokeWidth: 1
});
chart.legend.redraw();
chart.redraw();
});
Another alternative on sencha forums: ExtJS 4 chart legend sizing

Adding Pie Charts to Sencha Touch2 Application

I am trying to add pie chart to the existing sencha touch mvc application , pie chart displays fine if i place the chart related code in the app.js file , The problem i am facing is if place the chart in seperate view its not displaying , i dont see any errors also being triggered, Please can i know is their any different approach to integrate pie chart for different views?
This my sample code of the view where piechart code is written
Ext.define('Example.view.PieChartTest', {
extend: 'Ext.Panel',
xtype: "piecharttestpage",
requires: [
'Ext.chart.Panel',
'Ext.chart.axis.Numeric',
'Ext.chart.axis.Category',
'Ext.chart.series.Pie'
],
intit: function () {
//this.callParent(arguments);
window.initExample = function (title, helpText, defaultStore) {
defaultStore = defaultStore || 'store1';
window.generateData = function (n, floor) {
var data = [],
i;
floor = (!floor && floor !== 0) ? 20 : floor;
for (i = 0; i < (n || 12); i++) {
data.push({
name: Ext.Date.monthNames[i % 12],
data1: Math.floor(Math.max((Math.random() * 100), floor)),
data2: Math.floor(Math.max((Math.random() * 100), floor)),
data3: Math.floor(Math.max((Math.random() * 100), floor)),
2003: Math.floor(Math.max((Math.random() * 100), floor)),
2004: Math.floor(Math.max((Math.random() * 100), floor)),
2005: Math.floor(Math.max((Math.random() * 100), floor)),
2006: Math.floor(Math.max((Math.random() * 100), floor)),
2007: Math.floor(Math.max((Math.random() * 100), floor)),
2008: Math.floor(Math.max((Math.random() * 100), floor)),
2009: Math.floor(Math.max((Math.random() * 100), floor)),
2010: Math.floor(Math.max((Math.random() * 100), floor)),
iphone: Math.floor(Math.max((Math.random() * 100), floor)),
android: Math.floor(Math.max((Math.random() * 100), floor)),
ipad: Math.floor(Math.max((Math.random() * 100), floor))
});
}
return data;
};
window.store1 = new Ext.create('Ext.data.JsonStore', {
fields: ['name', '2004', '2005', '2006', '2007', '2008', '2009', '2010', 'iphone', 'android', 'ipad'],
data: generateData(5, 20)
});
window.store2 = new Ext.data.JsonStore({
fields: ['name', '2008', '2009', '2010', 'data4', 'data5', 'data6', 'data7', 'data8', 'data9'],
data: generateData(6, 20)
});
window.store3 = new Ext.data.JsonStore({
fields: ['name', '2007', '2008', '2009', '2010'],
data: generateData(12, 20)
});
var onRefreshTap = function () {
window[defaultStore].setData(generateData(window[defaultStore].data.length, 20));
};
var onHelpTap = function () {
window.helpPanel = window.helpPanel || Ext.create('Ext.Panel', {
ui: 'dark',
modal: true,
fullscreen: false,
hideOnMaskTap: true,
centered: true,
width: 300,
height: 250,
styleHtmlContent: true,
scrollable: 'vertical',
zIndex: 100,
items: [
{
docked: 'top',
xtype: 'toolbar',
title: title
},
{
html: helpText,
hidden: !helpText
}
]
});
window.helpPanel.show('pop');
};
window.createPanel = function (chart) {
return window.panel = Ext.create('Ext.chart.Panel', {
fullscreen: true,
title: title,
buttons: [
{
xtype: 'button',
iconCls: 'help',
iconMask: true,
ui: 'plain',
handler: onHelpTap
},
{
xtype: 'button',
iconCls: 'shuffle',
iconMask: true,
ui: 'plain',
handler: onRefreshTap
}
],
chart: chart
});
};
};
window.createPanel(new Ext.chart.Chart({
themeCls: 'pie1',
theme: 'Demo',
store: store1,
shadow: false,
animate: true,
insetPadding: 20,
legend: {
position: 'left'
},
interactions: [{
type: 'piegrouping',
listeners: {
selectionchange: function (interaction, selectedItems) {
var sum = 0,
i = selectedItems.length;
if (i) {
while (i--) {
sum += selectedItems[i].storeItem.get('visitors');
}
window.chartPanel.descriptionPanel.setTitle('Total visitors: ' + sum);
window.chartPanel.headerPanel.setActiveItem(1, { type: 'slide', direction: 'left' });
}
else {
window.chartPanel.headerPanel.setActiveItem(0, { type: 'slide', direction: 'right' });
}
}
}
}],
series: [
{
type: 'pie',
field: '2007',
showInLegend: true,
highlight: false,
listeners: {
'labelOverflow': function (label, item) {
item.useCallout = true;
}
},
// Example to return as soon as styling arrives for callouts
callouts: {
renderer: function (callout, storeItem) {
callout.label.setAttributes({
text: storeItem.get('name')
}, true);
},
filter: function () {
return false;
},
box: {
//no config here.
},
lines: {
'stroke-width': 2,
offsetFromViz: 20
},
label: {
font: 'italic 14px Arial'
},
styles: {
font: '14px Arial'
}
},
label: {
field: 'name'
}
}
]
}));
// this.add(chartpanel);
},
config: {
title: 'info',
iconCls: 'star',
scrollable: true,
cls: 'servicesclass',
layout: 'vbox',
height: 500,
width: 500,
autoDestroy: true
}
});
I know this issue you can fix it by converting things in variable. Try the code below in your view section and change the name of the app to your app
generateData = function(n) {
var data = [];
var names = ['one', 'two', 'three', 'four'];
var i;
for (i = 0; i < n; i++) {
data.push({description: names[i], value: 3 + i}); //pushes data onto the data array by looping, value is a funciton of i
}
return data;
};
var myStore = new Ext.create('Ext.data.Store', {
fields: ['description', 'value'],
data: generateData(4)
});
var chart1 = new Ext.create('Ext.chart.Chart', {
store: myStore, //the store that it will use
height: 480,
width: 320,
series: [{
type: 'pie',
showInLegend: true,
field: 'value',
label: { //the label inside each pie
field: 'description',
font: '20px Arial',
display: 'rotate',
contrast: true
},
}],
});
Ext.define('MyApp.view.panel1', {
extend: 'Ext.chart.Panel',
alias: 'widget.Panel1',
config:
{
chart: chart1 //displays the chart
}
});
Tut the name of this panel i.e Panel1 in the App.js file
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
views: [
'panel1',
],
name: 'MyApp',
controllers: [
'your controller name'
],
// include this one only if you have MainNav
launch: function() {
Ext.create('MyApp.view.MainNav', {fullscreen: true});
}
});
This one works for me.
first make sure that you're referencing the sencha touch library inside the sencha touch distribution, not the main sencha touch library you can download in your html.
secondly you'll save yourself a lot of headache if you use MVCS folders and learn how to use the new references in ST2 and it will make debugging this 1000 times easier.
also you are using globals (window.)??

Resources