Debian Codegraph @

examples/x_axis.html

raw
1 <!doctype html>
2
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 <script src="../rickshaw.js"></script>
8
9 <style>
10 #chart {
11 position: relative;
12 left: 40px;
13 display: block;
14 }
15 #y_axis {
16 position: absolute;
17 top: 0;
18 bottom: 0;
19 width: 40px;
20 }
21 #x_axis {
22 position: relative;
23 left: 40px;
24 height: 40px;
25 }
26 </style>
27
28 <div id="chart_container">
29 <div id="y_axis"></div>
30 <div id="chart"></div>
31 <div id="x_axis"></div>
32 </div>
33
34 <script>
35
36 // instantiate our graph!
37
38 var graph = new Rickshaw.Graph( {
39 element: document.getElementById("chart"),
40 renderer: 'line',
41 height: 300,
42 width: 800,
43 series: [
44 {
45 data: [ { x: 0, y: 120 }, { x: 1, y: 890 }, { x: 2, y: 38 }, { x: 3, y: 70 }, { x: 4, y: 32 } ],
46 color: "#c05020"
47 }, {
48 data: [ { x: 0, y: 80 }, { x: 1, y: 200 }, { x: 2, y: 100 }, { x: 3, y: 520 }, { x: 4, y: 133 } ],
49 color: "#30c020"
50 }, {
51 data: [ { x: 0, y: 200 }, { x: 1, y: 390 }, { x: 2, y: 1000 }, { x: 3, y: 200 }, { x: 4, y: 230 } ],
52 color: "#6060c0"
53 }
54 ]
55 } );
56
57 var format = function(n) {
58
59 var map = {
60 0: 'zero',
61 1: 'first',
62 2: 'second',
63 3: 'third',
64 4: 'fourth'
65 };
66
67 return map[n];
68 }
69
70 var x_ticks = new Rickshaw.Graph.Axis.X( {
71 graph: graph,
72 orientation: 'bottom',
73 element: document.getElementById('x_axis'),
74 pixelsPerTick: 200,
75 tickFormat: format
76 } );
77
78 graph.render();
79
80 </script>