Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error bar #975

Merged
merged 23 commits into from
Aug 17, 2023
Merged

Error bar #975

merged 23 commits into from
Aug 17, 2023

Conversation

Elias0127
Copy link
Contributor

@Elias0127 Elias0127 commented Jul 31, 2023

Description

We grabbed the min and max data from the database and added it to the line graph as error bars. Note that we did not write the SQL query (src/server/sql/reading/create_reading_views.sql) that was responsible for creating the min and max data in the database. The code was already written, and we only uncommented it.

This is a joint work
Co-authored - by JesseVarGar

Fixes #594

Type of change

(Check the ones that apply by placing an "x" instead of the space in the [ ] so it becomes [x])

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

Checklist

(Note what you have done by placing an "x" instead of the space in the [ ] so it becomes [x]. It is hoped you do all of them.)

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request

Limitations

Adding min and max to the database caused a mismatch with the tests and resulted in them failing.

@Elias0127 Elias0127 marked this pull request as ready for review July 31, 2023 22:41
Copy link
Contributor

@spearec spearec left a comment

Choose a reason for hiding this comment

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

Overall, great work from @Elias0127 and @JesseVarGar. This is a good implementation of the work that was done on the backend. I've got a few small code styling comments, and there are also two issues with the implementation.

As noted below, the min/max points array is kept across meters, which leads to problems when displaying bars on multiple meters.

Additionally, there should not be error bars for meter-resolution data. Currently, the code tries to display error bars on this data, which leads to errors in the console as well as weird plotly output.
image

src/client/app/actions/lineReadings.ts Outdated Show resolved Hide resolved
src/client/app/components/ErrorBarComponent.tsx Outdated Show resolved Hide resolved
src/client/app/containers/LineChartContainer.ts Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/types/redux/graph.ts Show resolved Hide resolved
src/server/migrations/1.0.0-1.1.0/index.js Show resolved Hide resolved
src/client/app/containers/LineChartContainer.ts Outdated Show resolved Hide resolved
src/client/app/containers/LineChartContainer.ts Outdated Show resolved Hide resolved
@Elias0127 Elias0127 requested a review from spearec August 3, 2023 18:08
@huss
Copy link
Member

huss commented Aug 4, 2023

@Elias0127 From the records I have, you have yet to sign the CLA for OED. OED needs a signed CLA to accept this work. If you think my records are in error then please let me know.

@huss
Copy link
Member

huss commented Aug 4, 2023

Before this PR I pushed a commit to get the tests working. I want to note that the fix did not include testing the new error bar values returned. I have opened issue #984 so the tests will be enhanced in the future. For now, the PR will be manually tested.

@huss
Copy link
Member

huss commented Aug 4, 2023

There is a slightly annoying behavior where adding error bars to some meters shifts the slider bars for the time range. What is interesting is the actual range displayed is not altered but the slider can now be zoomed out to earlier and later dates. If you graph test15MinSin over all time with and without error bars you can see the effect. I tried to debug this and found that simply commenting out the include of the error_y but leaving all the calculations removes the shift. This was consistent with finding that the graphic values seemed the same for the values with and without the error bars except for the error ranges. I have looked at the data in the debugger and it only seems to change the y-axis values so why the x-axis is effected is unclear. It isn't a big issue and the graph is correct. I wanted to document this and also see if someone else has any ideas.

Per discussion and agreement with the developers of this PR, I added the
min/max error bars to the chart link ability.
@huss
Copy link
Member

huss commented Aug 4, 2023

Per agreement with the developers of this PR, I just added min/max to the chart link. It should work correctly now and reproduce the desired graphic. Others should test that it is correct and code is okay.

@Elias0127
Copy link
Contributor Author

@Elias0127 From the records I have, you have yet to sign the CLA for OED. OED needs a signed CLA to accept this work. If you think my records are in error then please let me know.

@Elias0127 Elias0127 closed this Aug 4, 2023
@Elias0127 Elias0127 reopened this Aug 4, 2023
The line graphic no longer shows min/max values on raw data. This is
done by setting the values to null in Redux and NaN from the DB.
The graphic shows each meter so if one is raw it will
not show min/max but if another in the same graphic is not raw then
the min/max is shown.
@huss
Copy link
Member

huss commented Aug 4, 2023

Given the comments by @spearec, I have removed min/max for any meter that is raw data. Other meters still show min/max. Again, others should check this out to agree that this is a good fix.

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.

Congratulation to Elias and Jesse on their first PR to OED. Thanks for through work. My testing did not find any issues. I made a few comments that should be addressed. I also note:

  • I made a few commits to the PR (see comments to PR) that others should look at and verify to be correct.
  • I edited the description to remove the [ ] around the issue number so GitHub properly links.

src/client/app/actions/lineReadings.ts Outdated Show resolved Hide resolved
src/client/app/components/UIOptionsComponent.tsx Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/utils/exportData.ts Outdated Show resolved Hide resolved
src/server/models/Reading.js Outdated Show resolved Hide resolved
src/client/app/containers/LineChartContainer.ts Outdated Show resolved Hide resolved
@huss
Copy link
Member

huss commented Aug 4, 2023

* I made a few commits to the PR (see comments to PR) that others should look at and verify to be correct.

Thanks to @spearec for catching my mistake. I missed all the zero value at the bottom of the graphic. I believe their fix is correct.

Copy link
Contributor

@spearec spearec left a comment

Choose a reason for hiding this comment

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

Most of the above comments have been addressed. I just have a couple of minor things to note.

src/client/app/reducers/graph.ts Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/translations/data.js Outdated Show resolved Hide resolved
src/client/app/containers/LineChartContainer.ts Outdated Show resolved Hide resolved
@Elias0127 Elias0127 requested review from spearec and huss August 9, 2023 15:37
@huss
Copy link
Member

huss commented Aug 17, 2023

I have reviewed all the requested changes for both myself and @spearec. Everything looks good and this PR is ready to merge. I appreciate the efforts of @Elias0127 and @JesseVarGar and their understanding for the time it took us to do the final reviews.

@huss huss merged commit e6e9162 into OpenEnergyDashboard:development Aug 17, 2023
3 checks passed
@huss huss added this to the 1.1 release milestone Sep 1, 2023
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.

data range on line graphics
3 participants