3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
20 'Ext.layout.container.Column'
24 Ext.onReady(function(){
26 //use a renderer for values in the data view.
31 var bd = Ext.getBody(),
34 selectedStoreItem = false,
35 //performs the highlight of an item in the bar series
36 selectItem = function(storeItem) {
37 var name = storeItem.get('company'),
38 series = barChart.series.get(0),
41 series.highlight = true;
42 series.unHighlightItem();
43 series.cleanHighlights();
44 for (i = 0, items = series.items, l = items.length; i < l; i++) {
45 if (name == items[i].storeItem.get('company')) {
46 selectedStoreItem = items[i].storeItem;
47 series.highlightItem(items[i]);
51 series.highlight = false;
53 //updates a record modified via the form
54 updateRecord = function(rec) {
55 var name, series, i, l, items, json = [{
57 'Data': rec.get('price')
60 'Data': rec.get('revenue %')
63 'Data': rec.get('growth %')
66 'Data': rec.get('product %')
69 'Data': rec.get('market %')
74 createListeners = function() {
76 // buffer so we don't refire while the user is still typing
78 change: function(field, newValue, oldValue, listener) {
79 form.updateRecord(rec);
85 // sample static data for the store
90 ['American Express Company'],
91 ['American International Group, Inc.'],
96 ['E.I. du Pont de Nemours and Company'],
98 ['General Electric Company'],
99 ['General Motors Corporation'],
100 ['Hewlett-Packard Co'],
101 ['Honeywell Intl Inc'],
102 ['Intel Corporation'],
103 ['International Business Machines'],
104 ['Johnson & Johnson'],
105 ['JP Morgan & Chase & Co'],
106 ['McDonald\'s Corporation'],
107 ['Merck & Co., Inc.'],
108 ['Microsoft Corporation'],
110 ['The Coca-Cola Company'],
111 ['The Home Depot, Inc.'],
112 ['The Procter & Gamble Company'],
113 ['United Technologies Corporation'],
114 ['Verizon Communications'],
115 ['Wal-Mart Stores, Inc.']
118 for (var i = 0, l = myData.length, rand = Math.random; i < l; i++) {
119 var data = myData[i];
120 data[1] = ((rand() * 10000) >> 0) / 100;
121 data[2] = ((rand() * 10000) >> 0) / 100;
122 data[3] = ((rand() * 10000) >> 0) / 100;
123 data[4] = ((rand() * 10000) >> 0) / 100;
124 data[5] = ((rand() * 10000) >> 0) / 100;
127 //create data store to be shared among the grid and bar series.
128 var ds = Ext.create('Ext.data.ArrayStore', {
131 {name: 'price', type: 'float'},
132 {name: 'revenue %', type: 'float'},
133 {name: 'growth %', type: 'float'},
134 {name: 'product %', type: 'float'},
135 {name: 'market %', type: 'float'}
140 //create radar dataset model.
141 var chs = Ext.create('Ext.data.JsonStore', {
142 fields: ['Name', 'Data'],
162 //Radar chart will render information for a selected company in the
163 //list. Selection can also be done via clicking on the bars in the series.
164 var radarChart = Ext.create('Ext.chart.Chart', {
187 fill: 'rgb(194,214,240)',
194 //create a grid that will list the dataset items.
195 var gridPanel = Ext.create('Ext.grid.Panel', {
199 title:'Company Data',
222 dataIndex: 'revenue %',
230 dataIndex: 'growth %',
238 dataIndex: 'product %',
246 dataIndex: 'market %',
252 selectionchange: function(model, records) {
253 var json, name, i, l, items, series, fields;
256 form = form || this.up('form').getForm();
257 fields = form.getFields();
258 // prevent change events from firing
259 fields.each(function(field){
260 field.suspendEvents();
262 form.loadRecord(rec);
264 fields.each(function(field){
265 field.resumeEvents();
272 //create a bar series to be at the top of the panel.
273 var barChart = Ext.create('Ext.chart.Chart', {
289 renderer: function(v) {
290 return Ext.String.ellipsis(v, 15, false);
310 display: 'insideEnd',
313 orientation: 'vertical',
314 'text-anchor': 'middle'
317 'itemmouseup': function(item) {
318 var series = barChart.series.get(0),
319 index = Ext.Array.indexOf(series.items, item),
320 selectionModel = gridPanel.getSelectionModel();
322 selectedStoreItem = item.storeItem;
323 selectionModel.select(index);
331 //disable highlighting by default.
332 barChart.series.get(0).highlight = false;
334 //add listener to (re)select bar item after sorting or refreshing the dataset.
335 barChart.addListener('beforerefresh', (function() {
339 if (selectedStoreItem) {
340 timer = setTimeout(function() {
341 selectItem(selectedStoreItem);
348 * Here is where we create the Form
350 var gridForm = Ext.create('Ext.form.Panel', {
351 title: 'Company data',
376 layout: {type: 'hbox', align: 'stretch'},
379 bodyStyle: 'background-color: transparent',
388 title: 'Company Details',
393 title:'Company details',
398 defaultType: 'textfield',
406 listeners: createListeners('price')
408 fieldLabel: 'Revenue %',
410 listeners: createListeners('revenue %')
412 fieldLabel: 'Growth %',
414 listeners: createListeners('growth %')
416 fieldLabel: 'Product %',
418 listeners: createListeners('product %')
420 fieldLabel: 'Market %',
422 listeners: createListeners('market %')
430 var gp = Ext.getCmp('company-form');