Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed fuTelldus_v3.zip
Binary file not shown.
Binary file removed images/Thumbs.db
Binary file not shown.
47 changes: 13 additions & 34 deletions inc/chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@

/* Get chart type
--------------------------------------------------------------------------- */
if (empty($user['chart_type'])) $chartType = "rgraph";
if (empty($user['chart_type'])) $chartType = "mergeHCharts";
else $chartType = $user['chart_type'];

if (isset($_GET['charttype'])) {
$chartType = clean($_GET['charttype']);
}

if (isset($_GET['view'])) {
$view = clean($_GET['view']);
}



echo "<script>console.log( 'Chart type: $chartType' );</script>";


/* Headline
Expand All @@ -37,34 +32,22 @@
echo "<div style='float:right; margin-top:-45px; margin-right:20px;' class='btn-group'>";

echo "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#''>";
echo "{$lang['Action']}";
echo "{$lang['Chart type']}";
echo "<span class='caret'></span>";
echo "</a>";

echo "<ul class='dropdown-menu'>";
if ($chartType == "rgraph") {
echo "<li><a href='?page=chart&charttype=highcharts'>Switch to Highcharts</a></li>";
}

elseif ($chartType == "highcharts") {
echo "<li><a href='?page=chart&charttype=rgraph'>Switch to RGraph</a></li>";
}

echo "<li><a href='?page=chart&charttype=highcharts'>Single Highcharts</a></li>";
echo "<li><a href='?page=chart&charttype=mergeHCharts'>{$lang['Combine charts']} Highcharts</a></li>";
echo "<li><a href='?page=chart&charttype=rgraph'>Single RGraph</a></li>";
echo "<li><a href='?page=chart&charttype=mergeCharts'>{$lang['Combine charts']} RGraph</a></li>";
echo "<li><a href='?page=report'>{$lang['Report']} (RGraph)</a></li>";
echo "<li><a href='?page=chart&view=mergeCharts'>{$lang['Combine charts']}</a></li>";
echo "</ul>";
echo "</div>";








/* Include chart
--------------------------------------------------------------------------- */
if (!isset($_GET['view'])) {
if ($chartType == "rgraph") {
include("inc/chart_rgraph.php");
}
Expand All @@ -73,20 +56,16 @@
include("inc/chart_highchart.php");
}

elseif ($charttype == "mergeCharts") {
elseif ($chartType == "mergeCharts") {
include("inc/chart_rgraph_mergeSensors.php");
}

else {
echo "Something went wrong.. Could'n determine chart to display. Try selecting chart in your userprofile.";
elseif ($chartType == "mergeHCharts") {
include("inc/chart_highchart_mergeSensors.php");
}
}


else {
if ($view == "mergeCharts") {
include("inc/chart_rgraph_mergeSensors.php");
else {
echo "Something went wrong.. Could'n determine chart to display. Try selecting chart in your userprofile.";
}
}

?>
?>
137 changes: 137 additions & 0 deletions inc/chart_highchart_mergeSensors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<script src="lib/packages/Highstock-1.3.1/js/highstock.js"></script>
<script src="lib/packages/Highstock-1.3.1/js/modules/exporting.js"></script>

<script type="text/javascript">

$(function() {
$('#container').highcharts('StockChart', {

chart: {
},

rangeSelector: {
enabled: true,
buttons: [{
type: 'hour',
count: 1,
text: '1h'
},{
type: 'hour',
count: 12,
text: '12h'
},{
type: 'day',
count: 1,
text: '1d'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
selected: 4
},

legend: {
align: "center",
layout: "horizontal",
enabled: true,
verticalAlign: "bottom"
},

tooltip: {
valueSuffix: '°C'
},

xAxis: {
type: 'datetime',
},

yAxis: {
title: {
text: 'Temperature (°C)',
},
labels: {
formatter: function() {
return this.value +'\u00B0C';
},
style: {
color: '#777'
}
},
},

navigator : {
enabled : false
},

scrollbar : {
enabled : false
},

series: [

<?php

// Set how long back you want to pull data
$showFromDate = time() - 86400 * $config['chart_max_days']; // 86400 => 24 hours * 10 days

/* TEMP SENSOR 01: Get sensors
--------------------------------------------------------------------------- */
$query = "SELECT * FROM ".$db_prefix."sensors WHERE user_id='{$user['user_id']}' AND monitoring='1'";
$result = $mysqli->query($query);

while ($row = $result->fetch_array()) {

unset($temp_values);
$joinValues = "";

/* Get sensordata and generate graph
--------------------------------------------------------------------------- */
$queryS = "SELECT * FROM ".$db_prefix."sensors_log WHERE sensor_id='{$row["sensor_id"]}' AND time_updated > '$showFromDate' ORDER BY time_updated ASC";
$resultS = $mysqli->query($queryS);

while ($sensorData = $resultS->fetch_array()) {
$db_tempValue = trim($sensorData["temp_value"]);

$timeJS = $sensorData["time_updated"] * 1000;
$temp_values[] = "[" . $timeJS . "," . round($db_tempValue, 2) . "]";
}

$joinValues = join($temp_values, ',');

echo <<<end
{
name: '{$row["name"]}',
data: [$joinValues],
type: 'spline',
tooltip: {
valueDecimals: 1
}
},
end;

}
?>
],

});
});


</script>
<div id="container" style="height: 500px; min-width: 500px"></div>
3 changes: 2 additions & 1 deletion lib/languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"Secondary" => "Secondary",
"Now" => "Now",
"Action" => "Action",
"Chart type" => "Chart type",

// send warning IF temperature IS more/less THAN / FOR sensor ...
"If" => "If",
Expand Down Expand Up @@ -205,4 +206,4 @@

);

?>
?>
3 changes: 2 additions & 1 deletion lib/languages/no.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"Secondary" => "Sekundær",
"Now" => "Nå",
"Action" => "Action",
"Chart type" => "Graftype",

// send warning IF temperature IS more/less THAN / FOR sensor ...
"If" => "Hvis",
Expand Down Expand Up @@ -204,4 +205,4 @@

);

?>
?>
3 changes: 2 additions & 1 deletion lib/languages/sw.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"Secondary" => "Sekundär",
"Now" => "Nu",
"Action" => "Action",
"Chart type" => "Graftyp",

// send warning IF temperature IS more/less THAN / FOR sensor ...
"If" => "If",
Expand Down Expand Up @@ -202,4 +203,4 @@

);

?>
?>