Public
Edited
Apr 13, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
<div class="flex-parent-element">
<div class="flex-child-element magenta">
${createChart(finalJson)}
</div>
<div class="flex-child-element green">
<div id="app1"></div>
<div id="app2"></div>
</div>
</div>
Insert cell
// function renderApp() {
// const randomId = Array.from(randomImageByTopicsMap.keys())[Math.floor(Math.random() * randomImageByTopicsMap.size)];
// ReactDOM.render(
// React.createElement(Gallery, { id: randomId }),
// document.getElementById("app1")
// );
// }
Insert cell
dispatch.on("circle-clicked", (obj) => {
ReactDOM.render(
React.createElement(Gallery, obj),
document.getElementById(obj.tag)
);
});
Insert cell
Insert cell
<style>
.flex-parent-element {
display: flex;
width: 100%;
align-items: center; /* add this */
}

.flex-child-element {
flex: 1;
/* border: 2px solid black; */
margin: 0px;
}

.flex-child-element:first-child {
margin-right: 10px;
flex-basis: 20%;
}
.flex-child-element.green {
height: 100%;
/* justify-content: center; */
}
</style>
Insert cell
// {
// const randomId = Array.from(randomImageByTopicsMap.keys())[Math.floor(Math.random() * randomImageByTopicsMap.size)];
// ReactDOM.render(
// React.createElement(Gallery, { id: randomId }),
// document.getElementById("app2")
// );
// }
Insert cell
// function wrapperApp() {
// React.useEffect(() => {
// renderApp();
// }, [randomImageByTopicsMap]);

// return React.createElement("div", { id: "app1" });
// }
Insert cell
// ReactDOM.render(React.createElement(wrapperApp), document.getElementById("app1"));

Insert cell
// renderApp();
Insert cell
// function renderApp() {
// const randomId = Array.from(randomImageByTopicsMap.keys())[Math.floor(Math.random() * randomImageByTopicsMap.size)];
// ReactDOM.render(
// React.createElement(Gallery, { id: randomId }),
// document.getElementById("app1")
// );
// }
Insert cell
// dispatch.on("circle-clicked", (id) => {
// ReactDOM.render(
// React.createElement(Gallery, { id }),
// document.getElementById("app1")
// );
// });
Insert cell
Insert cell
<!-- <div id="app1"></div> -->
Insert cell
Insert cell
<!-- <style>
.image-container {
position: relative;
overflow: hidden;
width: 100%;
height: 0;
padding-bottom: 60%; /* 4:3 aspect ratio */
}

.image-container img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}

.image-container .caption {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
background-color: rgba(0, 0, 0, 0.5);
color: #fff;
padding: 0px;
box-sizing: border-box;
max-height: 50px;
overflow-y: scroll;
}
</style> -->
Insert cell
Insert cell
// {
// let idQueue = [];
// function addIdToQueue(id) {
// // Check if ID already exists in the queue
// for (let i = 0; i < idQueue.length; i++) {
// if (idQueue[i].id === id) {
// console.log(`ID ${id} already exists in the queue`);
// return;
// }
// }

// // Assign color to new object based on color of previous object
// let color;
// let divTag;
// if (idQueue.length === 0) {
// color = "green";
// divTag = "app1";
// } else if (idQueue[idQueue.length - 1].color === "green") {
// color = "red";
// divTag = "app2";
// } else {
// color = "green";
// divTag = "app1";
// }

// // Add new object to queue
// if (idQueue.length < 2) {
// idQueue.push({ id: id, color: color, divTag: divTag });
// } else {
// // Replace oldest object with new object
// idQueue[0] = idQueue[1];
// idQueue[1] = { id: id, color: color, divTag: divTag };
// }

// console.log(`ID ${id} added to queue with color ${color} and divTag ${divTag}`);
// }
// addIdToQueue(1);
// addIdToQueue(2);
// addIdToQueue(2);
// addIdToQueue(1);
// addIdToQueue(3);
// addIdToQueue(1);
// addIdToQueue(2);
// return idQueue;
// }
Insert cell
margin = ({top: 25, right: 50, bottom: 10, left: 7.5})
Insert cell
dy = width / 2.4
Insert cell
dx = 50
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
dispatchImg = d3.dispatch("img-clicked");
Insert cell
diagonal = d3.linkHorizontal().x(d => d.y).y(d => d.x)
Insert cell
tree = d3.tree().nodeSize([dx, dy])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// margin = ({top: 10, right: 120, bottom: 10, left: 40})
Insert cell
d3 = require("d3@6")
Insert cell
import {render, component, jsx, memo, forwardRef, React, ReactDOM, createElement, Children, createRef, createContext, lazy, Fragment, StrictMode, Suspense, cloneElement, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState, useDebugValue, createPortal, __SECRET_SWITCHER} from "@j-f1/react"
Insert cell
import {Range, pack} from "@esperanc/range-input-variations"
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