Public
Edited
Insert cell
Insert cell
Insert cell
footprint_svg_node = {
const dpi = dims.dpi;
const scale = v => Math.round(v * dpi * 1/3);
const width = Math.round(dims.width_in_inches * dpi/3);
const height = Math.round(dims.height_in_inches * dpi/3);
const marginx = 5;
const marginy = 5.5;

const svg = d3
.select(DOM.svg(width, height))
.style('display', 'block')
.style('background', 'ivory');

const rect_elems = svg
.selectAll('rect')
.data(design_elems.footprint.rects)
.join('rect')
.attr('fill', 'none')
.attr('stroke', d => d.c ? d.c : 'blue')
.attr('x', d => d.name == 'fullsize' || d.name == 'telephone_pole' ? scale(d.x) : scale(d.x+marginx))
.attr('y', d => d.name == 'fullsize' || d.name == 'telephone_pole' ? scale(d.y) : scale(d.y+marginy))
.attr('width', d => scale(d.w))
.attr('height', d => scale(d.h));

const polyline_points = design_elems.footprint.polylines.map(({name, points, c}) => {
return ({name, c, points: points.map(([x,y]) => `${scale(x+marginx)},${scale(y+marginy)}`).join(' ')});
});
const polylines = svg
.selectAll('polyline')
.data(polyline_points)
.join('polyline')
.attr('fill', 'none')
.attr('stroke', d => d.c ? d.c : 'blue')
.attr('points', d => d.points);

return svg.node();
}
Insert cell
Insert cell
design_elems = ({
footprint: ({
rects: rects,
polylines: poly,
})
})
Insert cell
step_width = 1
Insert cell
rects = [
{name: 'fullsize', x:0, y:0, w:32.333, h:34.5, c:'red'},
{name: 'telephone_pole', x:2, y:3, w:0.5, h:0.5, c:'brown'},
{name: 'bath_lr_wall', x:3.5+step_width*6+1.333, y:15, w:0.5, h:1.167, c:'red'},
{name: 'bathroom_wall', x:0, y:11.5, w:4.667, h:0.5, c:'red'},
{name: 'bedroom_wall', x:10.667, y:0, w:0.5, h:8.667, c:'red'},
{name: 'bedroom_bath_wall', x:7.333, y:11.5, w:3.833, h:0.5, c:'red'},
{name: 'closet_back', x:6, y:16.667, w:0.5, h:2.85, c:'red'},
{name: 'landing_wall', x:0, y:16.167, w:3.5, h:0.45, c:'red'},
{name: 'slide_br', x:5.833, y:11.7, w:2, h:0.15, c:'black'},
{name: 'slide_shower', x:3, y:16.333, w:2, h:0.125, c:'black'},
{name: 'washer_wall', x:5.5, y:16.167, w:5.833, h:0.45, c:'red'},
{name: 'outer_stair_wall', x:0, y:23.025, w:3.5+step_width*6, h:0.425, c:'red'},
{name: 'stair_wall', x:3.5, y:19.58, w:step_width*6, h:0.475, c:'red'},
{name: 'stair1', x:3.5+(0*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair2', x:3.5+(1*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair3', x:3.5+(2*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair4', x:3.5+(3*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair5', x:3.5+(4*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair6', x:3.5+(5*step_width), y:20.083, w:step_width, h:2.917, c:'green'},
{name: 'stair_landing', x:0, y:16.667, w:3.5, h:6.333, c:'green'},
// {name: 'closet', },
]
Insert cell
poly = [
{name: 'adu_footprint', points: [
[0,0],[19.833,0],[22.333,2.5],
[22.333,11.5],[25.333,11.5],[25.333,18],[22.333,18], // Window seat
[22.333,20.667],[13.667,20.667],
[13.667,23.5],[0,23.5],
[0,0],
]},
{name: 'upper_left_corner', points: [
[0,0.75],[0.25,0.75],[0.25,0.25],[0.75,0.25],[0.75,0],[0,0],[0,0.75]
], c: 'red'},
{name: 'upper_right_corner', points: [
[19.333,0],[19.333,0.25],[19.820, 0.25],[22.08,2.5],[22.08,2.75],[22.333,2.75],[22.333,2.5],[19.820,0],[19.333,0]
], c: 'red'},
{name: 'lower_left_corner', points: [
[0,22.75],[0.25,22.75],[0.25,23],[0,23]
], c: 'red'},
{name: 'bookcase', points: [
[22.333,11.75],[25.083,11.75],
[25.083,13],[22.333,13],
[22.333,11.75],
], c: 'brown'},
{name: 'seat', points: [
[22.333,16],[25.083,16],
[25.083,17.75],[22.333,17.75],
[22.333,16],
], c: 'brown'},
{name: 'shower', points: [
[0.5,12.25],[3,12.25],
[3,16],[0.5,16],
[0.5,12.25],[3,16],
[3,12.25],[0.5,16],
], c: 'brown'},
{name: 'washer', points: [
[1,16.833],[3.5,16.833],
[3.5,19.167],[1,19.167],
[1,16.833],[3.5,19.167],
[3.5,16.833],[1,19.167],
], c: 'brown'},
]
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more