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.onReady(function () {
22 var generateData = (function() {
25 date = new Date(2011, 1, 1),
33 date: Ext.Date.add(date, Ext.Date.DAY, i++),
34 visits: min(100, max(last? last.visits + (random() - 0.5) * 20 : random() * 100, 0)),
35 views: min(100, max(last? last.views + (random() - 0.5) * 10 : random() * 100, 0)),
36 veins: min(100, max(last? last.veins + (random() - 0.5) * 20 : random() * 100, 0))
38 last = data[data.length -1];
46 groupBy: 'year,month,day'
54 var axis = chart.axes.get(1),
55 selectedGroup = groupOp[+group];
56 axis.dateFormat = selectedGroup.dateFormat;
57 axis.groupBy = selectedGroup.groupBy;
62 var store = Ext.create('Ext.data.JsonStore', {
63 fields: ['date', 'visits', 'views', 'veins'],
67 var intr = setInterval(function() {
68 var gs = generateData();
69 var toDate = timeAxis.toDate,
70 lastDate = gs[gs.length - 1].date,
71 markerIndex = chart.markerIndex || 0;
72 if (+toDate < +lastDate) {
74 timeAxis.toDate = lastDate;
75 timeAxis.fromDate = Ext.Date.add(Ext.Date.clone(timeAxis.fromDate), Ext.Date.DAY, 1);
76 chart.markerIndex = markerIndex;
81 Ext.create('Ext.Window', {
87 title: 'Live Updated Chart',
91 style: 'background:#fff',
100 fields: ['views', 'visits', 'veins'],
101 title: 'Number of Hits',
115 groupBy: 'year,month,day',
119 fromDate: new Date(2011, 1, 1),
120 toDate: new Date(2011, 1, 7)
124 axis: ['left', 'bottom'],
130 renderer: function(v) { return v >> 0; },
131 'text-anchor': 'middle'
139 axis: ['left', 'bottom'],
145 renderer: function(v) { return v >> 0; },
146 'text-anchor': 'middle'
154 axis: ['left', 'bottom'],
160 renderer: function(v) { return v >> 0; },
161 'text-anchor': 'middle'
170 chart = Ext.getCmp('chartCmp');
171 var timeAxis = chart.axes.get(1);