Skip to content

Commit

Permalink
[client] debug font size issue un export image
Browse files Browse the repository at this point in the history
fixes #213
  • Loading branch information
paulgirard committed Apr 14, 2023
1 parent e11e979 commit ef7a157
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/js/lib/exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,26 @@ export function exportIndicatorsChart({vizContainer, legend, name, mode}) {
// add legend to the viz container to include it in the snapshot
const legendClone = legend.cloneNode(true);
vizContainer.appendChild(legendClone);

vizContainer.className = vizContainer.className + ' export-image';
const options = {
style: {margin: 0, display: 'flex', 'flex-direction': 'column'},
style: {
'margin-top': '1px',
'margin-left': '1px',
},
bgcolor: '#FFF',
};
if (mode === 'PNG')
return d2i.toBlob(vizContainer, options).then(blob => {
// remove the legend
vizContainer.removeChild(legendClone);
vizContainer.className = vizContainer.className.replace(' export-image', '');
return saveAs(blob, name);
});
if (mode === 'SVG')
return d2i.toSvg(vizContainer, options).then(finalSvg => {
// remove the legend
vizContainer.removeChild(legendClone);
vizContainer.className = vizContainer.className.replace(' export-image', '');
return saveAs(
new Blob([finalSvg.replace('data:image/svg+xml;charset=utf-8,', '')], {type: 'text/svg;charset=utf-8'}),
name,
Expand Down
7 changes: 7 additions & 0 deletions client/style/components/04-templates/_section-viz.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
&-expand {
margin-bottom: 3.3em;
}

&.export-image {
svg {
font-family: Arial, Helvetica, sans-serif !important;
font-size: 12px !important;
}
}
}

// Content Viz with .box-selection
Expand Down

0 comments on commit ef7a157

Please sign in to comment.