Render months instead of weeks underneath chart in weekly report
MODIFY
resources/views/reports/weekly_report.blade.php
resources/views/reports/weekly_report.blade.php
@section('scripts')
<script>
+ function getWeeksInMonth(year, month) {
+ var firstOfMonth = new Date(year, month - 1, 1);
+ var lastOfMonth = new Date(year, month, 0);
+
+ var used = firstOfMonth.getDay() + lastOfMonth.getDate();
+
+ return Math.ceil(used / 7);
+ }
+
var data = {
labels: [{!! implode(',', array_keys($weeks)) !!}],
series: [[{!! '"' . implode('","', $weeks) . '"' !!}]]
};
+ var currentMonth = 1;
+ var offset = 0;
+ var months = [];
+
+ for (var i = 1; i <= 12; i ++) {
+ months[i] = getWeeksInMonth(2018, i);
+ }
+
new Chartist.Line('.ct-chart', data, {
showPoint: false,
- lineSmooth: false
+ lineSmooth: false,
+
+ axisX: {
+ labelInterpolationFnc: function (value, index) {
+ offset ++;
+
+ if (months[currentMonth] == offset) {
+ currentMonth ++;
+ offset = 1;
+
+ return currentMonth - 1;
+ }
+
+ return null;
+ }
+ }
});
</script>
@endsection

Render months instead of weeks underneath chart in weekly report