Show Title only on Top in EXT JS - extjs

I want to show the title on Top, here is the code for same and please see the output below:
Data is coming but it overwrites the title , so is there anyway to show title separately on to the top, can anybody help?
items: {
xtype: 'chart',
animate: true,
shadow: true,
store: store,
legend: {
position: 'top',
title: 'XYZ ....',
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('startPeriod') + 'to ' + storeItem.get('endPeriod'));
}
},
axes: [{
type: 'Numeric',
position: 'left',
fields: ['per01', 'per02'],
title: false,
grid: true,
roundToDecimal: false
},
{
title: 'XYZ...',
position: 'top',
type: 'Category',
position: 'Bottom',
fields: ['..'],
label: {
rotate: {
degrees: 270
}
}
}, ],
series: [{
//type: 'bar',
type: 'column',
axis: 'bottom',
gutter: 80,
xField: 'ou',
//title: periodStr1,
title: ['April-' + lastyear_graph1 + " to " + strMonth + "-" + selectedText_yr, 'April-' + year2 + " to " + strMonth + "-" + year3_graph1],
yField: ['per01', 'per02'],
stacked: false,
tips: {
trackMouse: true,
width: 65,
height: 28,
renderer: function(storeItem, item) {
this.setTitle(String(item.value[1]));
}
}
}]
}

If you are looking for a title for the chart, you should set the title config of the chart and not the title config of the series. Title config of series is the human-readable name of the series which displayed in the legend.
items: {
xtype: 'chart',
animate: true,
shadow: true,
title: 'My Chart Title', //Set title here
-------------------
-------------------
}

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}]);
},

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 HTML tags in a Chart Legend?

How can use HTML tags in a chart legend while using title to apply custom legend text?
If we apply something like this title:['Your<b>New</b><br />Label'] the tags are just written as plain text.
Ext.application({
name: 'Fiddle',
launch: function () {
var store = Ext.create('Ext.data.JsonStore', {
fields: ['name', 'data', 'data2'],
data: [{
'name': 'metric one',
'data': 10,
'data2': 2
}, {
'name': 'metric two',
'data': 27,
'data2': 5
}]
});
Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
width: 500,
height: 300,
animate: true,
store: store,
legend: {
position: 'right'
},
axes: [{
type: 'Numeric',
position: 'left',
fields: ['data', 'data2'],
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
title: 'Sample Values',
grid: true,
minimum: 0
}, {
type: 'Category',
position: 'bottom',
fields: ['name'],
title: 'Sample Metrics'
}],
series: [{
type: 'column',
axis: 'left',
highlight: true,
stacked: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function (storeItem, item) {
this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') + ' $');
}
},
label: {
display: 'insideEnd',
'text-anchor': 'middle',
field: 'data',
renderer: Ext.util.Format.numberRenderer('0'),
orientation: 'vertical',
color: '#333'
},
xField: 'name',
yField: ['data', 'data2'],
title: ['Your<b>New</b><br />Label']
}]
});
}
});

ExtJS Graph not rendering inside panel

Graph:
var chart = Ext.create('Ext.chart.Chart', {
style: 'background:#fff',
animate: true,
shadow: true,
store: store1,
axes: [{
type: 'Numeric',
position: 'left',
fields: ['data1'],
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
title: 'Number of Hits',
grid: true,
minimum: 0
}, {
type: 'Category',
position: 'bottom',
fields: ['name'],
title: 'Month of the Year'
}],
series: [{
type: 'column',
axis: 'left',
highlight: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' $');
}
},
label: {
display: 'insideEnd',
'text-anchor': 'middle',
field: 'data1',
renderer: Ext.util.Format.numberRenderer('0'),
orientation: 'vertical',
color: '#333'
},
xField: 'name',
yField: 'data1'
}]
});
this not working.
{
xtype : 'panel',
layout : {
type : 'hbox',
pack : 'center'
},
id:'graphpanel',
width : 940,
margin : '20 0 20 0',
border : 0,
items: chart
}
this working.
var win = Ext.create('Ext.window.Window', {
width: 800,
height: 600,
minHeight: 400,
minWidth: 550,
hidden: false,
maximizable: true,
title: 'Bar Chart',
autoShow: true,
layout: 'fit',
items: chart
});
here is my problem graph working fine in popup window but not in panel. if i popup window first then only graph is rendering in panel.
pl'z help sorry for bad code formatting..:(
You're not providing the chart with dimensions, either explicitly (giving it a width and height) or implicitly (by using an appropriate layout).
The panel layout should be fit. Also, be sure whatever is the parent of that panel is giving it a height.

Ext chart autosize

I'm trying to make a chart(ext 4.1):
var chart = Ext.create('Ext.chart.Chart', {
width: 280,
height: 230,
animate: true,
autoSize: true,
shadow: true,
store: storeChart2,
renderTo: 'chart2',
legend: {
//position: 'right'
},
theme: 'Base:gradients',
series: [{
type: 'pie',
field: 'data',
showInLegend: false,
highlight: {
segment: {
margin: 20
}
},
tips: {
trackMouse: true,
width: 100,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('name') + ': ' + Math.round(all * storeItem.get('data') / 100) +' ('+ Math.round(storeItem.get('data') / 100 * 100) + '%)');
}
},
label: {
field: 'name',
display: 'rotate',
contrast: true,
font: '12px Arial'
}
}]
});
AutoSize: true, - don't work. In Chrome console:
Error: Invalid value for <svg> attribute width="-Infinity"
Error: Invalid value for <svg> attribute height="-Infinity"
What's wrong?
Try to add a property,
minimum: 0
Please refer this post

Resources