.chartContainer {
position: relative;
margin: auto;
height:500px;
width:500px;
 }
JavaScript
var graphData = {
type: "line",
data: {
labels: ['Feb','Mar','Apr','May','Jun','Jul'],
datasets: [{
data: [86,98,78,82,99,80],
label: "Effort Ratio",
borderColor: "#3e95cd",
fill: '+2',
lineTension: 0.2
}
]
},
options: {
title: {
display: false,
text: 'World population per region (in millions)'
}
}
}
var context = document.getElementById("radarCanvas").getContext("2d");
var radarChart = new Chart(context, graphData); // Works fine
// tweak the lib according to sspecht @ https://stackoverflow.com/questions/45563420/exporting-chart-js-charts-to-svg-using-canvas2svg-js
// deactivate responsiveness and animation
graphData.options.responsive = false;
graphData.options.animation = false;
// canvas2svg 'mock' context
var svgContext = new C2S(600,300);
// new chart on 'mock' context fails:
var mySvg = new Chart(svgContext, graphData);
// Failed to create chart: can't acquire context from the given item
var svg_chart = svgContext.getSerializedSvg(true);
console.log(svgContext.getSerializedSvg(true));
$(".svgContainer").html(svg_chart);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.