Repository navigation
散布図をドラッグで囲んだ範囲に拡大できるようにする - #1
Merged
Merged
Conversation
産総研データの追加で点が密集し、そのままでは読み取れない領域ができたため、 見たい範囲を選んで拡大表示できるようにした。 - 図の上をドラッグすると囲んだ範囲だけを表示し、「全画面に戻す」で解除する - 指の操作は押した時点でスクロールか選択かが決まるため、「指で範囲を選ぶ」を 押している間だけ選択に使う(拡大したら自動で解除して元に戻す) - 拡大中は範囲外の点を渡さず、残った点数に応じて点を大きくする - 拡大中は軸の範囲が半端な値になるので、目盛りの桁を範囲の広さから決める - 近似直線と相関係数は範囲を絞ると実際より弱く見えるため、全データのまま変えず その旨を注記する 範囲の計算は src/lib/zoom.ts に純粋関数として切り出してテストした。 ドラッグ操作自体は描画領域の大きさを要するため実ブラウザで確認している。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014hFxHoL1aDermyNEV1GXrB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
産総研データ(7,203件)の追加で散布図の点が密集し、そのままでは読み取れない領域ができたため、見たい範囲を選んで拡大表示できるようにしました。
使い方
指での操作にボタンを挟んでいる理由
ブラウザは指を置いた瞬間に「なぞる=範囲選択」か「画面のスクロール」かを決めてしまうため、常時ドラッグ選択にすると散布図の上(縦380px)で画面がスクロールできなくなります。そこで選択に使うのはモード中だけとし、拡大が済んだら自動でモードを抜けてスクロールを戻しています。マウス・ペンはスクロールと競合しないので、ボタンなしでいつでもドラッグできます。
あわせて調整した点
19.360902255639097のようになるため、範囲の広さから桁数を決めて19.4/13,497と表示する(全体表示時は recharts が切りのよい目盛りを選ぶのでそのまま):focus-visibleは維持)変更ファイル
src/lib/zoom.tssrc/lib/zoom.test.tssrc/components/ScatterView.tsxsrc/components/App.test.tsxsrc/styles.cssREADME.mdドラッグ中の枠は毎フレーム動くため、React の状態ではなく DOM を直接書き換えています。数千点のグラフを再描画せずに済ませるためです。
確認したこと