smith = props => {
const $ = React.createElement;
const SC = smithChart.chart($);
const root = document.createElement('div');
const r = (props && props.r) || 256;
const dark = document.body.classList.contains("observablehq--dark");
const tree = $('div', {},
$('svg', {width: 2 * r + 3, height: 2 * r + 3},
$('defs', {},
$('style', {}, `
.plot0 { fill: none; stroke: #0af; stroke-width: 2; stroke-linejoin: round; }
.plot1 { fill: none; stroke: #f50; stroke-width: 2; stroke-linejoin: round; }
.plot2 { fill: none; stroke: #3a3; stroke-width: 2; stroke-linejoin: round; }
.plot3 { fill: none; stroke: #a3a; stroke-width: 2; stroke-linejoin: round; }
.l1 { stroke: ${dark ? '#fff' : '#000'}; fill: none; stroke-linecap: round; }
.l2 { stroke: ${dark ? '#777' : '#aaa'}; fill: none; stroke-linecap: round; }`
)
),
$('g', {transform: `translate(${2 * r + 1}, ${r + 1})`},
$(SC.Grid.Re, {r: r, lines: SC.grid}),
$(SC.Grid.Im, {r: r, lines: SC.grid}),
$('g', {transform: `translate(${-r})`},
props.data.map((dat, i) =>
$('path', {
className: 'plot' + i,
d: 'M' + dat.map(e => {
const G = circleCircleIntersect(reactanceCircle(e[2]), resistanceCircle(e[1]))
return [r * G[0], -r * G[1]];
}).join(' ')
})
)),
$(SC.ReLabels, { r: r, lines: SC.reLabels0 })
)
)
);
ReactDOM.render(tree, root);
return root;
}