Published
Edited
Dec 8, 2020
Fork of Calling API
Insert cell
md`# Compare Sensor Data`
Insert cell
urltemp = "https://mqtt.boomgrowfarms.com/sensor/temp-view"
Insert cell
urlrh = "https://mqtt.boomgrowfarms.com/sensor/rh-view"
Insert cell
urlco2 = "https://mqtt.boomgrowfarms.com/sensor/co2-view"
Insert cell
urleco2 = "https://mqtt.boomgrowfarms.com/sensor/eco2-view"
Insert cell
md `Disable CORS in nginx with

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

Get json
response2 = await d3.json(url)

Slice and format for charts with .map

name : id
value : co2 values
`
Insert cell
d3 = require("d3@5")
Insert cell
co2 = await d3.json(urlco2)
Insert cell
eco2 = await d3.json(urleco2)
Insert cell
rh = await d3.json(urlrh)
Insert cell
te = await d3.json(urltemp)
Insert cell
co2format = co2.rows.map(function(d) {
return {
name: d.key,
value: d.value.co2
}
})
Insert cell
eco2format = eco2.rows.map(function(d) {
return {
name: d.key,
value: d.value.co2
}
})
Insert cell
import {chart as co2_chart} with { co2format as data } from '@d3/bar-chart'
Insert cell
import {chart as eco2_chart} with { eco2format as data } from '@d3/bar-chart'
Insert cell
md `## SCD30 CO2 Charts`
Insert cell
co2_chart
Insert cell
md `## SGP30 eCO2 charts`
Insert cell
eco2_chart

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more