forked from metricsgraphics/metrics-graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive-demo.htm
228 lines (198 loc) · 8.66 KB
/
interactive-demo.htm
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<meta property='og:title' content='MetricsGraphics.js' />
<meta property='og:description' content='MetricsGraphics.js is a library optimized
for visualizing and laying out time-series data. It provides a simple way to produce
common types of graphics in a principled, consistent and responsive way.' />
<meta property='og:image' content='http://metricsgraphicsjs.org/images/og-logo.png' />
<meta property='og:type' content='website' />
<meta property='og:url' content='http://metricsgraphicsjs.org/' />
<meta property='og:site_name' content='MetricsGraphics.js' />
<link href='images/og-logo.png' rel='icon' type='image/png' />
<title>MetricsGraphics.js - a library based on D3.js, optimized for visualizing and laying out time-series data</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700,400italic' rel='stylesheet' type='text/css'>
<link href='https://netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.css' rel='stylesheet' type='text/css'>
<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
<link href='css/metricsgraphics.css' rel='stylesheet' type='text/css'>
<link href='css/metricsgraphics-demo.css' rel='stylesheet' type='text/css'>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js' charset='utf-8'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js'></script>
<script src="js/lib/ace.js" charset="utf-8"></script>
<script src='js/metricsgraphics.min.js'></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-51487512-1', 'metricsgraphicsjs.org');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=1570736809816152&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class='container'>
<div id='content-body'>
<div class='head'>
<ul>
<li><a href='http://www.metricsgraphicsjs.org/'>Home</a></li>
<li><a href='https://github.com/mozilla/metrics-graphics/releases'>Download</a></li>
<li><a href='https://github.com/mozilla/metrics-graphics'>Code</a></li>
<li><a href='https://github.com/mozilla/metrics-graphics/issues'>Issues</a></li>
<li><a href='examples.htm'>Examples</a></li>
</ul>
<img src='images/logo.svg' id='logo' class='svg' />
</div>
<div id='description'>
<p><i>MetricsGraphics.js</i> is a library built on top of
<a href='http://d3js.org/'>D3</a> that is optimized for visualizing and
laying out time-series data. It provides a simple way to produce common
types of graphics in a principled, consistent and responsive way. The
library currently supports line charts, scatterplots and histograms as
well as features like rug plots and basic linear regression.</p>
<p>This demo allows you to play around with the library without having to
download it. Try doubling the number of sightings in, say, 1995 and see
how that affects the graphic. Or how about changing any of the options in
<i>data_graphic</i>? Or perhaps change the chart type to a scatterplot by
setting <code>chart_type:'point'</code>? The data object is set to the
contents of the <i>Data</i> text area. Errors are logged to the
console.</p>
</div>
</div>
</div>
<div class='container'>
<div class='row main-windows-titles'>
<div class='col-xs-2'>Data</div>
<div class='js-title col-xs-5'>
JavaScript <a href='https://github.com/mozilla/metrics-graphics/wiki/List-of-Options#list-of-options' target='_blank'>See Full List of Options</a>
<button type='button' class='update btn'>Run</button>
</div>
</div>
<div class='row main-windows'>
<div class='data col-xs-2'>
<textarea></textarea>
</div>
<div class='js col-xs-5' id='editor'></div>
<div class='result text-center col-xs-5'></div>
</div>
</div>
<div class='container footer'>
Created by <a href='https://twitter.com/alialmossawi'>Ali Almossawi</a>,
<a href='https://github.com/hamilton'>Hamilton Ulmer</a> and the
<a href='https://metrics.mozilla.com/'>Metrics Team</a> at
<a href='https://www.mozilla.org/en-US/'>Mozilla</a>.
<br />Shared under a <a href='http://www.mozilla.org/MPL/2.0/'>
Mozilla Public License</a>.
</div>
<style>
body {
background-color: #fcfcfc;
}
.container {
width: 90%;
min-width: 960px;
}
.data textarea {
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
font-size: 11px;
height: 100%;
width: 100%;
}
.footer {
background-image: url(images/divider.png);
background-repeat: no-repeat;
background-position: center 115px;
padding-top: 70px;
margin-bottom: 20px;
}
.hightop {
margin-top: 40px;
}
#logo {
margin: 15px 0 10px 0;
}
.main-windows-titles {
color: #3b3b3b;
font-size: 16px;
padding-bottom: 5px;
text-align: center;
}
.main-windows-titles .js-title a {
position: absolute;
right: 0;
font-size: 70%;
margin: 7px 1px 0 0;
}
.main-windows .data,
.main-windows .js,
.main-windows .result {
height: 400px;
}
p {
padding-top: 6px;
}
textarea,
#editor {
border-radius: 3px;
border: none;
overflow: auto;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
padding: 10px;
border: 1px solid #ccc;
}
.btn.update {
background-color: steelblue;
color: white;
margin-top: 34px;
outline: none;
position: absolute;
right: 7px;
z-index: 99;
}
.btn.update:hover,
.btn.update:active,
.btn.update:visited {
color: #efefef;
outline: none;
}
</style>
<script>
var default_call = '//modify away!\n'
+ 'data_graphic({\n'
+ ' title: "UFO Sightings",\n'
+ ' description: "Yearly UFO sightings from 1945 to 2010.",\n'
+ ' data: JSON.parse($(\'.data textarea\').val()),\n'
+ ' markers: [{\'year\': 1964, \'label\': \'"The Creeping Terror" released\'}],\n'
+ ' width: 400,\n'
+ ' height: 250,\n'
+ ' target: ".result",\n'
+ ' x_accessor: "year",\n'
+ ' y_accessor: "sightings",\n'
+ ' interpolate: "monotone"\n'
+ '});';
var editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/javascript");
editor.setValue(default_call);
editor.gotoLine(1);editor.setHighlightActiveLine(false);
d3.json('data/ufo-sightings.json', function(data) {
$('.data textarea').val(JSON.stringify(data, null, 2));
eval(editor.getValue());
})
$('.update').on('click', function() {
eval(editor.getValue());
})
</script>
</body>
</html>