screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useEffect } = React; const PieChart = () => { useEffect(() => { google.charts.load('current', { packages: ['corechart'] }); google.charts.setOnLoadCallback(drawChart); function drawChart() { const data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Coding', 8], ['Meetings', 2], ['Research', 4], ['Testing', 3], ['Documentation', 2], ['Breaks', 1], ]); const options = { title: 'Daily Work Distribution', width: 550, height: 400 }; const chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data, options); } }, []); return ( <div> <div id="piechart" style={{ width: '550px', height: '400px' }}></div> </div> ); } function App() { return ( <div className='container'> <h3>React Js Google Pie Chart</h3> <PieChart /> </div> ); } ReactDOM.render(<App />, document.getElementById('app')); </script> <style> /* Style the container */ .container { max-width: 600px; margin: 0 auto; padding: 20px; text-align: center; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } </style> </body> </html>