Skip to content

Instantly share code, notes, and snippets.

@Akiyamka
Last active September 13, 2018 12:48
Show Gist options
  • Select an option

  • Save Akiyamka/730a34b1dd642ba463d5d13cad4d4b7f to your computer and use it in GitHub Desktop.

Select an option

Save Akiyamka/730a34b1dd642ba463d5d13cad4d4b7f to your computer and use it in GitHub Desktop.
D3 migration tips (3 -> 5)
  • scale.linear -> scaleLinear
  • d3.time.format -> d3.timeFormat
  • d3.time.scale -> d3.scaleTime
  • d3.svg.line -> d3.line
  • d3.svg.brush().x() -> d3.brushX()
  • d3.svg.brush().y() -> d3.brushY()
  • d3.svg.brush().x().y() -> d3.brush() ???

https://github.com/d3/d3/blob/master/CHANGES.md#brushes-d3-brush

extent([[xScale.range()[0], 0], [xScale.range()[1], brushHeight]])
  • brushstart -> start
  • brushend -> end
  • d3.svg.axis().scale( y ).orient( 'left' ); -> d3.axisLeft(y)
  • d3.svg.axis().scale( y ).orient( 'right' ); -> d3.axisRight(y)
  • d3.svg.axis().scale( x ).orient( 'bottom' ); -> d3.axisBottom(x)
  • d3.svg.axis().scale( x ).orient( 'top' ); -> d3.axisTop(x)
  • d3.layout.histogram.value(d => d.value).bins( x.ticks( 24 ))
    => d3.histogram(d -> d.value).thresholds(x.ticks( 24 ))
  • this.chart.brush.empty() -> d3.event.selection === null

more https://stackoverflow.com/questions/42781226/d3-js-v3-to-v4-brush-changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment