SVG chart is converted wrong with Canvg

138 Views Asked by At

When I try to convert a svg chart with Canvg, the bars of the char are missing. I think the problem might be that the svg is attached to the canvas before the bars animations are executed.

  const canvas = document.createElement('canvas');
  canvas.width = svgElement.clientWidth;
  canvas.height = svgElement.clientHeight;

  const svg = new XMLSerializer().serializeToString(svgElement);

  const ctx = canvas.getContext('2d');
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  const canvgView = await Canvg.fromString(ctx, svg);
  await canvgView.render();

Missing bars

0

There are 0 best solutions below