Lint components

This commit is contained in:
Sam Nolan 2022-05-02 17:01:09 +00:00
parent 213808d3aa
commit 8452995c31
2 changed files with 25 additions and 24 deletions

View File

@ -6,7 +6,7 @@ import { distributionErrorToString } from "@quri/squiggle-lang";
import { createClassFromSpec } from "react-vega";
import * as chartSpecification from "../vega-specs/spec-distributions.json";
import { ErrorBox } from "./ErrorBox";
import { useSize } from 'react-use';
import { useSize } from "react-use";
let SquiggleVegaChart = createClassFromSpec({
spec: chartSpecification as Spec,
@ -23,12 +23,12 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
height,
width,
}: DistributionChartProps) => {
const [sized, _] = useSize((size) => {
let shape = distribution.pointSet();
let widthProp = width !== undefined ? width - 20 : size.width - 10;
if (shape.tag === "Ok") {
return ( <div>
return (
<div>
<SquiggleVegaChart
data={{ con: shape.value.continuous, dis: shape.value.discrete }}
width={widthProp}
@ -38,13 +38,14 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
</div>
);
} else {
return (<div>
return (
<div>
<ErrorBox heading="Distribution Error">
{distributionErrorToString(shape.value)}
</ErrorBox>
</div>
)
);
}
})
});
return sized;
};

View File

@ -121,7 +121,7 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
<RecordKeyHeader>{key}</RecordKeyHeader>
<SquiggleItem
expression={r}
width={width !== undefined? width - 20 : width}
width={width !== undefined ? width - 20 : width}
height={50}
/>
</>