Skip to content

Commit

Permalink
feat(renderer): Add support for direct arc-based segments
Browse files Browse the repository at this point in the history
  • Loading branch information
David Emory committed Apr 10, 2018
1 parent 1b471af commit 0d14d2f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/renderer/renderedsegment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import d3 from 'd3'
import { forEach } from 'lodash'

import interpolateLine from '../util/interpolate-line'

import { distance } from '../util'
/**
* RenderedSegment
*/
Expand Down Expand Up @@ -85,6 +85,19 @@ export default class RenderedSegment {
})
}

// Check if this segment is to be drawn as an arc; if so replace render data
if (this.pathSegment.journeySegment && this.pathSegment.journeySegment.arc) {
const first = this.renderData[0]
const last = this.renderData[this.renderData.length - 1]
const arc = {
x: last.x,
y: last.y,
arc: -45,
radius: distance(first.x, first.y, last.x, last.y)
}
this.renderData = [first, arc, last]
}

var lineData = this.line(this.renderData)
this.lineGraph.attr('d', lineData)
this.lineGraphFront.attr('d', lineData)
Expand Down

0 comments on commit 0d14d2f

Please sign in to comment.