Hello colleagues, I am trying to print my graphic in an excel (xlsx or csv) the problem is that I have only found that only the data of the table is printed but not the graph as such. So I would like to know if there is any way or I have to use another type of plugin so that I can do this, for now all I want to print is this:
<script>
var cadena = "";
var datos = "";
var respuestas = "";
var datosSeparados = "";
var downloadBtn = document.getElementById('downloadBtn');
var canvas = document.getElementById("Graf01");
var frecuencias = [];
$(document).ready(function(){
@foreach($preguntas as $p)
var respuestas{{$p->id_pesp}} = [];
@if($p->tipo != "1" && $p->tipo != "2")
if($("#graf{{$p->id_pesp}}")){
cadena = ""
@foreach($resultados as $res)
@if($res->id_pesp == $p->id_pesp)
cadena += "{{$res->respuesta}};";
@endif
@endforeach
datos = cadena.substring(0, cadena.length - 1);
alert(datos);
datosSeparados = datos.split(';');
@foreach($respuestas as $r)
var f = 0;
@if($r->id_pesp == $p->id_pesp)
respuestas{{$p->id_pesp}}.push("{{$r->respuestas}}");
for(var i = 0; i < datosSeparados.length; i++){
if(datosSeparados[i]=={{$r->id_res}}){
f++;
}
}
frecuencias.push(f);
@endif
@endforeach
var grafica = $('#graf{{$p->id_pesp}}');
var grafica = new Chart(canvas, {
type: 'doughnut',
data: {
labels: respuestas{{$p->id_pesp}},
datasets: [{
label: 'Encuesta Especifica',
data: frecuencias,
lineTension: 0,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
}
});
}
@endif
@endforeach
I got it in PDF but missing the Excel part, thanks for your help,