-
Notifications
You must be signed in to change notification settings - Fork 22
/
standalone.js
181 lines (167 loc) · 4.12 KB
/
standalone.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Ext.Loader.setConfig({
enabled : true,
disableCaching : true, // For debug only
paths : {
'Chart' : './Chart/'
}
});
Ext.require('Chart.ux.HighChart');
Ext.application({
name : 'HighChart',
launch : function() {
// Using the new ExtJS 4 store
Ext.define('HighChartData', {
extend : 'Ext.data.Model',
fields : [{
name : 'time',
type : 'string'
}, {
name : 'yesterday',
type : 'float'
}, {
name : 'today',
type : 'float'
}]
});
var store = Ext.create('Ext.data.Store', {
model : 'HighChartData',
proxy : {
type : 'ajax',
url : './data/standalone.json',
reader : {
type : 'json',
root : 'rows'
}
},
autoLoad : true
});
var randomFromTo = function(from, to) {
return Math.floor(Math.random() * (to - from + 1) + from);
};
var seriesNum = 2;
var genSeries = function() {
var temps = [];
for(var i = 0; i < 20; i++) {
temps[i] = randomFromTo(15, 30);
}
var series = {
type : 'spline',
name : seriesNum + ' days ago',
data : temps
};
seriesNum++;
return series;
};
var win = Ext.create('Ext.window.Window', {
width : 800,
height : 600,
minHeight : 400,
minWidth : 550,
hidden : false,
shadow : false,
maximizable : true,
title : 'Highchart example',
renderTo : Ext.getBody(),
layout : 'fit',
tbar : [{
xtype : 'button',
text : 'Add series',
handler : function() {
var chart = Ext.getCmp('chart');
chart.addSeries([ genSeries() ], true);
}
}],
items : [{
xtype : 'highchart',
id : 'chart',
defaultSeriesType : 'spline',
series : [{
type : 'spline',
dataIndex : 'yesterday',
name : 'Yesterday',
visible : true
}, {
type : 'spline',
dataIndex : 'today',
name : 'Today',
visible : true
}],
store : store,
xField : 'time',
chartConfig : {
chart : {
marginRight : 130,
marginBottom : 120,
zoomType : 'x',
animation : {
duration : 1500,
easing : 'swing'
}
},
title : {
text : 'Highcharts (' + Highcharts.version + ') Example For ExtJs ' + Ext.versions.core.version,
x : -20 //center
},
subtitle : {
text : 'Random value',
x : -20
},
xAxis : [{
title : {
text : 'Time',
margin : 20
},
labels : {
rotation : 270,
y : 35,
formatter : function() {
if( typeof this.value == 'string') {
var dt = Ext.Date.parse(parseInt(this.value) / 1000, "U");
return Ext.Date.format(dt, "H:i:s");
} else {
return this.value;
}
}
}
}],
yAxis : {
title : {
text : 'Value'
},
plotLines : [{
value : 0,
width : 1,
color : '#808080'
}]
},
plotOptions : {
series : {
animation : {
duration : 3000,
easing : 'swing'
}
}
},
tooltip : {
formatter : function() {
return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y;
}
},
credits : {
href : 'http://joekuan.wordpress.com',
text : 'joekuan.wordpress.com'
},
legend : {
layout : 'vertical',
align : 'right',
verticalAlign : 'top',
x : -10,
y : 100,
borderWidth : 0
}
}
}]
});
win.show();
}
});