0
<?php 
 $no1=0;
foreach($location_data as $last_data){ 
                      
        if($location[0]->depth_unit=="meter"){
          $depth_drilled=($last_data->end_depth - $last_data->start_depth)*3.28;
          $acceptable_loss=((12.25*12.25)/1029.4*($depth_drilled)/6.28);
      }
      else{
          $depth_drilled=($last_data->end_depth - $last_data->start_depth);
          $acceptable_loss=(12.25*12.25)/1029.4*($depth_drilled);
      }
      ?>
      setInterval(function(){
  <?php  if($last_data->shaker_loss_value < $acceptable_loss ){ ?>
    chart.options.data[3].dataPoints[<?php echo $no1; ?>].markerColor = "transparent";
 <?php } else { ?>
    chart.options.data[3].dataPoints[<?php echo $no1; ?>].markerColor = "red";
      chart.options.data[3].dataPoints[<?php echo $no1; ?>].markerType = "triangle";
      <?php  } ?>
 chart.render();
 },<?php echo $no1; ?> * 1000);
 <?php
 $no1++;
}  ?>

above is my code i am implementing in canvas.js to blink the marker but its only blink once while onload it should be blinking all the time any luck

 setInterval(function(){
          chart.options.data[3].dataPoints[0].markerColor = "red";
          chart.options.data[3].dataPoints[0].markerType = "triangle";
           chart.render();
     },0 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[1].markerColor = "red";
          chart.options.data[3].dataPoints[1].markerType = "triangle";
           chart.render();
     },1 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[2].markerColor = "red";
          chart.options.data[3].dataPoints[2].markerType = "triangle";
           chart.render();
     },2 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[3].markerColor = "red";
          chart.options.data[3].dataPoints[3].markerType = "triangle";
           chart.render();
     },3 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[4].markerColor = "red";
          chart.options.data[3].dataPoints[4].markerType = "triangle";
           chart.render();
     },4 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[5].markerColor = "red";
          chart.options.data[3].dataPoints[5].markerType = "triangle";
           chart.render();
     },5 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[6].markerColor = "red";
          chart.options.data[3].dataPoints[6].markerType = "triangle";
           chart.render();
     },6 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[7].markerColor = "red";
          chart.options.data[3].dataPoints[7].markerType = "triangle";
           chart.render();
     },7 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[8].markerColor = "red";
          chart.options.data[3].dataPoints[8].markerType = "triangle";
           chart.render();
     },8 * 1000);
           setInterval(function(){
          chart.options.data[3].dataPoints[9].markerColor = "red";
          chart.options.data[3].dataPoints[9].markerType = "triangle";
           chart.render();
     },9 * 1000);

this is what i am getting at source view-source:http://dssecosystem.com/index.php/account/client_dashboard_new/1 above is the link you can check my code at line 28847

AbcMvc
  • 55
  • 3
  • 10
  • At first, if you're going to use an interval, you need only a single method call, now you have multiple intervals firing continuously. Secondly, nothing makes the marker to blink, all the intervals are setting the same color and type to all the markers. Drop the server-side code from this, and try to code this purely with JS. – Teemu Sep 01 '21 at 05:10
  • ok i have change to single function and call that function within loss and pass values – AbcMvc Sep 01 '21 at 05:46

1 Answers1

0
<?php 
 $no1=0;
foreach($location_data as $last_data){ 
                      
        if($location[0]->depth_unit=="meter"){
          $depth_drilled=($last_data->end_depth - $last_data->start_depth)*3.28;
          $acceptable_loss=((12.25*12.25)/1029.4*($depth_drilled)/6.28);
      }
      else{
          $depth_drilled=($last_data->end_depth - $last_data->start_depth);
          $acceptable_loss=(12.25*12.25)/1029.4*($depth_drilled);
      }
      ?>
      callFun(<?php echo $last_data->shaker_loss_value ?>,<?php echo $acceptable_loss ?>,<?php echo $no1 ?>);
      
   
 <?php
 $no1++;
}  ?>

function callFun(shaker_loss_val,acceptable_los_val,n){
    setInterval(function(){
   if(shaker_loss_val < acceptable_los_val ){
    chart.options.data[3].dataPoints[n].markerColor = "transparent";
  } else { 
    chart.options.data[3].dataPoints[n].markerColor = "red";
      chart.options.data[3].dataPoints[n].markerType = "triangle";
      }
 chart.render();
 },500);   
}

still its only blink one time, the source link is https://jsfiddle.net/kj87p5cL/

AbcMvc
  • 55
  • 3
  • 10