Skip to content

Commit

Permalink
Adjusting PNG Plot Download in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
zain55337 committed Sep 7, 2023
1 parent fda235c commit 7049c48
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/javascript/components/Chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ const Chart = ({

const downloadChart = (downloadType) => {
if (downloadType === "png") {
htmlToImage
.toBlob(document.getElementById("canvasChart"))
.then(function (blob) {
saveAs(blob, "canvasChart.png");
});
const canvasChart = document.getElementById("canvasChart");
canvasChart.toBlob(function (blob) {

Check warning on line 30 in src/javascript/components/Chart.jsx

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function
saveAs(blob, "canvasChart.png");
});
} else if (downloadType === "svg") {
htmlToImage
.toSvg(document.getElementById("canvasChart"))
.toSvg(document.getElementById("canvasChartDiv"))
.then(function (blob) {

Check warning on line 36 in src/javascript/components/Chart.jsx

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function
saveAs(blob, "canvasChart.svg");
});
Expand Down Expand Up @@ -151,21 +150,23 @@ const Chart = ({
</div>
</div>
<div className="col-md-8 col-xs-12">
{windowWidth < 500 ? (
<canvas
width="800"
height="800"
ref={chartRef}
id="canvasChart"
/>
) : (
<canvas
width="400"
height="200"
ref={chartRef}
id="canvasChart"
/>
)}
<div id="canvasChartDiv">
{windowWidth < 500 ? (
<canvas
width="800"
height="800"
ref={chartRef}
id="canvasChart"
/>
) : (
<canvas
width="400"
height="200"
ref={chartRef}
id="canvasChart"
/>
)}
</div>
<div className="col-md-12">
<Button
variant="primary"
Expand Down

0 comments on commit 7049c48

Please sign in to comment.