Commit 1864ad15 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

new capture setup/teardown

parent 33a0910c
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
function update() { function update() {
scatterplot.update({ scatterplot.update({
values: generateRandomData(1000, -10000, 10000), values: generateRandomData(2000, -10000, 10000),
categories: { name: 'Gender', 0: 'male', 2: 'female', 1: 'N/A'}, categories: { name: 'Gender', 0: 'male', 1: 'female', 2: 'N/A'},
title: 'Scatterplot', title: 'Scatterplot',
xAxisLabel: 'X Axis Values', xAxisLabel: 'X Axis Values',
yAxisLabel: 'Y Axis Values', yAxisLabel: 'Y Axis Values',
......
...@@ -22,8 +22,10 @@ export default class { ...@@ -22,8 +22,10 @@ export default class {
this.render(args); this.render(args);
} }
prepareSVGForCapture() { captureSetup() {
throw Error('prepareSVGForCapture() not implemented.'); }
captureTeardown() {
} }
get containerWidth() { get containerWidth() {
...@@ -35,6 +37,7 @@ export default class { ...@@ -35,6 +37,7 @@ export default class {
} }
toPNG() { toPNG() {
this.captureSetup();
html2canvas(this.container).then((canvas) => { html2canvas(this.container).then((canvas) => {
const img = canvas.toDataURL('image/png'); const img = canvas.toDataURL('image/png');
const a = document.createElement('a'); const a = document.createElement('a');
...@@ -43,6 +46,7 @@ export default class { ...@@ -43,6 +46,7 @@ export default class {
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
document.body.removeChild(a); document.body.removeChild(a);
this.captureTeardown();
}); });
} }
} }
...@@ -48,10 +48,6 @@ export default class extends Chart { ...@@ -48,10 +48,6 @@ export default class extends Chart {
return 'heatmap'; return 'heatmap';
} }
prepareSVGForCapture() {
return this.svg;
}
prepareValues({ values, rows, cols }) { prepareValues({ values, rows, cols }) {
this.data = []; this.data = [];
rows.forEach((row, i) => { rows.forEach((row, i) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment