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.
15 Ext.require('Ext.chart.*');
17 Ext.onReady(function () {
19 var generateData = (function() {
22 date = new Date(2011, 1, 1),
30 date: Ext.Date.add(date, Ext.Date.DAY, i++),
31 visits: min(100, max(last? last.visits + (random() - 0.5) * 20 : random() * 100, 0)),
32 views: min(100, max(last? last.views + (random() - 0.5) * 10 : random() * 100, 0)),
33 users: min(100, max(last? last.users + (random() - 0.5) * 20 : random() * 100, 0))
35 last = data[data.length -1];
43 groupBy: 'year,month,day'
51 var axis = chart.axes.get(1),
52 selectedGroup = groupOp[+group];
53 axis.dateFormat = selectedGroup.dateFormat;
54 axis.groupBy = selectedGroup.groupBy;
58 var store = Ext.create('Ext.data.JsonStore', {
59 fields: ['date', 'visits', 'views', 'users'],
63 var intr = setInterval(function() {
64 var gs = generateData();
65 var toDate = timeAxis.toDate,
66 lastDate = gs[gs.length - 1].date,
67 markerIndex = chart.markerIndex || 0;
68 if (+toDate < +lastDate) {
70 timeAxis.toDate = lastDate;
71 timeAxis.fromDate = Ext.Date.add(Ext.Date.clone(timeAxis.fromDate), Ext.Date.DAY, 1);
72 chart.markerIndex = markerIndex;
77 Ext.create('Ext.Window', {
82 title: 'Live Animated Chart',
83 renderTo: Ext.getBody(),
87 style: 'background:#fff',
98 fields: ['views', 'visits', 'users'],
99 title: 'Number of Hits',
113 groupBy: 'year,month,day',
117 fromDate: new Date(2011, 1, 1),
118 toDate: new Date(2011, 1, 7),
130 renderer: function(v) { return v >> 0; },
131 'text-anchor': 'middle'
146 renderer: function(v) { return v >> 0; },
147 'text-anchor': 'middle'
162 renderer: function(v) { return v >> 0; },
163 'text-anchor': 'middle'
172 chart = Ext.getCmp('chartCmp');
173 var timeAxis = chart.axes.get(1);