Skip to content

Instantly share code, notes, and snippets.

@hbqy90
Created March 29, 2015 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbqy90/255855f2beb2602f5df3 to your computer and use it in GitHub Desktop.
Save hbqy90/255855f2beb2602f5df3 to your computer and use it in GitHub Desktop.
demo_chart with netzke
{
// a demo from http://dev.sencha.com/ext/5.1.0/examples/charts-kitchensink/#basic-column
initComponent: function() {
var me = this;
this.myDataStore = Ext.create('Ext.data.JsonStore', {
fields: ['month', 'data1' ],
data: [
{ month: 'Jan', data1: 20 },
{ month: 'Feb', data1: 20 },
{ month: 'Mar', data1: 19 },
{ month: 'Apr', data1: 18 },
{ month: 'May', data1: 18 },
{ month: 'Jun', data1: 17 },
{ month: 'Jul', data1: 16 },
{ month: 'Aug', data1: 16 },
{ month: 'Sep', data1: 16 },
{ month: 'Oct', data1: 16 },
{ month: 'Nov', data1: 15 },
{ month: 'Dec', data1: 15 }
]
});
me.items = [{
xtype: 'chart',
width: '100%',
height: 410,
style: 'background: #fff',
padding: '10 0 0 0',
insetPadding: 40,
animate: true,
shadow: false,
store: this.myDataStore,
items: [{
type : 'text',
text : 'Column Charts - Basic Column',
font : '22px Helvetica',
width : 100,
height: 30,
x : 40, //the sprite x position
y : 12 //the sprite y position
}, {
type: 'text',
text: 'Data: Browser Stats 2012',
font: '10px Helvetica',
x: 12,
y: 380
}, {
type: 'text',
text: 'Source: http://www.w3schools.com/',
font: '10px Helvetica',
x: 12,
y: 390
}],
axes: [{
type: 'Numeric',
position: 'left',
fields: ['data1'],
label: {
renderer: function(v) { return v + '%'; }
},
grid: true,
minimum: 0
}, {
type: 'Category',
position: 'bottom',
fields: ['month'],
grid: true,
label: {
rotate: {
degrees: -45
}
}
}],
series: [{
type: 'column',
axis: 'left',
xField: 'month',
yField: 'data1',
style: {
opacity: 0.80
},
highlight: {
fill: '#000',
'stroke-width': 20,
stroke: '#fff'
},
tips: {
trackMouse: true,
style: 'background: #FFF',
height: 20,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('month') + ': ' + storeItem.get('data1') + '%');
}
}
}]
}];
Netzke.classes.DemoChart.superclass.initComponent.call(this);
}
}
class DemoChart < Netzke::Base
include Netzke::Basepack::DataAccessor
js_configure do |c|
c.mixin
c.title = "Simple Chart"
c.width = 800
c.height = 600
c.extend = 'Ext.chart.Chart'
end
end
@mxgrn
Copy link

mxgrn commented Mar 30, 2015

"Netzke.classes.DemoChart.superclass.initComponent.call(this);" ==> this.callParent()

@hbqy90
Copy link
Author

hbqy90 commented Mar 31, 2015

@mxgrn
console told following

Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:3000/netzke/components/Ext/chart/Chart.js?_dc=1427785210756

[E] [Ext.Loader] Some requested files failed to load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment