Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse mb-4">
  <div class="container">
    <div class="navbar-header">
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <a class="navbar-brand" href="#">GHC Client</a>
    </div>
    <div id="navbarCollapse" class="collapse navbar-collapse">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item {{navi_class_dashboard}}">
          <a class="nav-link" href="{{navi_href_dashboard}}">Dashboard</a>
        </li>
        <li class="nav-item {{navi_class_readings}}">
          <a class="nav-link" href="{{navi_href_readings}}">Readings</a>
        </li>
        <li class="nav-item {{navi_class_regulation}}">
          <a class="nav-link" href="{{navi_href_regulation}}">Regulation</a>
        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li class="nav-item {{navi_class_settings}}">
          <a class="nav-link" href="{{navi_href_settings}}">Settings</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{{navi_href_logout}}">Logout</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
<div id="content-container" class="container">
  <div class="row">
    <div class="col">
      <h1 class="section-header">Dashboard</h1>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <p>
        <strong>Outside Temperature:</strong> {{weatherdata_temp}}°C,
        <strong>Outside Humidity:</strong> {{weatherdata_hum}}%,
        <strong>Current weather conditions:</strong> {{weatherdata_summary}} (Rain Probability: {{weatherdata_rain_prob}}%)
      </p>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Temperature</h4>
      <div id="temp_charts" class="chart-block"></div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Humidity</h4>
      <div id="hum_charts" class="chart-block"></div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Soil Moisture</h4>
      <div id="soilmoisture_charts" class="chart-block"></div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Last 24h Temperature</h4>
      <div id="temp_charts_24h" class="chart-block"></div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Last 24h Humidity</h4>
      <div id="hum_charts_24h" class="chart-block"></div>
    </div>
  </div>
  <div class="row">
    <div class="col">
      <h4 class="section-header">Last 24h Soil Moisture</h4>
      <div id="soilmoisture_charts_24h" class="chart-block"></div>
    </div>
  </div>
</div>
<script type="text/javascript">
    const rpi_dht22_11_temp = 22;
    const rpi_dht22_13_temp = 23;
    const rpi_dht22_15_temp = 24;
    const rpi_dht22_11_hum = 45;
    const rpi_dht22_13_hum = 42;
    const rpi_dht22_15_hum = 53;
    const rpi_soilmoisture_0_hum = 76;
    const rpi_soilmoisture_1_hum = 77;
    const rpi_soilmoisture_2_hum = 73;
  const temp_charts_24h_data = [
    [new Date("Sun Feb 26 2017 21:40:21 GMT+0100 (CET)"), 15],
    [new Date("Sun Feb 26 2017 22:40:21 GMT+0100 (CET)"), 10],
    [new Date("Sun Feb 26 2017 23:40:21 GMT+0100 (CET)"), 23]
  ];
  const hum_charts_24h_data = [
    [0, 0],   [1, 10],  [2, 23],  [3, 17],  [4, 18],  [5, 9],
    [6, 11],  [7, 27],  [8, 33],  [9, 40],  [10, 32], [11, 35],
    [12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48],
    [18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57],
    [24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53],
    [30, 55], [31, 60], [32, 61], [33, 59], [34, 62], [35, 65],
    [36, 62], [37, 58], [38, 55], [39, 61], [40, 64], [41, 65],
    [42, 63], [43, 66], [44, 67], [45, 69], [46, 69], [47, 70],
    [48, 72], [49, 68], [50, 66], [51, 65], [52, 67], [53, 70],
    [54, 71], [55, 72], [56, 73], [57, 75], [58, 70], [59, 68],
    [60, 64], [61, 60], [62, 65], [63, 67], [64, 68], [65, 69],
    [66, 70], [67, 72], [68, 75], [69, 80]
  ];
  const soilmoisture_charts_24h_data = [
    [0, 0],   [1, 10],  [2, 23],  [3, 17],  [4, 18],  [5, 9],
    [6, 11],  [7, 27],  [8, 33],  [9, 40],  [10, 32], [11, 35],
    [12, 30], [13, 40], [14, 42], [15, 47], [16, 44], [17, 48],
    [18, 52], [19, 54], [20, 42], [21, 55], [22, 56], [23, 57],
    [24, 60], [25, 50], [26, 52], [27, 51], [28, 49], [29, 53],
    [30, 55], [31, 60], [32, 61], [33, 59], [34, 62], [35, 65],
    [36, 62], [37, 58], [38, 55], [39, 61], [40, 64], [41, 65],
    [42, 63], [43, 66], [44, 67], [45, 69], [46, 69], [47, 70],
    [48, 72], [49, 68], [50, 66], [51, 65], [52, 67], [53, 70],
    [54, 71], [55, 72], [56, 73], [57, 75], [58, 70], [59, 68],
    [60, 64], [61, 60], [62, 65], [63, 67], [64, 68], [65, 69],
    [66, 70], [67, 72], [68, 75], [69, 80]
  ];
</script>

              
            
!

CSS

              
                #content-container {
  padding-bottom: 20px;
}

.section-header {
  padding-top: 5px;
  padding-bottom: 10px;
}

.chart-block {
  padding-top: 5px;
  padding-bottom: 5px;
}

              
            
!

JS

              
                google.charts.load('current', {'packages':['gauge', 'corechart']});
google.charts.setOnLoadCallback(drawTempGauges);
google.charts.setOnLoadCallback(drawHumGauges);
google.charts.setOnLoadCallback(drawSoilMoistureGauges);
google.charts.setOnLoadCallback(drawTempChart);
google.charts.setOnLoadCallback(drawHumChart);
google.charts.setOnLoadCallback(drawSoilMoistureChart);

function drawTempGauges() {
  var data = google.visualization.arrayToDataTable([
    ['Label', 'Value'],
    ['°C', rpi_dht22_11_temp],
    ['°C', rpi_dht22_13_temp],
    ['°C', rpi_dht22_15_temp]
  ]);
  var options = {
    min: 10, max: 40,
    greenFrom: 20, greenTo: 26,
    minorTicks: 5,
    majorTicks: ["10", "15", "20", "25", "30", "35", "40"]
  };
  var chart = new google.visualization.Gauge(document.getElementById('temp_charts'));
  chart.draw(data, options);
}

function drawHumGauges() {
  var data = google.visualization.arrayToDataTable([
    ['Label', 'Value'],
    ['%', rpi_dht22_11_hum],
    ['%', rpi_dht22_13_hum],
    ['%', rpi_dht22_15_hum]
  ]);
  var options = {
    min: 0, max: 100,
    greenFrom: 20, greenTo: 26,
    minorTicks: 4,
    majorTicks: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]
  };
  var chart = new google.visualization.Gauge(document.getElementById('hum_charts'));
  chart.draw(data, options);
}

function drawSoilMoistureGauges() {
  var data = google.visualization.arrayToDataTable([
    ['Label', 'Value'],
    ['%', rpi_soilmoisture_0_hum],
    ['%', rpi_soilmoisture_1_hum],
    ['%', rpi_soilmoisture_2_hum]
  ]);
  var options = {
    min: 0, max: 100,
    greenFrom: 20, greenTo: 26,
    minorTicks: 4,
    majorTicks: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]
  };
  var chart = new google.visualization.Gauge(document.getElementById('soilmoisture_charts'));
  chart.draw(data, options);
}

function drawTempChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('datetime', 'Timestamp');
  data.addColumn('number', 'rpi-dht22-11');
  data.addRows(temp_charts_24h_data);
  var options = {
    hAxis: {
      title: 'Timestamp'
    },
    vAxis: {title: '°C'}
  };
  var chart = new google.visualization.LineChart(document.getElementById('temp_charts_24h'));  
  chart.draw(data, options);
}

function drawHumChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'Timestamp');
  data.addColumn('number', 'rpi-dht22-11');
  data.addRows(hum_charts_24h_data);
  var options = {
    hAxis: {
      title: 'Timestamp'
    },
    vAxis: {title: '%'}
  };
  var chart = new google.visualization.LineChart(document.getElementById('hum_charts_24h'));  
  chart.draw(data, options);
}

function drawSoilMoistureChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'Timestamp');
  data.addColumn('number', 'rpi-soilmoisture-0');
  data.addRows(soilmoisture_charts_24h_data);
  var options = {
    hAxis: {
      title: 'Timestamp'
    },
    vAxis: {title: '%'}
  };
  var chart = new google.visualization.LineChart(document.getElementById('soilmoisture_charts_24h'));  
  chart.draw(data, options);
}

              
            
!
999px

Console