2017-11-05 01:26:52 +09:00
|
|
|
@extends('user.base')
|
|
|
|
|
2019-01-08 23:27:48 +09:00
|
|
|
@section('title', $user->display_name . ' さんのグラフ')
|
|
|
|
|
2017-11-07 00:22:40 +09:00
|
|
|
@push('head')
|
|
|
|
<link rel="stylesheet" href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" />
|
|
|
|
@endpush
|
|
|
|
|
2017-11-05 01:26:52 +09:00
|
|
|
@section('tab-content')
|
2017-11-05 22:29:09 +09:00
|
|
|
@if ($user->is_protected && !$user->isMe())
|
2017-11-05 21:59:01 +09:00
|
|
|
<p class="mt-4">
|
|
|
|
<span class="oi oi-lock-locked"></span> このユーザはチェックイン履歴を公開していません。
|
|
|
|
</p>
|
|
|
|
@else
|
2017-11-07 00:22:40 +09:00
|
|
|
<h5 class="my-4">Shikontribution graph</h5>
|
2017-11-07 00:39:07 +09:00
|
|
|
<div id="cal-heatmap" class="tis-contribution-graph"></div>
|
2017-11-07 00:22:40 +09:00
|
|
|
<hr class="my-4">
|
2018-01-04 15:52:04 +09:00
|
|
|
<h5 class="my-4">月間チェックイン回数</h5>
|
2018-01-04 14:50:14 +09:00
|
|
|
<canvas id="monthly-graph" class="w-100"></canvas>
|
2018-01-04 15:52:04 +09:00
|
|
|
<hr class="my-4">
|
|
|
|
<h5 class="my-4">年間チェックイン回数</h5>
|
|
|
|
<canvas id="yearly-graph" class="w-100"></canvas>
|
2019-01-02 14:44:31 +09:00
|
|
|
<hr class="my-4">
|
|
|
|
<h5 class="my-4">時間別チェックイン回数</h5>
|
|
|
|
<canvas id="hourly-graph" class="w-100"></canvas>
|
|
|
|
<hr class="my-4">
|
|
|
|
<h5 class="my-4">曜日別チェックイン回数</h5>
|
|
|
|
<canvas id="dow-graph" class="w-100"></canvas>
|
2017-11-05 21:59:01 +09:00
|
|
|
@endif
|
2017-11-07 00:22:40 +09:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@push('script')
|
2018-01-04 14:50:14 +09:00
|
|
|
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/chart.js@2.7.1/dist/Chart.min.js"></script>
|
2017-11-07 00:22:40 +09:00
|
|
|
<script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script>
|
|
|
|
<script type="text/javascript" src="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.min.js"></script>
|
|
|
|
<script>
|
|
|
|
var cal = new CalHeatMap();
|
|
|
|
cal.init({
|
|
|
|
itemSelector: '#cal-heatmap',
|
|
|
|
domain: 'month',
|
|
|
|
subDomain: 'day',
|
|
|
|
domainLabelFormat: '%Y/%m',
|
2018-03-06 23:19:01 +09:00
|
|
|
weekStartOnMonday: false,
|
2017-11-07 00:22:40 +09:00
|
|
|
start: new Date({{ \Carbon\Carbon::now()->addMonths(-9)->timestamp * 1000 }}),
|
|
|
|
range: 10,
|
2018-01-04 15:52:04 +09:00
|
|
|
data: @json($dailySum),
|
2017-11-07 00:22:40 +09:00
|
|
|
legend: [1, 2, 3, 4]
|
|
|
|
});
|
2018-01-04 14:50:14 +09:00
|
|
|
|
2019-01-02 14:44:31 +09:00
|
|
|
function createLineGraph(id, labels, data) {
|
2018-01-04 15:52:04 +09:00
|
|
|
var context = document.getElementById(id).getContext('2d');
|
2018-01-04 14:50:14 +09:00
|
|
|
var chart = new Chart(context, {
|
|
|
|
type: 'line',
|
|
|
|
data: {
|
|
|
|
labels: labels,
|
|
|
|
datasets: [{
|
2018-01-04 15:52:04 +09:00
|
|
|
data: data,
|
2018-01-04 14:50:14 +09:00
|
|
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
|
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
|
|
borderWidth: 1
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
legend: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
elements: {
|
|
|
|
line: {
|
|
|
|
tension: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
yAxes: [{
|
|
|
|
ticks: {
|
|
|
|
beginAtZero: true
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-01-04 15:52:04 +09:00
|
|
|
}
|
2019-01-02 14:44:31 +09:00
|
|
|
|
|
|
|
function createBarGraph(id, labels, data) {
|
|
|
|
var context = document.getElementById(id).getContext('2d');
|
|
|
|
var chart = new Chart(context, {
|
|
|
|
type: 'bar',
|
|
|
|
data: {
|
|
|
|
labels: labels,
|
|
|
|
datasets: [{
|
|
|
|
data: data,
|
|
|
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
|
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
|
|
borderWidth: 1
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
options: {
|
|
|
|
legend: {
|
|
|
|
display: false
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
yAxes: [{
|
|
|
|
ticks: {
|
|
|
|
beginAtZero: true
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
createLineGraph('monthly-graph', @json(array_keys($monthlySum)), @json(array_values($monthlySum)));
|
|
|
|
createLineGraph('yearly-graph', @json(array_keys($yearlySum)), @json(array_values($yearlySum)));
|
|
|
|
createBarGraph('hourly-graph', @json(array_keys($hourlySum)), @json(array_values($hourlySum)));
|
|
|
|
createBarGraph('dow-graph', ['日', '月', '火', '水', '木', '金', '土'], @json($dowSum));
|
2017-11-07 00:22:40 +09:00
|
|
|
</script>
|
|
|
|
@endpush
|