Skip to content

Conversation

@w-b-d
Copy link

@w-b-d w-b-d commented Aug 25, 2025

Description

Extend chart link to support from latest readings. Users can now select "keep current" and the current timespan within the slider range will be saved as a parameter in the URL. If the right is bounded, the "keep current" checkbox is greyed out, as well as if the whole graph is unbounded the checkbox is greyed out. When a user changes the slider range, the graph must be refreshed for the "keep current" functionality to work for the updated slider range.

Partly Addresses #[457]

  • Added "Chart Link Options:" section title.

  • Moved "Hide Options When Using This Link" checkbox outside of the button (UI only, logic unchanged).

  • Added "Keep Chart Current" checkbox with full logic implementation.

  • Implemented tooltip content for “Keep Chart Current” checkbox.

  • All hard coded strings moved into data.ts file for consistency and to support multiple languages.

  • Updated UI so that the "Keep Chart Current" checkbox remains visible but is disabled and greyed out when requirements are not met.

  • Preserved original behavior for the hide options feature.

  • Added isKeepCurrent variable in appStateSlice.ts

  • Added "&timeSpan=" to URL in uiSelectors.ts if keep current checkbox is checked

  • added timeCreated in graphSlice.ts and is updated within PlotNavComponent.tsx

  • added case for timeSpan within the processGraphLink function in graphSlice.ts to handle the logic of the "keep current" functionality.

Documentation for the Chart LInk should be updated so users will be able to understand the functionality of the new "keep current" checkbox.

Type of change

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the [OED Contributing License Agreement]

Limitations

Tests have not been created using Mocha/Chai, which is why this is labeled as a partial address.

Contributors: @w-b-d, @anntreasajojo, @rianhassett, @nickhitos

w-b-d and others added 21 commits July 18, 2025 12:32
 - Added "Chart Link Options:" section title
 - Moved "Hide Options When Using This Link" checkbox outside of button (UI only, logic unchanged)
 - Added "Keep Chart Current" checkbox (UI only, logic not implemented yet)
 - Added tooltips for both checkboxes (tooltip content for "Keep Chart Current" still pending)
 - Preserved original behavior for hide options feature
Updated UI + Checkbox Visibility
…met, aswell as the checkbox being disabled under the same conditions.
Addding backend functionality
Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

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

Thanks to @w-b-d, @anntreasajojo, @rianhassett & @nickhitos for this contribution, esp. since I think it is your first one to OED. Overall, it works well. I have made a few comments within files to consider. Here are some global ones:

The box indicating everyone signed the CLA is checked but the OED records do not show that @rianhassett & @nickhitos have signed. Could they please sign or let me know if you think our records are off.

I tried using a chart link from a graphic that had the slider range set so the left side differed from the data range of the graphic. If I don't use the new option then it reproduces the slider range. If I use the new option then it does not. I also tried to test the new option by doing: const now = moment('2025-08-28 10:35:00'); in timeSpan in src/client/app/redux/slices/graphSlice.ts. This shifted the current time forward to convince the code the chart link was used in the future. It seems to do that and changes leftBound but it does not change what the graphic shows. I have not investigated the cause. I looked at the design document and it talks about two values that needed to be fixed (in the general case): 1) the data fetched from the server (server range); 2) the points displayed on the graphic (slider range). The code in src/client/app/redux/slices/graphSlice.ts only seems to adjust current.rangeSliderInterval and I think it might relate to that. I appreciate this is subtle so please ask questions or seek my help (I can do video calls) as needed.

{
"version": "0.2.0",
"configurations": [

Copy link
Member

Choose a reason for hiding this comment

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

This file only has new blank lines so please revert changes so none in file.

as
@@ -0,0 +1,7 @@
origin/HEAD -> origin/development
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure what this file is for. Should it be removed?

d
@@ -0,0 +1,7 @@
origin/HEAD -> origin/development
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure what this file is for. Should it be removed?

# Visual Studio Code settings file
.vscode/settings.json

.vscode/launch.json
Copy link
Member

Choose a reason for hiding this comment

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

This file is used by OED to define the debugging setup, etc. I'm not sure it should be in .gitignore.

},updateTimeCreated: state => {
state.current.timeCreated = new TimeInterval(moment(), moment());
},

Copy link
Member

Choose a reason for hiding this comment

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

Please remove blank line.

const handleButtonClick = () => {
// First attempt to write directly to user's clipboard.
navigator.clipboard.writeText(linkText)
navigator.clipboard
Copy link
Member

Choose a reason for hiding this comment

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

I preferred the old formatting without the extra lines to shorten the code.

if (selectedMeters.length > 0 || selectedGroups.length > 0) {
return (
<div>
{/* inputting new "keep chart current" feature */}
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment should just say what the code does or be removed if you think it is not necessary.

selectSelectedGroups, selectSelectedMeters,
selectSliderRangeInterval, selectInitialXAxisRange,
selectQueryTimeInterval, updateTimeIntervalAndSliderRange
selectQueryTimeInterval, updateTimeIntervalAndSliderRange,updateTimeCreated
Copy link
Member

Choose a reason for hiding this comment

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

space after comma.

</div>
</Button>
<Button outline onClick={() => setLinkTextVisible(visible => !visible)}>
<Button
Copy link
Member

Choose a reason for hiding this comment

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

Can the original formatting please be put back since shorter and will remove these lines as having changes.

break;
case 'timeSpan':{
const days = parseFloat(value);
const now = moment();
Copy link
Member

Choose a reason for hiding this comment

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

This is a subtle point but this uses moment to get the current time (as was done in the link creation). This will use the time zone of the current system to get the time. If it differs from the time zone where the link was created then it will differ by the shift amount between the time zones. This means that if a user creates a chart link and quickly sends it to someone else in a different time zone that uses it quickly, the graph will be slightly different. I think this is a small concern but here is a proposal to fix it up:

OED tries to avoid this issue with readings by storing them all in UTC. The time help page discusses this. I propose that the time used in all the calculations be UTC for the current time. Thus, the time at a given point is the same everywhere in the world in UTC and moment() will give this value. It also means that the time sent to the server for readings will relate to the time zone used for readings.

I'm also happy to help make this happen by either working with you or doing it as an addition to this work. Having done a fair amount with time zones in moment I can say it can be a little tricky to use the right code (and why there are so many comment about it in the code). I welcome your thoughts on doing this and how it will get done.

@rianhassett
Copy link

Thanks to @w-b-d, @anntreasajojo, @rianhassett & @nickhitos for this contribution, esp. since I think it is your first one to OED. Overall, it works well. I have made a few comments within files to consider. Here are some global ones:

The box indicating everyone signed the CLA is checked but the OED records do not show that @rianhassett & @nickhitos have signed. Could they please sign or let me know if you think our records are off.

I tried using a chart link from a graphic that had the slider range set so the left side differed from the data range of the graphic. If I don't use the new option then it reproduces the slider range. If I use the new option then it does not. I also tried to test the new option by doing: const now = moment('2025-08-28 10:35:00'); in timeSpan in src/client/app/redux/slices/graphSlice.ts. This shifted the current time forward to convince the code the chart link was used in the future. It seems to do that and changes leftBound but it does not change what the graphic shows. I have not investigated the cause. I looked at the design document and it talks about two values that needed to be fixed (in the general case): 1) the data fetched from the server (server range); 2) the points displayed on the graphic (slider range). The code in src/client/app/redux/slices/graphSlice.ts only seems to adjust current.rangeSliderInterval and I think it might relate to that. I appreciate this is subtle so please ask questions or seek my help (I can do video calls) as needed.

Hey @huss! Thanks for the feedback, currently our classes just started but I do want to continue with this, I will try fixing these issues when I can.

@huss
Copy link
Member

huss commented Aug 25, 2025

Hey @huss! Thanks for the feedback, currently our classes just started but I do want to continue with this, I will try fixing these iss

@rianhassett Thanks for letting me know. This work is not on a tight clock so as long as it moves forward at a reasonable pace that is fine. I understand that you have classes. Anyone else on the team is welcome to continue. Also, I have your (and all the CLAs) now.

@huss
Copy link
Member

huss commented Nov 19, 2025

Hey @huss! Thanks for the feedback, currently our classes just started but I do want to continue with this, I will try fixing these iss

@rianhassett Thanks for letting me know. This work is not on a tight clock so as long as it moves forward at a reasonable pace that is fine. I understand that you have classes. Anyone else on the team is welcome to continue. Also, I have your (and all the CLAs) now.

@w-b-d, @anntreasajojo, @rianhassett & @nickhitos I was looking at all the open PRs and wanted to touch base to verify you still want to work on this. Thanks for any information.

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.

5 participants