Skip to content

Instantly share code, notes, and snippets.

@mpayetta
Created March 28, 2018 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpayetta/516b56a7b6ff4c54bc3e974ad523603f to your computer and use it in GitHub Desktop.
Save mpayetta/516b56a7b6ff4c54bc3e974ad523603f to your computer and use it in GitHub Desktop.
d3-canvas-5
const container = d3.select('.scatter-container');
// Init SVG
const svgChart = container.append('svg:svg')
.attr('width', outerWidth)
.attr('height', outerHeight)
.attr('class', 'svg-plot')
.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
// Init Canvas
const canvasChart = container.append('canvas')
.attr('width', width)
.attr('height', height)
.style('margin-left', margin.left + 'px')
.style('margin-top', margin.top + 'px')
.attr('class', 'canvas-plot');
const context = canvasChart.node().getContext('2d');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment