function createGenerator(props, generator?: Line): Line { generator = generator || d3.line(); return args.reduce((acc: Line, arg) => { const prop = props[arg]; if (prop) { return acc[arg](prop); } return acc; }, generator); }
const _arc = edge => { const draw = line().curve(curveBasis); const midX = (edge.source.x + edge.target.x) / 2; const midY = (edge.source.x - edge.target.x) * 2; return draw([[edge.source.x, 0], [midX, midY], [edge.target.x, 0]]); }
function createLine({ data, curve = d3Shape.curveLinear }): string { return d3Shape.line().curve(curve)(data); }
this.container.selectAll('.link') .data(links) .enter() .append('path') .attr('fill', 'none') .attr('stroke', 'lightblue') .attr('d', d => line([ [d.y, d.x], // [d.y, (d.x + d.parent.x) / 2], // [d.parent.y, (d.x + d.parent.x) / 2], [(d.y + d.parent.y) / 2, d.x], [(d.y + d.parent.y) / 2, d.parent.x], [d.parent.y, d.parent.x]], ));
function Line(props) { const { data } = props; const lineGenerator = line() .curve(curveCatmullRom.alpha(0.5)) .x(d => d.x) .y(d => d.y); return ( <path stroke={'red'} fill={'none'} d={lineGenerator(data)} /> ); }
_createGuides() { if (!this.ticksY) { return null; } const lines = this.ticksY // don't draw guide line for 0s .filter(t => t) .map((tick) => { return d3.shape.line() .x((d) => this.scaleX(moment(d[0]).toDate())) .y((d) => -this.scaleY(d[1])) ([ [this.extentX[0], tick], [this.extentX[1], tick] ]) }) ; return lines; }
render() { const scaledPoints = this.props.chartPoints.map(this.props.scale); const d = line()(scaledPoints); const lastPoint = scaledPoints[scaledPoints.length - 1]; return (
.domain([min, max]); this.lineGenerator = d3Shape .line() .curve(curve) .x((d, i) => this.x(this.now - (limit - 1 - i) * duration))
const scaleY = createScaleY(extentY[0], extentY[1], height); const lineShape = d3.shape.line() .x(d => scaleX(xAccessor(d))) .y(d => scaleY(yAccessor(d)));
.domain([min, max]); const lineGenerator = d3Shape .line() .curve(curve) .x(d => x(d.index))
chart.selectAll('.link') .data(links) .enter() .append('path') .attr('fill', 'none') .attr('stroke', 'lightblue') .attr('d', d => line([ [d.x, d.y], [d.x, (d.y + d.parent.y) / 2], [d.parent.x, (d.y + d.parent.y) / 2], // [(d.x + d.parent.x) / 2, d.y], // [(d.x + d.parent.y) / 2, d.parent.y], [d.parent.x, d.parent.y]], ));
function createGenerator(props, generator?: Line): Line { generator = generator || d3.line(); return args.reduce((acc: Line, arg) => { const prop = props[arg]; if (prop) { return acc[arg](prop); } return acc; }, generator); }
function createLine({ data, curve = d3Shape.curveLinear }): string { return d3Shape.line().curve(curve)(data); }
.domain([min, max]); this.lineGenerator = d3Shape .line() .curve(curve) .x((d, i) => this.x(this.now - (limit - 1 - i) * duration))