Skip to content

Commit

Permalink
added comments to highlight the sections
Browse files Browse the repository at this point in the history
  • Loading branch information
SutarPrasad committed Aug 9, 2023
1 parent ac249c0 commit 302df95
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/MultiSiteLineChart/MultiSiteLineChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@ import FileDownloadOutlinedIcon from '@mui/icons-material/FileDownloadOutlined';
import { Button } from "@mui/material";

class MultiSiteLineChart extends React.Component {

// used to create pdf object and download the image of the chart as pdf
handleDownloadPDF = () => {
// Here we fetch the html element of chart-container that needs to be downloaded by id.
const chartContainer = document.getElementById("chart-container");

// Check if chartContainer exists before proceeding
if (chartContainer) {
html2canvas(chartContainer).then((canvas) => {
const imgData = canvas.toDataURL("image/jpeg");

// Get the dimensions of the chart
const chartWidth = chartContainer.offsetWidth;
const chartHeight = chartContainer.offsetHeight;

// Create a new PDF document with the size of the chart
const pdf = new jsPDF({
orientation: chartWidth > chartHeight ? "landscape" : "portrait",
unit: "mm",
format: [chartWidth, chartHeight],
});

// Add the image of the chart to the PDF
pdf.addImage(imgData, "JPEG", 0, 0, chartWidth, chartHeight);

// Save the PDF
pdf.save("concentrationTime_OpenghgPlot.pdf");
});
} else {
Expand Down Expand Up @@ -114,6 +112,8 @@ class MultiSiteLineChart extends React.Component {

const widthScaleFactor = 0.925;


// This specifies various plot elements that needs to be supplied as argument to <Plot>
const layout = {
title: {
text: this.props.title ? this.props.title : null,
Expand Down

0 comments on commit 302df95

Please sign in to comment.