1

I'm trying to convert a d3.js visualization to canvas. The d3.js code can be found here: https://gist.github.com/3166265

Could somebody explain the basics of converting this visualization to canvas? I cannot use a program like canvg because the browser I'm targeting (android platform 2.3) cannot parse any SVG AT ALL. Therefore I need to convert this visualizatoin to Canvas. Any help that you can provide would be most appreciated...

Wex
  • 15,539
  • 10
  • 64
  • 107
Apollo
  • 8,874
  • 32
  • 104
  • 192
  • Are you familiar with JavaScript? Do you know how to use d3? – Wex Jul 23 '12 at 22:54
  • neither as well as you. I picked up js and d3 about 2 or 3 weeks ago. If you can point me to a tutorial on how to do this I'd appreciate it. – Apollo Jul 24 '12 at 13:54
  • @wex currently trying to just do this server side. http://stackoverflow.com/questions/11632748/svg-to-png-server-side-using-node-js – Apollo Jul 24 '12 at 14:12
  • possible duplicate of [Pushing D3.js output through fabric.js for IE8 support?](http://stackoverflow.com/questions/17817882/pushing-d3-js-output-through-fabric-js-for-ie8-support) – Paul Sweatte Apr 25 '14 at 20:16
  • If you can't parse SVG I don't think you can get it into the canvas. Typical solutions look like this: var svg = d3.select("#svgdiv").node().parentNode.innerHTML; var img = new Image; img.onload = function(){ var canvas = document.createElement('canvas'); //Explicitly setting the w/h seems to work better for me. canvas.width = this.width||960; canvas.height = this.height||500; canvas.getContext('2d').drawImage(this, 0,0); //document.body.appendChild(canvas); } SVG is basically just XML, can you show as a string? – nighliber Oct 05 '15 at 16:24

0 Answers0