From d4d98db686b5278e5004f33517326cfe9b99c779 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 5 Mar 2019 00:25:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9B=E3=83=BC=E3=83=A0=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=81=AE=E3=82=A4=E3=83=B3=E3=83=A9=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=97=E3=83=88=E3=82=92home.js=E3=81=AB?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/home.js | 38 ++++++++++++++++++++++++++++++ resources/views/home.blade.php | 42 +++------------------------------- webpack.mix.js | 1 + 3 files changed, 42 insertions(+), 39 deletions(-) create mode 100644 resources/assets/js/home.js diff --git a/resources/assets/js/home.js b/resources/assets/js/home.js new file mode 100644 index 0000000..da0b04f --- /dev/null +++ b/resources/assets/js/home.js @@ -0,0 +1,38 @@ +import Chart from 'chart.js'; + +const graph = document.getElementById('global-count-graph'); +const labels = JSON.parse(document.getElementById('global-count-labels').textContent); +const data = JSON.parse(document.getElementById('global-count-data').textContent); + +new Chart(graph.getContext('2d'), { + type: 'bar', + data: { + labels, + datasets: [{ + data, + backgroundColor: 'rgba(0, 0, 0, .1)', + borderColor: 'rgba(0, 0, 0, .25)', + borderWidth: 1 + }] + }, + options: { + maintainAspectRatio: false, + legend: { + display: false + }, + elements: { + line: {} + }, + scales: { + xAxes: [{ + display: false + }], + yAxes: [{ + display: false, + ticks: { + beginAtZero: true + } + }] + } + } +}); \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 6c443ec..9bf2128 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -102,43 +102,7 @@ @endsection @push('script') - - + + + @endpush \ No newline at end of file diff --git a/webpack.mix.js b/webpack.mix.js index bd34d84..b02c4a4 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -12,6 +12,7 @@ let mix = require('laravel-mix'); */ mix.js('resources/assets/js/app.js', 'public/js') + .js('resources/assets/js/home.js', 'public/js') .sass('resources/assets/sass/app.scss', 'public/css') .autoload({ 'jquery': ['$', 'jQuery', 'window.jQuery']