javascript - How to take data into piechart from database? -
i have dynamically created table , on click of view button in each row modal opens have pie chart no of leaves taken people till date in categories sick, vacation, maternity, paternity particular year.please me how take data database..and on click of 1st button pie chart shows
but if click on button other 1st blank page.
<td> <button type="button" class="btn btn-default btn-sm view" data-toggle="modal" data-target="#{{pl.id}}_3"><i class="fa fa-eye" aria-hidden="true" style="color:black"></i></button> <!-- modal --> <div class="modal fade" id= "{{pl.id}}_3" role="dialog"> <div class="modal-dialog"> <!-- modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title"><b>{{pl.employee.emp_name|title }}</b> leave details</h4> </div> <div class="modal-body"> <p>applied leave {{pl.start_date}} {{pl.end_date}} {{ pl.end_date|timeuntil:pl.start_date }} </p> <p>leave applied on : {{pl.date_created}}</p> <p><div id="container" class="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">close</button> </div> </div> </div> </div> </td>
my jquery code:
$(document).on('click','.view', function(e){ highcharts.chart('container', { chart: { plotbackgroundcolor: null, plotborderwidth: null, plotshadow: false, type: 'pie' }, title: { text: 'total number of leaves applied till now' }, tooltip: { pointformat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotoptions: { pie: { allowpointselect: true, cursor: 'pointer', datalabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %', style: { color: (highcharts.theme && highcharts.theme.contrasttextcolor) || 'black' } } } }, series: [{ name: 'brands', colorbypoint: true, data: [{ name: 'sick leaves', y: 56.33 }, { name: 'casual leaves', y: 24.03, sliced: true, selected: true }, { name: 'vacation leaves', y: 10.3 }, { name: 'maternity leaves', y: 4.77 }, { name: 'paternity leaves', y: 0.91 }] }] }); });
modal fade has time delay have call function using set time out
create new function , call settimeout(function(){ myfunc(); }, 500);
work on modal.
Comments
Post a Comment