Skip to content

DevOverlayの精度履歴グラフの縦軸を固定ログスケールに変更し値の変化を読み取りやすくする - #6128

Merged
TinyKitten merged 1 commit into
devfrom
claude/devoverlay-accuracy-log-scale
Jun 4, 2026
Merged

TinyKitten merged 1 commit into
devfrom
claude/devoverlay-accuracy-log-scale

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

概要

DevOverlay の精度履歴グラフの縦軸スケールが履歴ウィンドウの min/max に依存する相対スケールだったため、平常時のわずかな揺れでもグラフが全高に広がり、逆に値の変化量が読み取りづらかった。実機フィードバックを受け、縦軸を固定ログスケールに変更する。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • 縦軸を、履歴ウィンドウの min/max に依存する相対スケールから、下限 5m〜上限 MAX_PERMIT_ACCURACY(1500m) を対数で割り当てる固定スケールに変更。同じ精度値は常に同じ高さに描画され、値の変化量を直接読み取れる。
  • 対数軸により、良好域の微小な変化(例: 5m↔60m)と数百m級の悪化の双方を判読可能に。GPS 精度のように桁が広い量に適した割り当て。
  • 5m 以下は下端(0)、MAX_PERMIT_ACCURACY 以上は上端(1)にクランプ(許容上限超過=棄却域は「振り切れ」として上端に張り付かせる)。
  • buildAccuracyChartSeries の相対正規化(min/max・range・全同値時 0.5)を撤去し、normalizeAccuracy で各サンプルを独立に固定変換する実装へ簡素化。
  • 関連テストを固定ログスケール向けに更新(accuracyChart.test.ts)。ウィンドウ非依存・クランプ・単調性・良好域の判読性を検証。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

スクリーンショット(任意)


Generated by Claude Code

Summary by CodeRabbit

リリースノート

  • Refactor

    • 精度チャートの正規化ロジックを改善し、グラフの軸スケーリングをより一貫性のあるものに変更しました。
  • Tests

    • 精度チャート関連のテストを拡充し、固定スケールでの正規化が正しく動作することを検証します。

@TinyKitten TinyKitten self-assigned this Jun 4, 2026
@github-actions github-actions Bot added the react label Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

精度チャートの正規化ロジックが相対スケール(系列内 min/max)から固定ログスケール(床/天井定数)へ移行。ACCURACY_CHART_FLOOR_M・CEILING_M 定数と normalizeAccuracy 関数を追加し、buildAccuracyChartSeries がこれを使用するよう更新。テストは床/天井飽和、単調性、系列依存性の廃止を検証。

Changes

固定ログスケール精度正規化の導入

Layer / File(s) Summary
固定ログスケール契約と正規化実装
src/utils/accuracyChart.ts
AccuracyChartPoint.normalized のドキュメントを更新し、ログ正規化に用いる固定下限・上限として ACCURACY_CHART_FLOOR_M・ACCURACY_CHART_CEILING_M をエクスポート。精度(m)を 0..1 に変換する normalizeAccuracy 関数(床/天井に基づくクランプ・正規化)を追加。
normalizeAccuracy テスト群
src/utils/accuracyChart.test.ts
normalizeAccuracy の床以下→0、天井以上→1、単調増加、範囲内、良好域の相対差分離を検証するテスト群を追加。import を拡張し新規定数・関数を取り込み。
チャート系列の固定位置決め統合
src/utils/accuracyChart.ts
buildAccuracyChartSeries の各点 normalized を従来の min/max 相対計算から normalizeAccuracy(value) による固定ログスケール計算へ置換。
buildAccuracyChartSeries テスト更新
src/utils/accuracyChart.test.ts
系列内の単一・複数サンプル、同値非潰れ、精度の大小関係順序、単一値と normalizeAccuracy との一致、最大履歴の単調増加を検証するテスト群に置換・拡張。旧の 0/1・0.5 固定期待は削除。

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6125: 本 PR は buildAccuracyChartSeries の正規化ロジック(normalizeAccuracy 導入)を固定ログスケール境界へ変更する修正であり、当該 PR の折れ線グラフ実装が依存する系列生成の挙動変更のため直接関連する。

Suggested labels

react

🐰 ウサギが見た精度チャート、
床から天井へログスケール跳ぶ
相対から固定へ、安定する
normalizeAccuracy さん登場〜
テストもばっちり単調増加 ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR のタイトルは、変更内容を正確に反映しており、縦軸を固定ログスケールに変更するという主要な目的を明確に表示しています。
Description check ✅ Passed PR の説明は提供されたテンプレートの全ての主要セクション(概要、変更の種類、変更内容、テスト)を完備しており、変更内容が詳細に記述されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/devoverlay-accuracy-log-scale

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/utils/accuracyChart.test.ts (1)

1-43: ⚡ Quick win

afterEach で jest.clearAllMocks() を追加してください。

このテストファイルに afterEach がないため、ガイドライン準拠のために追加してください。

🔧 追加例
 import {
   ACCURACY_CHART_CEILING_M,
   ACCURACY_CHART_COLORS,
   ACCURACY_CHART_FLOOR_M,
   buildAccuracyChartSeries,
   getAccuracyColor,
   normalizeAccuracy,
 } from './accuracyChart';
+
+afterEach(() => {
+  jest.clearAllMocks();
+});

As per coding guidelines "Mock network and Firebase layers with jest.mock and call jest.clearAllMocks() in afterEach".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/accuracyChart.test.ts` around lines 1 - 43, Add an afterEach hook
that calls jest.clearAllMocks() to this test file so mocks are reset between
tests; locate the test suite containing normalizeAccuracy and other imports
(e.g., the describe block for "normalizeAccuracy (fixed log scale)") and insert
afterEach(() => jest.clearAllMocks()) at the top level of the file (outside
individual it blocks) to comply with the mocking guideline.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/utils/accuracyChart.test.ts`:
- Around line 1-43: Add an afterEach hook that calls jest.clearAllMocks() to
this test file so mocks are reset between tests; locate the test suite
containing normalizeAccuracy and other imports (e.g., the describe block for
"normalizeAccuracy (fixed log scale)") and insert afterEach(() =>
jest.clearAllMocks()) at the top level of the file (outside individual it
blocks) to comply with the mocking guideline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd0223a0-ea83-4577-a7c8-d30d2f335621

📥 Commits

Reviewing files that changed from the base of the PR and between 0802a79 and 2238e5f.

📒 Files selected for processing (2)
  • src/utils/accuracyChart.test.ts
  • src/utils/accuracyChart.ts

@TinyKitten
TinyKitten merged commit ef8567f into dev Jun 4, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the claude/devoverlay-accuracy-log-scale branch June 4, 2026 12:43
@TinyKitten TinyKitten mentioned this pull request Jun 4, 2026
4 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants