Chart js static chart โ€“ how to

0๐Ÿ‘

โœ…

Use the script outside the canvas

chartData4 = 
    {    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
         datasets: [{
             data: [10, 59, 80, 81, 56, 55, 40],
             fill: true,
             backgroundColor: 'rgb(75, 192, 192)',
             tension: 0.1,
         }]
    };
    const myChartfill = document.getElementById('myChartfill');
     
    if(myChartfill!=null){
        new Chart(myChartfill, {
            type: 'line',
            data: chartData4,
                options: { 
                            events: [],
                            plugins: { tooltip: { enabled: false} ,
                            legend: {
                            display: false},
                            
                                    },
                                    scales: {
                                         y: {
                                            ticks: {
                                             display: false,
                                          },
                                          grid: {
                                          display: false,
                                          },
                                        },
                                         x: {
                                            ticks: {
                                             display: false,
                                          },
                                          grid: {
                                          display: false,
                                          },
                                          },
                                            },

                        },
    )}
    .container {
      display: flex;
        width: 100%;
       height: 50vh;
    }
<div class="container">
    <canvas class = "w-100" id="myChartfill"></canvas>
</div>

๐Ÿ‘:0

options: {
    tooltips: {
      enabled: false,
    },
    legend: {
      display: false
    },
    scales: {
      xAxes: [{display: false}],
      yAxes: [{display: false}],
    }
  }

Leave a comment