Debian Codegraph @

examples/jsonp.html

raw
1 <!doctype>
2 <head>
3 <link type="text/css" rel="stylesheet" href="../src/css/graph.css">
4 <link type="text/css" rel="stylesheet" href="css/lines.css">
5
6 <script src="../vendor/d3.v3.js"></script>
7
8 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
9
10 <script src="../rickshaw.js"></script>
11 </head>
12 <body>
13
14 <div id="chart_container">
15 <div id="chart"></div>
16 </div>
17
18 <script>
19
20 // subclass to hard-code callback name so we can call this in a static context
21
22 Rickshaw.Graph.JSONP.Static = Rickshaw.Class.create( Rickshaw.Graph.JSONP, {
23 request: function() {
24 $.ajax( {
25 url: this.dataURL,
26 success: this.success.bind(this),
27 error: this.error.bind(this),
28 dataType: 'jsonp',
29 jsonpCallback: 'callback'
30 } );
31 }
32 } );
33
34 var jsonpGraph = new Rickshaw.Graph.JSONP.Static( {
35
36 element: document.getElementById("chart"),
37 width: 400,
38 height: 200,
39 renderer: 'line',
40 dataURL: 'data/data.jsonp',
41 onData: function(d) { Rickshaw.Series.zeroFill(d); return d },
42 series: [
43 {
44 name: 'New York',
45 color: '#c05020',
46 }, {
47 name: 'London',
48 color: '#30c020',
49 }, {
50 name: 'Tokyo',
51 color: '#6060c0'
52 }
53 ]
54 } );
55
56 </script>
57
58 </body>