-
Notifications
You must be signed in to change notification settings - Fork 941
/
jsonp.html
59 lines (48 loc) · 1.2 KB
/
jsonp.html
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
<!doctype>
<head>
<link type="text/css" rel="stylesheet" href="../src/css/graph.css">
<link type="text/css" rel="stylesheet" href="css/lines.css">
<script src="../vendor/d3.min.js"></script>
<script src="../vendor/d3.layout.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="../rickshaw.js"></script>
</head>
<body>
<div id="chart_container">
<div id="chart"></div>
</div>
<script>
// subclass to hard-code callback name so we can call this in a static context
Rickshaw.Graph.JSONP.Static = Rickshaw.Class.create( Rickshaw.Graph.JSONP, {
request: function() {
$.ajax( {
url: this.dataURL,
success: this.success.bind(this),
error: this.error.bind(this),
dataType: 'jsonp',
jsonpCallback: 'callback'
} );
}
} );
var jsonpGraph = new Rickshaw.Graph.JSONP.Static( {
element: document.getElementById("chart"),
width: 400,
height: 200,
renderer: 'line',
dataURL: 'data/data.jsonp',
onData: function(d) { Rickshaw.Series.zeroFill(d); return d },
series: [
{
name: 'New York',
color: '#c05020',
}, {
name: 'London',
color: '#30c020',
}, {
name: 'Tokyo',
color: '#6060c0'
}
]
} );
</script>
</body>