/*! * Ext JS Library 3.0+ * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ Ext.chart.Chart.CHART_URL = '/ext-3.0.0/resources/charts.swf'; Ext.onReady(function(){ var store = new Ext.data.JsonStore({ fields: ['season', 'total'], data: [{ season: 'Summer', total: 150 },{ season: 'Fall', total: 245 },{ season: 'Winter', total: 117 },{ season: 'Spring', total: 184 }] }); /* new Ext.Panel({ width: 400, height: 400, title: 'Pie Chart with Legend - Favorite Season', renderTo: 'container', items: { store: store, xtype: 'piechart', dataField: 'total', categoryField: 'season', //extra styles get applied to the chart defaults extraStyle: { legend: { display: 'bottom', padding: 5, font: { family: 'Tahoma', size: 13 } } } } }); */ ip = 'http://10.2.226.20:9876' // new Ext.Panel({ // title:'Disk', // renderTo: 'disk', // width: 400, // height: 400, // items:[{ // id:"Glb_portal_a_certain_host_panel_ip_"+ip+"_disk_chart", // // url:'/ext-3.0.0/resources/charts.swf', // store: new Ext.data.Store({ // proxy: new Ext.data.HttpProxy({url: '/host/proc/df/?ip='+ip, method: 'GET'}), // reader: new Ext.data.JsonReader({ // root: "root", // fields: // [ // {name: 'type', mapping: 'type'}, // {name: 'count', mapping: 'count'} // ] // }) // }), // xtype: 'piechart', // dataField: 'count', // categoryField: 'type' // }] // }); // interval_fn = function(argument) { // load = Ext.getCmp("Glb_portal_a_certain_host_panel"+"_ip_"+ip+"_load_chart"); // Ext.Ajax.request({ // url: '/host/proc/loadavg/?ip='+ip, // // response.responseText => {value:6.3, time: 1253419592} // success: function(response){Glb.portal.insert_a_new_record_to_linechart(load,response.responseText)}, // failure: function(){Ext.Msg.alert('Attention!','Can\'t get load info from host:'+ip)} // }); // }; // "Glb_portal_a_certain_host_panel"+"_ip_"+'http://10.2.226.20:9876'+"_load_chart" new Ext.Panel({ xype:'panel', id:'panel_id', iconCls:'chart', title:'Load', renderTo: 'disk', width: 400, height: 400, items:[{ /*load line graph report*/ id:"Glb_portal_a_certain_host_panel"+"_ip_"+ip+"_load_chart", xtype: 'linechart', url:'/ext-3.0.0/resources/charts.swf', store: new Ext.data.JsonStore({ url: '', fields:['value', 'time'], data: [ {"value":0,"time":1254116592}, {"value":3,"time":1254116594}, {"value":2,"time":1254116595}, {"value":3.6,"time":1254116596}, {"value":7.1,"time":1254116597}, {"value":6.0,"time":1254116598}, {"value":3.2,"time":1254116599}, {"value":0,"time":1254116600} //{value:6.3, time: 1253419592} ] }), xField: 'time', yField: 'value', listeners: { itemclick: function(o){ var rec = store.getAt(o.index); Ext.Msg.alert('Item Selected', 'You get ' + rec.get('value')); } } }]}); var LineChartRecord = Ext.data.Record.create([ {name: 'value', type: 'int'}, {name: 'time', type: 'string'} ]); Glb.portal.insert_a_new_record_to_linechart = function(chart,record) { // record = {a:123,b:'hello'} // var PersonRecord = Ext.data.Record.create([ // {name: 'name', type: 'string'}, // {name: 'sex', type: 'int'} // ]); var store = chart.store; alert(store) var rec = new LineChartRecord(Ext.util.JSON.decode(record)); alert(rec) store.add(rec); // store.loadData(rec,true); // store.load(); return rec; }; });