my charts getting smaller automatically

48 views
Skip to first unread message

sai reddy

unread,
Aug 19, 2020, 5:11:03 AM8/19/20
to Google Visualization API
import React, { useState, useEffect, Fragment } from "react";
import { Chart } from "react-google-charts";
import {DownloadOutlined} from '@ant-design/icons';
import Button from './Button';

const GoogleBubble = ({ hAxisLabel, vAxisLabel, chartData, chartTitle, printOption }) => {
const [chartWrapper, setChartWrapper] = useState(null);

print = () => {
let element = document.createElement("a");
if (chartWrapper === null) {
console.error("ChartWrapper not ready yet");
}
const image = chartWrapper.getChart().getImageURI();
element.href = image;
element.download = "chart.png";
element.click();
};

return (
<Fragment>
<div style={{textAlign:"right"}}>
{chartWrapper !== null && printOption && (
<Button onClick={print} download className="chart-download-button">
Download Chart<DownloadOutlined />
</Button>
)}
</div>
<Chart
width={"100%"}
height={"500px"}
chartType="BubbleChart"
loader={<div>Loading Chart</div>}
data={chartData}
options={{
title:`${chartTitle}`,
chartArea:{width:"70%",height:"80%"},
hAxis: {
title: `${hAxisLabel}`,
viewWindow: {
min: 0,
max: 100,
},
},
legend: {
position: "right",
textStyle: { color: "blue", fontSize: 16 },
},
animation: {
duration: 2000,
easing: "out",
startup: true,
},
series: {
Positive: { color: "#98D880" },
Negative: { color: "#cd5c5c" },
},
vAxis: {
title: `${vAxisLabel}`,
viewWindow: {
min: 0,
max: 100,
},
},
tooltip: {
// isHtml: true,
trigger: "both",
},
selectionMode: "multiple",
bubble: {
textStyle: { fontSize: 10, auraColor: "none", color: "#000" },
},
sizeAxis: { minSize: 20, maxSize: 50 },
}}
getChartWrapper={(chartWrapper) => {
setChartWrapper({ chartWrapper });
}}
/>
</Fragment>
);
};
export default GoogleBubble;

Screenshot 2020-08-19 at 2.39.57 PM.png
Screenshot 2020-08-19 at 2.40.04 PM.png
Reply all
Reply to author
Forward
0 new messages