Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
- <script src="http://code.highcharts.com/highcharts.js"></script>
- <script src="http://code.highcharts.com/modules/exporting.js"></script>
- <script src="http://code.highcharts.com/themes/gray.js"></script>
- <script type="text/javascript">
- var chart;
- $(document).ready(function() {
- var options = {
- chart: {
- renderTo: 'container1',
- defaultSeriesType: 'area',
- marginRight: 10,
- marginBottom: 25,
- zoomType: 'xy' //zoom
- },
- credits: {
- enabled: false
- },
- title: {
- text: 'Temperature',
- x: -20 //center
- },
- subtitle: {
- text: '',
- x: -20
- },
- xAxis: {
- type: 'datetime',
- //tickInterval: 4 * 24 * 3600 * 1000 , // one hour
- //minRange: 14 * 24 * 3600000,
- minRange: 4 * 24 * 3600 * 1000,
- tickWidth: 0,
- gridLineWidth: 2,
- /*labels: {
- align: 'center',
- x: -3,
- y: 20,
- formatter: function() {
- return Highcharts.dateFormat('%b %e', this.value);
- }
- }*/
- },
- yAxis: {
- title: {
- text: 'Temperature °C',
- lineColor: '#FF0000',
- lineWidth: 1,
- },
- min: null, // Will for min and max to adjust when you zoom
- max: null, //
- startOnTick: false,
- minTickInterval: 1,
- showFirstLabel: false
- /*plotLines: [{
- value: 0,
- width: 0,
- color: 'green'
- }]*/
- },
- tooltip: {
- valueDecimals: 2
- //formatter: function() {
- // return Highcharts.dateFormat('%b %e', this.x-(1000*3600)) +'-'+ Highcharts.dateFormat('%l%p', this.x) +': <b>'+ this.y + '</b>';
- //}
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'top',
- x: -10,
- y: 100,
- borderWidth: 0
- },
- plotOptions: {
- series: {
- marker: {
- radius: 1
- }
- }
- },
- series : [{
- type: 'area',
- name : 'Temperature °C',
- color: '#0099FF',
- fillOpacity: 0.3,
- showInLegend: false,
- }]
- }
- // Load data asynchronously using jQuery. On success, add the data
- // to the options and initiate the chart.
- // This data is obtained by exporting a GA custom report to TSV.
- // http://api.jquery.com/jQuery.get/
- jQuery.get('php_scripts/data.php', null, function(tsv) {
- var lines = [];
- traffic = [];
- try {
- // split the data return into lines and parse them
- tsv = tsv.split(/n/g);
- jQuery.each(tsv, function(i, line) {
- line = line.split(/,/);
- date = Date.parse(line[0] +' UTC');
- traffic.push([
- date,
- parseInt(line[4].replace(',', ''), 10)
- ]);
- });
- } catch (e) { }
- options.series[0].data = traffic;
- chart = new Highcharts.Chart(options);
- });
- });
- <td><div id="container1" style="width: 725px; height: 300px;"></div></td>
- <?php
- $con = mysql_connect("db4free.net","username","password");
- if (!$con) {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("weatherlog", $con);
- $result = mysql_query("SELECT * FROM weatherlog");
- while($row = mysql_fetch_array($result)) {
- echo $row['TIME'] . " , " . $row['TEMP']. " , " . $row['HUMIDITY'] . " , " . $row['PRESSURE'] . " , " . $row['OUTTEMP'] . " , " . $row['OUTHUMIDITY'] . " , " . $row['RAIN'] . " , " . $row['WINDSPEED'] . "n";
- }
- mysql_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement