3👍
✅
You just need to modify the existing code mentioned in the fiddle with following code. This might help you work with v2.
animation: {
onComplete: function(data) {
var getParentIdName = this.chart.canvas.attributes.id.value,
targetElement = document.getElementById("virtual-chart-axis"),
sourceElement = document.getElementById("organizational-view"),
sourceCanvas = this.chart.ctx.canvas,
copyWidth = this.scales["y-axis-0"].width, // we are copying the width of actual chart
copyHeight = this.chart.height, // we are copying the width of actual chart
targetElementWidth = sourceElement.getContext("2d").canvas.clientWidth,
targetElementHeight = sourceElement.getContext("2d").canvas.clientHeight,
targetCtx = targetElement.getContext("2d");
targetCtx.canvas.width = copyWidth;
targetCtx.canvas.height = copyHeight;
targetCtx.drawImage(sourceCanvas, 0, 0, targetElementWidth, targetElementHeight);
}
}
Good Luck.
Source:stackexchange.com