I would like to know if it will be possible to send HTML (containing multiple charts) via an AJAX method and then render them. I don't seem to have much luck and I can't find much online doing it with this approach. I would appreciate any input.
Here is my AJAX function:
$.ajax({
url: "/admin/expensereport/getgraphs",
type: 'GET',
data: { dateFrom: $("#dateFrom").val(), dateTo:$("#dateTo").val(),
expenseBuildingType: $("input[name='expenseBuildingType']:checked").val(),
expenseScheduledType: $("input[name='expenseScheduledType']:checked").val()},
cache: false,
success: function(data) {
$('#graphsDiv').html(data);
},
Here is my PHP Laravel function with one of 3 graphs included:
$chartCategories = app()->chartjs
->name('chartCategories')
->type('pie')
->size(['width' => 400, 'height' => 200])
->labels(['Label x', 'Label y'])
->datasets([
[
'backgroundColor' => ['#FF6384', '#36A2EB'],
'hoverBackgroundColor' => ['#FF6384', '#36A2EB'],
'data' => [69, 59]
]
])
->options([]);
$view = View::make('partials.CPM.expensereportgraphs', [
'chartCategories' => $chartCategories,
]);
Here is an extract of my view:
<div class="col-md-6">
<h4>Top 10 Categories</h4>
{!! $chartCategories->render() !!}
</div>