Lint components
This commit is contained in:
parent
213808d3aa
commit
8452995c31
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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}
|
||||
/>
|
||||
</>
|
||||
|
|
Loading…
Reference in New Issue
Block a user