62 lines
1.9 KiB
PHP
Raw Normal View History

2017-12-11 19:07:09 +03:00
@if(!$model->customId)
@include('charts::_partials.container.canvas2')
@endif
2019-11-16 10:21:14 +03:00
@push('body_scripts')
2017-12-11 19:07:09 +03:00
<script type="text/javascript">
2019-11-16 10:21:14 +03:00
var ctx = document.getElementById("{{ $model->id }}");
2017-12-11 19:07:09 +03:00
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [
2019-11-16 10:21:14 +03:00
@foreach ($model->labels as $label)
"{!! $label !!}",
2017-12-11 19:07:09 +03:00
@endforeach
],
datasets: [
@for ($i = 0; $i < count($model->datasets); $i++)
2019-11-16 10:21:14 +03:00
{
fill: true,
label: "{!! $model->datasets[$i]['label'] !!}",
lineTension: 0.3,
@if ($model->colors and count($model->colors) > $i)
borderColor: "{{ $model->colors[$i] }}",
backgroundColor: "{{ $model->colors[$i] }}",
@else
@php $c = sprintf('#%06X', mt_rand(0, 0xFFFFFF)); @endphp
borderColor: "{{ $c }}",
backgroundColor: "{{ $c }}",
@endif
data: [
@foreach ($model->datasets[$i]['values'] as $dta)
{{ $dta }},
@endforeach
],
},
2017-12-11 19:07:09 +03:00
@endfor
]
},
options: {
responsive: {{ $model->responsive || !$model->width ? 'true' : 'false' }},
maintainAspectRatio: false,
2019-11-16 10:21:14 +03:00
@if ($model->title)
title: {
2017-12-11 19:07:09 +03:00
display: true,
2019-11-16 10:21:14 +03:00
text: "{!! $model->title !!}",
fontSize: 20,
2017-12-11 19:07:09 +03:00
},
@endif
2019-11-16 10:21:14 +03:00
scales: {
2017-12-11 19:07:09 +03:00
yAxes: [{
display: true,
ticks: {
beginAtZero: true,
}
}]
}
}
});
</script>
2019-11-16 10:21:14 +03:00
@endpush