Skip to content

Fix hover tooltip showing wrong values when valueMap contains numeric strings - #269

Draft
mbehr1 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-268
Draft

Fix hover tooltip showing wrong values when valueMap contains numeric strings#269
mbehr1 with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-268

Conversation

Copilot AI commented Aug 1, 2025

Copy link
Copy Markdown

The hover tooltip in graphical reports was displaying incorrect values when reportOptions.valueMap mapped values to strings that could be interpreted as numbers. For example, if a value was mapped to "8", the tooltip would show 1 instead of 8.

Root Cause

The issue occurred because Chart.js uses category-type axes when valueMap is present, and internally represents data points using array indices rather than the actual mapped values. The tooltip callback was accessing item.parsed.y or item.formattedValue, which returned the chart position (index) instead of the actual data value.

Solution

Modified the tooltip callback in regularGraphs.js to:

  1. Check if the dataset has a valuesMap property
  2. When present, retrieve the actual data point value using item.dataset.data[item.dataIndex].y instead of the parsed chart position
  3. Fall back to the original logic for datasets without valuesMap

Also updated timeSeriesReport.html to include the valuesMap in the dataset configuration so it's accessible to the tooltip callback.

Example

Before fix:

  • Value mapped to "8" displays as 1 in tooltip (chart index)

After fix:

  • Value mapped to "8" correctly displays as 8 in tooltip (actual value)

The fix maintains backward compatibility - datasets without valuesMap continue to work exactly as before.

Fixes #268.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hg.mozilla.org
    • Triggering command: node ./dist/install.js (dns block)
  • https://api.github.com/repos/mbehr1/adlt/releases/tags/v0.62.0
    • Triggering command: node ./lib/postinstall.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: mbehr1 <3258891+mbehr1@users.noreply.github.com>
Copilot AI changed the title [WIP] Hover data points are wrong if values are coming from a valueMap where the values are numbers Fix hover tooltip showing wrong values when valueMap contains numeric strings Aug 1, 2025
Copilot AI requested a review from mbehr1 August 1, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hover data points are wrong if values are coming from a valueMap where the values are numbers

2 participants