Skip to content

Commit

Permalink
Merge pull request #1637 from masterismail/masterismail/issue1565
Browse files Browse the repository at this point in the history
corrected the rounding of percentages in parameter history hovercard
  • Loading branch information
anth-volk authored Apr 24, 2024
2 parents 4be3bca + 3787a55 commit d787797
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pages/policy/input/ParameterOverTime.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Plot from "react-plotly.js";
import { ChartLogo } from "../../../api/charts";
import { getPlotlyAxisFormat } from "../../../api/variables";
import {
getPlotlyAxisFormat,
formatVariableValue,
} from "../../../api/variables";
import useMobile from "../../../layout/Responsive";
import useWindowHeight from "layout/WindowHeight";
import style from "../../../style";
Expand Down Expand Up @@ -50,6 +53,11 @@ export default function ParameterOverTime(props) {
const xaxisFormat = getPlotlyAxisFormat("date", xaxisValues);
const yaxisFormat = getPlotlyAxisFormat(parameter.unit, yaxisValues);

const customData = y.map((value) => formatVariableValue(parameter, value, 2));
const reformedCustomData = reformedY.map((value) =>
formatVariableValue(parameter, value, 2),
);

return (
<>
<Plot
Expand All @@ -65,6 +73,8 @@ export default function ParameterOverTime(props) {
color: style.colors.GRAY,
},
name: "Current law",
customdata: customData,
hovertemplate: "%{x|%b, %Y}: %{customdata}<extra></extra>",
},
reformMap && {
x: reformedX,
Expand All @@ -78,6 +88,8 @@ export default function ParameterOverTime(props) {
color: style.colors.BLUE,
},
name: getReformPolicyLabel(policy),
customdata: reformedCustomData,
hovertemplate: "%{x|%b, %Y}: %{customdata}<extra></extra>",
},
].filter((x) => x)}
layout={{
Expand Down

0 comments on commit d787797

Please sign in to comment.