-
Notifications
You must be signed in to change notification settings - Fork 0
Emissions lineplots #660
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
Merged
Merged
Emissions lineplots #660
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
979fa7c
fix from #659
cjyetman 5ce4228
display emissions data in line charts
cjyetman 90a9e38
Merge branch 'main' into emissions-lineplots
cjyetman 3c73739
Merge branch 'main' into emissions-lineplots
cjyetman afb5442
Merge branch 'main' into emissions-lineplots
cjyetman 2303020
Merge branch 'main' into emissions-lineplots
cjyetman adef7f5
Merge branch 'main' into emissions-lineplots
AlexAxthelm 2402e1c
Merge branch 'main' into emissions-lineplots
jacobvjk b66abaa
use linecharts for emissions metrics consistenly across views
jacobvjk 78a5a84
Merge branch 'main' into emissions-lineplots
jacobvjk 00d0980
feat: use line plots instead of bar charts
jacobvjk dc5e5bc
address comments
jacobvjk 566e6cc
Merge branch 'main' into emissions-lineplots
jacobvjk 190fd24
rm bar chart component
jacobvjk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
| import { render, screen } from "@testing-library/react"; | ||
| import userEvent from "@testing-library/user-event"; | ||
| import { PlotSelector } from "./PlotSelector"; | ||
| import type { TimeSeries } from "./PlotSelector"; | ||
| import MultiLineChart from "./MultiLineChart"; | ||
|
|
||
| vi.mock("./MultiLineChart", () => ({ | ||
| default: vi.fn(() => <div data-testid="multi-line-chart" />), | ||
| })); | ||
| vi.mock("./NormalizedStackedAreaChart", () => ({ | ||
| default: () => <div data-testid="stacked-area-chart" />, | ||
| })); | ||
| vi.mock("../utils/geographyUtils", () => ({ | ||
| geographyLabel: (geo: string) => geo, | ||
| })); | ||
|
|
||
| const mockedMultiLineChart = vi.mocked(MultiLineChart); | ||
|
|
||
| function makeTimeseries(metric: string): TimeSeries { | ||
| return { | ||
| data: [ | ||
| { | ||
| sector: "power", | ||
| metric, | ||
| geography: "Global", | ||
| year: "2020", | ||
| value: 100, | ||
| unit: "MtCO2e", | ||
| technology: metric, | ||
| }, | ||
| { | ||
| sector: "power", | ||
| metric, | ||
| geography: "Global", | ||
| year: "2030", | ||
| value: 200, | ||
| unit: "MtCO2e", | ||
| technology: metric, | ||
| }, | ||
| ], | ||
| }; | ||
| } | ||
|
|
||
| describe("PlotSelector", () => { | ||
| beforeEach(() => { | ||
| mockedMultiLineChart.mockClear(); | ||
| }); | ||
|
|
||
| it("forces the emissions intensity line chart's y-axis minimum to 0", async () => { | ||
| render( | ||
| <PlotSelector timeseriesdata={makeTimeseries("emissionsIntensity")} />, | ||
| ); | ||
|
|
||
| const plotSelect = screen.getByLabelText("Select Plot"); | ||
| await userEvent.setup().selectOptions(plotSelect, "Emissions Intensity"); | ||
|
|
||
| expect(mockedMultiLineChart).toHaveBeenCalled(); | ||
| const props = mockedMultiLineChart.mock.calls.at(-1)?.[0]; | ||
| expect(props?.yMin).toBe(0); | ||
| }); | ||
|
|
||
| it("leaves the absolute emissions line chart's y-axis minimum unset (natural extent)", async () => { | ||
| render( | ||
| <PlotSelector timeseriesdata={makeTimeseries("absoluteEmissions")} />, | ||
| ); | ||
|
|
||
| const plotSelect = screen.getByLabelText("Select Plot"); | ||
| await userEvent.setup().selectOptions(plotSelect, "Absolute Emissions"); | ||
|
|
||
| expect(mockedMultiLineChart).toHaveBeenCalled(); | ||
| const props = mockedMultiLineChart.mock.calls.at(-1)?.[0]; | ||
| expect(props?.yMin).toBeUndefined(); | ||
| }); | ||
| }); | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.