Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Temp Chart</title>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <style type="text/css">
- ${demo.css}
- </style>
- <script type="text/javascript">
- $(function () {
- $('#container').highcharts({
- chart: {
- type: 'spline'
- },
- title: {
- text: 'Temperature at Dag Hammarskjölds Väg, Uppsala'
- },
- subtitle: {
- text: 'by Gortz'
- },
- xAxis: {
- type: 'datetime',
- dateTimeLabelFormats: { // don't display the dummy year
- hour: '%I %p',
- month: '%e. %b',
- year: '%b'
- },
- title: {
- text: 'Date'
- }
- },
- yAxis: {
- title: {
- text: 'degree celsius (°)'
- },
- min: 0
- },
- tooltip: {
- headerFormat: '<b>{series.name}</b><br>',
- pointFormat: '{point.x:%e. %b %I %p}: {point.y:.1f}°'
- },
- plotOptions: {
- spline: {
- marker: {
- enabled: true
- }
- }
- },
- series: [{
- name: 'Inside',
- data: [
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "home";
- // Create connection
- $conn = new mysqli($servername, $username, $password,$dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM tempIn";
- $result = $conn->query($sql);
- $firstRow=1;
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- if ($firstRow==1){
- $firstRow=0;
- } else{
- echo ",";
- }
- echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["temperature"] . "]";
- }
- } else {
- echo "0 results";
- }
- ?>
- ]
- },{
- name: 'Outside',
- data: [
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "home";
- // Create connection
- $conn = new mysqli($servername, $username, $password,$dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM tempOut";
- $result = $conn->query($sql);
- $firstRow=1;
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- if ($firstRow==1){
- $firstRow=0;
- } else{
- echo ",";
- }
- echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["temperature"] . "]";
- }
- } else {
- echo "0 results";
- }
- ?>
- ]
- },]
- });
- });
- </script>
- </head>
- <body>
- <script src="https://code.highcharts.com/highcharts.js"></script>
- <script src="https://code.highcharts.com/modules/exporting.js"></script>
- <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
- <script>
- $(function () {
- $('#container-hum').highcharts({
- chart: {
- type: 'spline'
- },
- title: {
- text: 'Humidity at Dag Hammarskjölds Väg, Uppsala'
- },
- subtitle: {
- text: 'by Gortz'
- },
- xAxis: {
- type: 'datetime',
- dateTimeLabelFormats: { // don't display the dummy year
- hour: '%I %p',
- month: '%e. %b',
- year: '%b'
- },
- title: {
- text: 'Date'
- }
- },
- yAxis: {
- title: {
- text: 'humidity (%)'
- },
- min: 0
- },
- tooltip: {
- headerFormat: '<b>{series.name}</b><br>',
- pointFormat: '{point.x:%e. %b %I %p}: {point.y:f}%'
- },
- plotOptions: {
- spline: {
- marker: {
- enabled: true
- }
- }
- },
- series: [{
- name: 'Inside',
- data: [
- <?php
- $servername = "localhost";
- $username = "";
- $password = "";
- $dbname = "home";
- // Create connection
- $conn = new mysqli($servername, $username, $password,$dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM humidityIn";
- $result = $conn->query($sql);
- $firstRow=1;
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- if ($firstRow==1){
- $firstRow=0;
- } else{
- echo ",";
- }
- echo "[Date.UTC(" . date('Y,m,d,H',strtotime($row["timestamp"])) . "),". $row["humidity"] . "]";
- }
- } else {
- echo "0 results";
- }
- ?>
- ]
- },]
- });
- });
- </script>
- <div id="container-hum" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement