benaskins / simplegraph

Simple graphs using jQuery and Raphael

This URL has Read+Write access

simplegraph / index.html
100644 169 lines (161 sloc) 5.557 kb
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
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>SimpleGraph - simple javascript graphs with Raphael and jQuery</title>
    <script src="vendor/jquery.js" type="text/javascript"></script>
    <script src="vendor/raphael.js" type="text/javascript"></script>
    <script src="jquery.simplegraph.js" type="text/javascript"></script>
    <script src="sample.js" type="text/javascript"></script>
    <style type="text/css">
      #container {
        margin:auto;
        width:900px;
      }
      pre {
        background:#EEEEEE none repeat scroll 0 0;
        border:4px solid #DDDDDD;
        line-height:20px;
        overflow:auto;
        padding:5px;
        width:800px;
      }
      h1, h2, h3 {
        font-family:verdana;
      }
      a {
        background-color:#FFFFCC;
        color:#000000;
        text-decoration:none;
      }
      a:hover {
        background-color:yellow;
      }
    </style>
  </head>
  <body>
    <a href="http://github.com/benaskins/simplegraph">
    <img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" style="border: 0pt none ; position: absolute; top: 0pt; right: 0pt;"/>
    </a>
    <div id='container'>
      <h1>SimpleGraph</h1>
      <h2>
        Simple javascript line graphs using <a href="http://raphaeljs.com/">Raphael</a> and
        <a href="http://jquery.com/">jQuery</a>. Find me, download me, or fork me at
        <a href="http://github.com/benaskins/simplegraph">github</a>. The following examples should speak for themselves...
      </h2>
      <div id='temp-data'>
        <table cellspacing='0' class='graph' summary='Temperature in 7 days'>
          <caption>Temperature in 7 days</caption>
          <tfoot>
            <tr>
              <th>
                Wed 17 Dec
              </th>
              <th>
                Thu 18 Dec
              </th>
              <th>
                Fri 19 Dec
              </th>
              <th>
                Sat 20 Dec
              </th>
              <th>
                Sun 21 Dec
              </th>
              <th>
                Mon 22 Dec
              </th>
              <th>
                Tue 23 Dec
              </th>
            </tr>
          </tfoot>
          <tbody>
            <tr>
              <td class="pos">20</td>
              <td class="pos">23</td>
              <td class="pos">23</td>
              <td class="pos">28</td>
              <td class="pos">28</td>
              <td class="pos">22</td>
              <td class="pos">25</td>
            </tr>
            <tr>
              <td class="neg">-5</td>
              <td class="neg">-2</td>
              <td class="neg">5</td>
              <td class="neg">6</td>
              <td class="neg">-1</td>
              <td class="neg">-3</td>
              <td class="neg">5</td>
            </tr>
          </tbody>
        </table>
      </div>
 
      <div id='rain-data'>
        <table cellspacing='0' class='graph' summary='Rain in 7 days'>
          <caption>Rain in 7 days</caption>
          <tfoot>
            <tr>
              <th>
                Wed 17 Dec
              </th>
              <th>
                Thu 18 Dec
              </th>
              <th>
                Fri 19 Dec
              </th>
              <th>
                Sat 20 Dec
              </th>
              <th>
                Sun 21 Dec
              </th>
              <th>
                Mon 22 Dec
              </th>
              <th>
                Tue 23 Dec
              </th>
            </tr>
          </tfoot>
          <tbody>
            <tr>
              <td>5</td>
              <td>0</td>
              <td>0</td>
              <td>5</td>
              <td>0</td>
              <td>0</td>
              <td>0</td>
            </tr>
          </tbody>
        </table>
      </div>
 
      <h3>Simplest Graph (no customisation)</h3>
      <pre>$("#simplest_graph_holder").simplegraph(temp_data, temp_labels);</pre>
      <div id='simplest_graph_holder'></div>
 
      <h3>Temperature in 7 days (with color, fill, and min y-axis value)</h3>
      <pre>$("#temp_graph_holder").simplegraph(temp_data, temp_labels,
  {penColor: "#f00", fillUnderLine: true, units: "ºC", minYAxisValue: 30});</pre>
      <div id='temp_graph_holder'></div>
      
      <h3>Rain in 7 days (with y-axis labels)</h3>
      <pre>$("#rain_graph_holder").simplegraph(rain_data, rain_labels,
  {penColor: "#00f", units: "mm", leftGutter: 60, minYAxisValue: 10, yAxisCaption: "Max Rainfall"});</pre>
      <div id='rain_graph_holder'></div>
      
      <h3>Combined Temperature / Rain </h3>
      <pre>$("#combined_graph_holder").simplegraph(temp_data, temp_labels,
  {penColor: "#f00", leftGutter: 90, units: "ºC", minYAxisValue: 30, yAxisCaption: "Max Temp", lowerBound: -10})
    .simplegraph.more(rain_data,
      {penColor: "#00f", units: "mm", minYAxisValue: 10, yAxisCaption: "Max Rainfall"});</pre>
      <div id='combined_graph_holder'></div>
 
      <h3>Temperature in 7 days bar graph (with color, and min y-axis value)</h3>
      <pre>$("#bar_graph_holder").simplegraph(temp_data, temp_labels,
  {penColor: "#f00", units: "ºC", minYAxisValue: 30, drawBars: true, drawLine: false, drawPoints: false, drawGrid: false, barWidth: 20});</pre>
      <div id='bar_graph_holder'></div>
 
    </div>
  </body>
</html>