Chart js in embedded window shows in preview but not in browser

I would like to know that it can go wrong since when previewing a chart in a window embedded with Chart js in the editor (htmlcomponent) it shows fine but when I go to the published site it doesn’t do the chart, everything else is fine. I have not left the cache option on on the page and my browser seems to respond to other changes within the graphic such as the color.
This is the code from the editor:

            $w("#html2").postMessage(item2 => [item2.x, item2.z]);
            $w("#html3").postMessage(item3 => [item3.x, item3.p1]); 


             if( === 'ready'){
             $w("#html1").postMessage( => [item3.x, item3.y]));



              if( === 'ready'){
                   $w("#html2").postMessage( => [item.x, item.z]));



                if( === 'ready'){
                   $w("#html3").postMessage( => [item2.x, item2.p1]));


This is the code of the htmlComponent:

<html lang="en">
  <meta charset="UTF-8">
  <title>Gráfico Concentracion vs tiempo</title>
  <script src=""></script>
<body onLoad="ready()">
<canvas id="myChart" width="950" height="510"></canvas>

var ctx = document.getElementById("myChart");
let tiempo = [];
  var myChart = new Chart(ctx, {
    type: 'line',
    data: {
      labels: => o.x),
      datasets: [{
        label: 'Concentración(Quanta/m3)',
        data: => o.y),
        fill: false,
        borderColor: "RoyalBlue"
    options: {
      scales: {
        yAxes: [{
          ticks: {
            beginAtZero: true

  window.onmessage = function(event){

    if ( && Array.isArray( {[0].data =;
     tiempo =;

  function ready(){
    window.parent.postMessage({"type":"ready"}, "*");