Reflect policy parameter changes in policy right sidebar and parameter-over-time chart #839
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.
Description
Fixes #53 and fixes #17. The issues are about accurately reflecting changes made through the policy editor inputs (dates, value) in the right sidebar and parameter-over-time chart.
Strategy for fix
The policy right sidebar (#53) and the parameter-over-time chart (#17) display the information in policy.reform.data, directly or via the getReformedParameter() function. I have modified getReformedParameter() so that the end date is also inserted into the reformed parameter, and I have used getReformedParameter() to construct new policy objects (see newReforms() in ParameterEditor.jsx). These changes ensure that the correct information is available to the right sidebar and the chart.
I have modified the input field component so that it does not store unnecessary state and calls the onChange function with the placeholder when the value is deleted from the field. This change was needed for #53.
I have added new logic for generating axis ranges for dates, and used it to update the parameter-over-time chart. This change helps with #17.
Tests
I have checked the behavior of the sidebar and the chart for policy inputs of different types (bool, %, numeric).
🤖 Generated by Copilot at ef787fe
Summary
🚀📈🧹
This pull request improves the functionality and performance of the parameter editing and plotting features in the policy engine app. It adds support for date units in plotly charts, simplifies the input field component, refactors the parameter editor component, enhances the parameter over time component, and optimizes the reform application algorithm.
Walkthrough
InputField
component by removing unnecessary state variablesavedPlaceholder
and using placeholder prop as default value when input field is empty, avoiding sending empty strings toonChange
prop (link, link, link, link)onChange
inParameterEditor
component, and use it for different types of controls (switch, slider, input field), removing unused state variable_
and converting input field value to number (link, link, link, link)ParameterOverTime
component by usinggetPlotlyAxisFormat
function to format x-axis when unit is "date", merging and filtering original and reformed values arrays for both axes, and using dashed line for reformed values trace (link, link, link)