Fix/vizualisation#29
Merged
Merged
Conversation
Merge pull request #27 from IFRI-AI-Classes/fix/vizualisation
There was a problem hiding this comment.
Pull request overview
This PR updates the solution visualisation UI to adjust which metrics are shown and to make metric updates more resilient to missing DOM elements, and adds a new example solution .dat file.
Changes:
- Replace the “Exchanges” metric display with a “Trucks” metric in the metrics panel.
- Add a small
setTextContentByIdhelper and use it for stats updates to avoid null-element runtime errors. - Add
Sol_MPVRP_S_002_s10_d2_p3.datunderdata/solutions/.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pages/visualisation.html | Updates the metrics grid to hide Exchanges and display Trucks. |
| pages/static/js/visualisation.js | Adds a safe DOM text setter and updates stats rendering accordingly. |
| data/solutions/Sol_MPVRP_S_002_s10_d2_p3.dat | Adds a new solution data file in the documented format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| setTextContentById('stat-dist', (metrics.total_cost || solution.objective || 0).toFixed(2)); | ||
| setTextContentById('stat-routing', (metrics.routing_cost || 0).toFixed(2)); | ||
| // setTextContentById('stat-exchanges', `0/${totalExchanges}`); | ||
| setTextContentById('stat-trucks', metrics.vehicles_used || trucks.length); |
There was a problem hiding this comment.
Using metrics.vehicles_used || trucks.length will incorrectly fall back to trucks.length when vehicles_used is 0 (valid numeric value but falsy). Prefer a nullish check (e.g., ??) or an explicit Number.isFinite/!= null guard so 0 is displayed correctly when that’s what the metrics report.
Suggested change
| setTextContentById('stat-trucks', metrics.vehicles_used || trucks.length); | |
| setTextContentById('stat-trucks', metrics.vehicles_used ?? trucks.length); |
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.
No description provided.