Responded to code review comments

This commit is contained in:
Ozzie Gooen 2022-04-07 07:28:33 -04:00
parent 0f0d0270d0
commit f8af290bcf
3 changed files with 17 additions and 12 deletions

View File

@ -12,7 +12,7 @@ import { createClassFromSpec } from "react-vega";
import * as chartSpecification from "./spec-distributions.json"; import * as chartSpecification from "./spec-distributions.json";
import * as percentilesSpec from "./spec-percentiles.json"; import * as percentilesSpec from "./spec-percentiles.json";
import { NumberShower } from "./NumberShower"; import { NumberShower } from "./NumberShower";
import styled from 'styled-components' import styled from "styled-components";
let SquiggleVegaChart = createClassFromSpec({ let SquiggleVegaChart = createClassFromSpec({
spec: chartSpecification as Spec, spec: chartSpecification as Spec,
@ -53,14 +53,17 @@ const Error = styled.div`
padding: 0.4em 0.8em; padding: 0.4em 0.8em;
`; `;
const ShowError: React.FC<{ heading:string, errorMessage: string }> = ({ heading="Error", errorMessage }) => { const ShowError: React.FC<{ heading: string; children: React.ReactNode }> = ({
heading = "Error",
children,
}) => {
return ( return (
<Error> <Error>
<h3>{heading}</h3> <h3>{heading}</h3>
<>{errorMessage}</> {children}
</Error> </Error>
); );
} };
export const SquiggleChart: React.FC<SquiggleChartProps> = ({ export const SquiggleChart: React.FC<SquiggleChartProps> = ({
squiggleString = "", squiggleString = "",
@ -72,7 +75,7 @@ export const SquiggleChart: React.FC<SquiggleChartProps> = ({
diagramStop = 10, diagramStop = 10,
diagramCount = 20, diagramCount = 20,
environment = [], environment = [],
onEnvChange = () => { }, onEnvChange = () => {},
width = 500, width = 500,
height = 60, height = 60,
}: SquiggleChartProps) => { }: SquiggleChartProps) => {
@ -247,7 +250,11 @@ export const SquiggleChart: React.FC<SquiggleChartProps> = ({
return <>{chartResults}</>; return <>{chartResults}</>;
} else if (result.tag === "Error") { } else if (result.tag === "Error") {
// At this point, we came across an error. What was our error? // At this point, we came across an error. What was our error?
return <ShowError heading={"Parse Error"} errorMessage={result.value} /> return (
<ShowError heading={"Parse Error"}>
{result.value}
</ShowError>
);
} }
return <p>{"Invalid Response"}</p>; return <p>{"Invalid Response"}</p>;
}; };
@ -336,4 +343,4 @@ function getPercentiles(percentiles: number[], t: DistPlus) {
}); });
return bounds; return bounds;
} }
} }

View File

@ -180,4 +180,4 @@
} }
} }
] ]
} }

View File

@ -20,9 +20,7 @@
"transform": [ "transform": [
{ {
"type": "aggregate", "type": "aggregate",
"groupby": [ "groupby": ["x"],
"x"
],
"ops": [ "ops": [
"mean", "mean",
"mean", "mean",
@ -372,4 +370,4 @@
} }
} }
] ]
} }