Advertisement
RemcoE33

Chart - HTML

Sep 17th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.21 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <base target="_top" />
  5.     <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.1/chart.min.js"></script>
  6.     <title>Chart</title>
  7.   </head>
  8.   <body>
  9.     <div class="container">
  10.       <canvas id="myChart"></canvas>
  11.     </div>
  12.  
  13.     <script>
  14.       let myChart = document.getElementById("myChart").getContext("2d");
  15.       function passData(sheetData){
  16.       let data = {
  17.         labels: sheetData.labels,
  18.         datasets: [
  19.           {
  20.             label: sheetData.ticker,
  21.             data: sheetData.data,
  22.           },
  23.         ],
  24.       };
  25.       let popChart = new Chart(myChart, {
  26.         type: "line",
  27.         data: data,
  28.         options: {
  29.           responsive: true,
  30.           plugins: {
  31.             legend: {
  32.               position: "top",
  33.             },
  34.             title: {
  35.               display: false,
  36.               text: sheetData.ticker,
  37.             },
  38.           },
  39.         },
  40.       });
  41.       }
  42.      
  43.       google.script.run.withSuccessHandler(passData).getChartData();
  44.  
  45.       //let sheetData = { ticker: "AAPL", data: [1, 4, 6, 8], labels: ['2021-01-01','2021-02-01','2021-03-01','2021-04-01'] };
  46.  
  47.     </script>
  48.   </body>
  49. </html>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement