Closed curran closed 6 years ago
As far as developer comfort goes, this would be a huge improvement.
As far as additional complexity, the impact is minimal.
Example usage:
const initState = selection => { const g = selection.append('g'); const xAxisG = g.append('g'); const yAxisG = g.append('g'); const xScale = ({ data, innerWidth, xValue }) => scaleLinear() .domain([0, max(data, xValue)] .range([0, innerWidth]); xScale.dependencies = 'data, innerWidth, xValue'; const yScale = ({ data, innerHeight, yValue }) => scaleBand() .domain(data.map(yValue)) .range([0, innerHeight]); yScale.dependencies = 'data, innerHeight, yValue'; const marks = ({ data, xScale, yScale, xValue, yValue }) => { const circles = g.selectAll('circle').data(data); circles.enter().append('circle') .merge(circles) .attr('cx', d => xScale(xValue(d))) .attr('cy', d => yScale(yValue(d))); }; marks.dependencies = 'data, xScale, yScale'; // const marks = props => circleMarks(g, props); // marks.dependencies = 'data, xScale, yScale'; // const marks = curry(circleMarks)(g); // marks.dependencies = 'data, xScale, yScale'; return Topologica({ xScale, yScale, marks }); }; const stateLocal = local(); const state = selection => stateLocal.get(selection.node()) || stateLocal.set(selection.node(), initState(selection)); const scatterPlot = (selection, props) => { state(selection).set(props); };
As far as developer comfort goes, this would be a huge improvement.
As far as additional complexity, the impact is minimal.
Example usage: