Public
Edited
Jun 7, 2023
1 fork
Insert cell
Insert cell
heatJson = FileAttachment("heat.json").json();
Insert cell
coorSensorJson = FileAttachment("coor_sensor.json").json()
Insert cell
sensorPlaceJson = FileAttachment("sensor_place@1.json").json()
Insert cell
background1 = FileAttachment("Sensor Distribution Map-Floor 1.png").image({width: 400, style: "border: 1px solid black"});
Insert cell
background2 = FileAttachment("Sensor Distribution Map-Floor 2.png").image({width: 400, style: "border: 1px solid black"});
Insert cell
heatConfig = {
return {
"graph": {
"eid": "heat_graph",
"x10": 84 / 1986,
"y10": 64 / 1132,
"x11": 1838 / 1986,
"y11": 983 / 1132,
"x20": 89 / 1977,
"y20": 64 / 1115,
"x21": 1816 / 1977,
"y21": 971 / 1115,
"x_len": 16,
"y_len": 30,
"max_color": "#ff0000",
"max_number": 2500,
"min_color": "#ffffff",
}
}
}
Insert cell
function cnt2Ratio(cnt) {
let ret = Math.log2(cnt / heatConfig.graph.max_number + 1);
return Math.min(1, ret);
}
Insert cell
function getBoxes(floor) {
let xOffset, yOffset;
let xEdge, yEdge;
if (floor === 1) {
xOffset = heatConfig.graph.x10 * background1.width;
let xEnd = heatConfig.graph.x11 * background1.width;
xEdge = (xEnd - xOffset) / heatConfig.graph.y_len;
yOffset = heatConfig.graph.y10 * background1.height;
let yEnd = heatConfig.graph.y11 * background1.height;
yEdge = (yEnd - yOffset) / heatConfig.graph.x_len;
}
else {
xOffset = heatConfig.graph.x20 * background2.width;
let xEnd = heatConfig.graph.x21 * background2.width;
xEdge = (xEnd - xOffset) / heatConfig.graph.y_len;
yOffset = heatConfig.graph.y20 * background2.height;
let yEnd = heatConfig.graph.y21 * background2.height;
yEdge = (yEnd - yOffset) / heatConfig.graph.x_len;
}
var ret = []
for (let j = 0; j < heatConfig.graph.x_len; j++) {
for (let i = 0; i < heatConfig.graph.y_len; i++) {
ret.push([xOffset + i * xEdge, yOffset + j * yEdge, xOffset + (i + 1) * xEdge, yOffset + (j + 1) * yEdge]);
}
}
return ret;
}
Insert cell
function getCoorId(x, y) {
return floor.toString() + "_" + x.toString() + "_" + y.toString();
}
Insert cell
boxes = [undefined, getBoxes(1), getBoxes(2)]
Insert cell
viewof day = Inputs.radio(["Day1", "Day2", "Day3"], {label: "Day", value: "Day1"}, )
Insert cell
viewof hour = Inputs.range([0, 23], {value: 12, step: 1, label: "Hour"})
Insert cell
Insert cell
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