Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
pie chart js disappear after refresh page by livewire

Im used chart js and its type is Pie chart, everything is working well when I open the page like this : https://pasteboard.co/I5HolYQLFxvE.png

, but after changing one page to another like enter link description here,

the chart is disappear, like this enter link description here

I have no clue for this one, Can anyone figure it out? Your suggestion or solutions would really helpful

this is my script for chart js

    <script type="text/javascript">

document.addEventListener('livewire:load', function () {
   var ctx = document.getElementById("dashboardChart");
ctx.width = 300;
ctx.height = 300;

if ( {{ $data[1]->percentage; }} == 0 && {{ $data[2]->percentage; }} == 0 && {{ $data[3]->percentage; }} == 0 && {{ $data[4]->percentage; }} == 0 ) {
    var datas = [ 100 ]
    var bgColor = "#f2f2f2";
    var labelss = ["No Coaching"];
}else{
    var datas = [ {{ $data[1]->percentage; }} , {{ $data[2]->percentage; }} , {{ $data[3]->percentage; }}, {{ $data[4]->percentage; }} ];
    var bgColor = [
        "#fc8181",
        "#f6ad55",
        "#7555f6",
        "#3498db"
      ];
      var labelss = ["Completed coaching", "Running coaching", "Waiting for agenda", "Waiting for approval"];
}

var myChart = new Chart(ctx, {
  type: 'pie',
  data: {
    labels: labelss,
    datasets: [{
      data: datas,
      backgroundColor: bgColor
    }]
  },
  options: {
    tooltips: {
      enabled: true,
      mode: 'single',
      callbacks: {
        label: function(tooltipItem, data) {
          var allData = data.datasets[tooltipItem.datasetIndex].data;
          var tooltipLabel = data.labels[tooltipItem.index];
          var tooltipData = allData[tooltipItem.index];
          return tooltipLabel + ": " + tooltipData + "%";
        }
      }
    },
    plugins: {
        datalabels: {
            color: '#fff',
            display: false,
        },
    },
    // title: {
    //     display: true,
    //     text: 'All Coaching Data'
    // },
    responsive: true,
    legend: {
        position: 'bottom',
        labels: {
            boxWidth: 20,
            padding: 20
        }
  }
}
});
});

</script>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!