Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
benaskins committed Dec 16, 2008
0 parents commit 875255a
Show file tree
Hide file tree
Showing 6 changed files with 5,630 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.txt
@@ -0,0 +1,5 @@
1. Clone it
2. Open index.html to see an example
3. Look at js/sample.js to see how it's done
4. Look at js/simplegraph.js for tweakability
5. $$$
117 changes: 117 additions & 0 deletions index.html
@@ -0,0 +1,117 @@
<?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>Title of page &rsaquo; Category if there is one &rsaquo; Site name here: site description</title>
<script src="js/vendor/jquery.js" type="text/javascript"></script>
<script src="js/vendor/raphael.js" type="text/javascript"></script>
<script src="js/simplegraph.js" type="text/javascript"></script>
<script src="js/sample.js" type="text/javascript"></script>
</head>
<body>
<div id='canvas'>
<h3>Temperature in 7 days</h3>
<div id='temp-data'>
<table cellspacing='0' class='graph' summary='Temperature in 7 days'>
<caption>Temperature in 7 days</caption>
<tfoot>
<tr></tr>
<th>
Wednesday
17 Dec
</th>
<th>
Thursday
18 Dec
</th>
<th>
Friday
19 Dec
</th>
<th>
Saturday
20 Dec
</th>
<th>
Sunday
21 Dec
</th>
<th>
Monday
22 Dec
</th>
<th>
Tuesday
23 Dec
</th>
</tfoot>
<tbody>
<tr></tr>
<td>25</td>
<td>23</td>
<td>23</td>
<td>28</td>
<td>28</td>
<td>22</td>
<td>25</td>
</tbody>
</table>
</div>
<div id='temp_graph_holder'></div>

<h3>Rain in 7 days</h3>
<div id='rain-data'>
<table cellspacing='0' class='graph' summary='Rain in 7 days'>
<caption>Rain in 7 days</caption>
<tfoot>
<tr></tr>
<th>
Wednesday
17 Dec
</th>
<th>
Thursday
18 Dec
</th>
<th>
Friday
19 Dec
</th>
<th>
Saturday
20 Dec
</th>
<th>
Sunday
21 Dec
</th>
<th>
Monday
22 Dec
</th>
<th>
Tuesday
23 Dec
</th>
</tfoot>
<tbody>
<tr></tr>
<td>5</td>
<td>0</td>
<td>0</td>
<td>5</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tbody>
</table>
</div>
<div id='rain_graph_holder'></div>

<h3>Combined Graph</h3>
<div></div>
<div id='combined_graph_holder'></div>

</div>
</body>
</html>
46 changes: 46 additions & 0 deletions js/sample.js
@@ -0,0 +1,46 @@
window.onload = function () {

// Get the data
var temp_labels = [], temp_data = [];
$("#temp-data tfoot th").each(function () {
temp_labels.push($(this).html());
});
$("#temp-data tbody td").each(function () {
temp_data.push($(this).html());
});
var rain_labels = [], rain_data = [];
$("#rain-data tfoot th").each(function () {
rain_labels.push($(this).html());
});
$("#rain-data tbody td").each(function () {
rain_data.push($(this).html());
});

// Hide the data
$("#rain-data").hide();
$("#temp-data").hide();

// Plot the data
// - Temperature Graph
var temp_graph = new SimpleGraph("temp_graph_holder", {lineColor: "#f00", pointColor: "#f00", fillUnderLine: true, fillColor: "#f00"});
temp_graph.drawGrid(temp_labels, temp_data, 30);
temp_graph.addYAxisLabels(0, "Max Temp (ºC)");
temp_graph.plot(temp_labels, temp_data, "ºC");
// - Rain Graph
var rain_graph = new SimpleGraph("rain_graph_holder", {lineColor: "#00f", pointColor: "#00f"});
rain_graph.drawGrid(rain_labels, rain_data, 10);
rain_graph.addYAxisLabels(0, "Max Rainfall (mm)");
rain_graph.plot(rain_labels, rain_data, "mm");
// - Combined Graph
var combined_graph = new SimpleGraph("combined_graph_holder", {lineColor: "#f00", pointColor: "#f00"});
combined_graph.drawGrid(temp_labels, temp_data, 30);
combined_graph.addYAxisLabels(0, "Max Temp (ºC)");
combined_graph.plot(temp_labels, temp_data, "ºC");
combined_graph.changeYAxis(rain_labels, rain_data, 10);
combined_graph.settings.lineColor = "#00f";
combined_graph.settings.pointColor = "#00f";
combined_graph.addYAxisLabels(30, "Max Rainfall (mm)");
combined_graph.plot(rain_labels, rain_data, "mm");


};

0 comments on commit 875255a

Please sign in to comment.