Here is an example of Bar Chart. I want to print this bar chart in browser, for that i tried react-to-print but it is throwing error like react-to-print only works with class components.
import React from "react";
import { Bar } from "react-chartjs-2";
// dataset for bar chart
const data = {
// goes onto X-axis
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fill: false,
// background color
backgroundColor: "rgba(75,192,192,0.4)",
// border color
borderColor: "rgba(75,192,192,1)",
// goes onto y-axis
data: [65, 59, 80, 81, 56, 55, 40]
}
]
};
const options={
//options for bar chart
};
export const BarDemo = () => {
return (
<div>
<h2>Bar Example</h2>
<Bar data={data} />
</div>
);
};