Export Code
Connected
index.js
import { select, range } from 'd3';
import { makeData } from './makeData.js';
import { vizDraw } from './vizDraw.js';

const width = window.innerWidth;
const height = window.innerHeight / 2;

const svg = select('body')
.append('svg')
.attr('width', width)
.attr('height', height);

const svg2 = select('body')
.append('svg')
.attr('width', width)
.attr('height', height);

svg2
.append('rect')
.attr('width', width)
.attr('height', height)
.attr('fill', 'black');

let t = 0;

setInterval(() => {
const n = 10 + Math.sin(t) * 5;

const data = makeData(n, t, 10, Math.sin);
const data2 = makeData(n, t, 15, Math.cos);

svg.call(vizDraw, data);
svg2.call(vizDraw, data2, 'white');

t = t + 0.02;
}, 1000 / 60);

D3 Selections

Kaustav Sen

Last edited May 26, 2021
Created on May 20, 2021
Forked from HTML Starter
MIT Licensed