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>Weather Database</title>
- <link rel="shortcut icon" type="image/x-icon" href="icon.png">
- <link rel="icon" sizes="192x192" href="icon.png">
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(function () {
- var seriesOptions = [],
- seriesCounter = 0,
- units = [' °C', ' %', ' hPa', ' LUX', ''],
- digits = [1, 1, 2, 0, 0],
- names = ['Temperature', 'Humidity', 'Pressure', 'Luminance', 'Soil Humidity'];
- /**
- * Create the chart when all data is loaded
- * @returns {undefined}
- */
- function createChart() {
- $('#container').highcharts('StockChart', {
- rangeSelector: {
- 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: 2
- },
- yAxis: [{
- title: {
- text: 'Temperature'
- },
- labels: {
- format: '{value} °C'
- },
- height: '25%', //$(window).height() / 4.93, //200,
- offset: 0,
- lineWidth: 2
- }, {
- title: {
- text: 'Humidity'
- },
- labels: {
- format: '{value} %'
- },
- top: '30%', //$(window).height() / 3.29, //300,
- height: '12.5%', //$(window).height() / 9.86, //100,
- offset: 0,
- lineWidth: 2
- }, {
- title: {
- text: 'Pressure'
- },
- labels: {
- format: '{value} hPa'
- },
- top: '47.5%', //$(window).height() / 2.19, //450,
- height: '12.5%', //$(window).height() / 9.86, // 100,
- offset: 0,
- lineWidth: 2,
- }, {
- title: {
- text: 'Luminance'
- },
- labels: {
- format: '{value} LUX'
- },
- top: '65%', //$(window).height() / 1.64, //600,
- height: '12.5%', //$(window).height() / 9.86, //100,
- offset: 0,
- lineWidth: 2
- }, {
- title: {
- text: 'Soil Humidity'
- },
- top: '82.5%', //$(window).height() / 1.32, //750,
- height: '12.5%', //$(window).height() / 9.86, //100,
- offset: 0,
- lineWidth: 2
- }, {
- }],
- scrollbar : {
- enabled : false
- },
- series: seriesOptions
- });
- }
- $.each(names, function (i, name) {
- $.getJSON('sql_' + name.toLowerCase() + '.php', function (data) {
- seriesOptions[i] = {
- name: name,
- data: data,
- yAxis: i,
- tooltip: {
- valueDecimals: digits[i], // 2
- valueSuffix: units[i]
- },
- dataGrouping: {
- units: [
- ['minute', [1]],
- ['hour', [1]],
- ['day', [1]],
- ['month', [1]],
- ['year', null]
- ],
- groupPixelWidth: 10
- }
- };
- seriesCounter += 1;
- if (seriesCounter === names.length) {
- createChart();
- }
- });
- });
- });
- </script>
- </head>
- <body bgcolor="#2a2a2b">
- <script src="https://code.highcharts.com/stock/highstock.js"></script>
- <script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
- <script type="text/javascript" src="sand-signika.js"></script> <!-- sand-signika.js dark-unica.js-->
- <div id="container" style="height:98vh; min-width: 310px"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement