From 4327c3df84a5912d3168cbe1a341a775629099d9 Mon Sep 17 00:00:00 2001 From: koi-chan Date: Sun, 24 Nov 2024 20:29:51 +0900 Subject: [PATCH] =?UTF-8?q?chartjs-4:=20JS=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E5=BE=85=E3=81=A4=E6=99=82=E9=96=93=E3=81=8C=E7=9F=AD=E3=81=99?= =?UTF-8?q?=E3=81=8E=E3=81=A6=E3=83=86=E3=82=B9=E3=83=88=E3=81=AB=E5=A4=B1?= =?UTF-8?q?=E6=95=97=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/controllers/speeches_chart_controller.js | 8 +++++--- test/system/channel_days_index_chart_test.rb | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/javascript/controllers/speeches_chart_controller.js b/app/javascript/controllers/speeches_chart_controller.js index 7c04e049..a38c1ea2 100644 --- a/app/javascript/controllers/speeches_chart_controller.js +++ b/app/javascript/controllers/speeches_chart_controller.js @@ -45,7 +45,7 @@ class SpeechesChartController extends Controller { options: { scales: { y: { - beginAtZero: true + beginAtZero: true } }, @@ -58,13 +58,13 @@ class SpeechesChartController extends Controller { title: (tooltipItems, _data) => { const tooltipItem = tooltipItems[0]; return this.dates[tooltipItem.dataIndex]; - }, + }, } }, }, // SpeechesChartControllerのthisを使いたいため、アロー関数にする - onHover: (_e, elements) => { + onHover: (_e, elements, _c) => { const chartClassList = this.chartTarget.classList; if (elements[0] === undefined) { @@ -77,6 +77,8 @@ class SpeechesChartController extends Controller { animation: { active: { duration: 400 } }, }, }); + + this.chartTarget.classList.add("chartjs-render-monitor"); } /** diff --git a/test/system/channel_days_index_chart_test.rb b/test/system/channel_days_index_chart_test.rb index 4ac40487..abb2ee64 100644 --- a/test/system/channel_days_index_chart_test.rb +++ b/test/system/channel_days_index_chart_test.rb @@ -28,7 +28,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase test '月のページにおいてグラフが描画されている' do visit(@browse_month.path) - sleep(0.1) + sleep(0.5) chart_canvas = find_chart_canvas assert do @@ -43,7 +43,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase visit(@browse_month.path) - sleep(0.1) + sleep(0.5) chart_canvas = find_chart_canvas chart_canvas.click @@ -69,7 +69,7 @@ class ChannelDaysIndexChartTest < ApplicationSystemTestCase visit(@browse_month.path) - sleep(0.1) + sleep(0.5) chart_canvas = find_chart_canvas chart_canvas.click