Minor fixes

This commit is contained in:
Ozzie Gooen 2022-05-26 08:23:43 -04:00
parent 298d3923bc
commit d630f7335d
3 changed files with 17 additions and 19 deletions

View File

@ -12,7 +12,7 @@ import {
defaultBindings, defaultBindings,
defaultEnvironment, defaultEnvironment,
declarationArg, declarationArg,
declaration declaration,
} from "@quri/squiggle-lang"; } from "@quri/squiggle-lang";
import { NumberShower } from "./NumberShower"; import { NumberShower } from "./NumberShower";
import { DistributionChart } from "./DistributionChart"; import { DistributionChart } from "./DistributionChart";
@ -25,14 +25,12 @@ function getRange<a>(x: declaration<a>) {
case "Float": { case "Float": {
return { floats: { min: first.value.min, max: first.value.max } }; return { floats: { min: first.value.min, max: first.value.max } };
} }
case "Time": { case "Date": {
return { time: { min: first.value.min, max: first.value.max } }; return { time: { min: first.value.min, max: first.value.max} };
} }
} }
} }
function getChartSettings<a>( function getChartSettings<a>(x: declaration<a>): FunctionChartSettings {
x: declaration<a>
): FunctionChartSettings {
let range = getRange(x); let range = getRange(x);
let min = range.floats ? range.floats.min : 0; let min = range.floats ? range.floats.min : 0;
let max = range.floats ? range.floats.max : 10; let max = range.floats ? range.floats.max : 10;
@ -207,7 +205,6 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
/> />
</div> </div>
))} ))}
)
</VariableBox> </VariableBox>
); );
case "arraystring": case "arraystring":
@ -241,17 +238,17 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
/> />
); );
case "lambdaDeclaration": { case "lambdaDeclaration": {
return ( return (
<FunctionChart <FunctionChart
fn={expression.value.fn} fn={expression.value.fn}
chartSettings={getChartSettings(expression.value)} chartSettings={getChartSettings(expression.value)}
environment={{ environment={{
sampleCount: environment.sampleCount / 10, sampleCount: environment.sampleCount / 10,
xyPointLength: environment.xyPointLength / 10, xyPointLength: environment.xyPointLength / 10,
}} }}
/> />
); );
} }
default: { default: {
return <>Should be unreachable</>; return <>Should be unreachable</>;
} }

View File

@ -75,6 +75,7 @@
"name": "xscale", "name": "xscale",
"type": "linear", "type": "linear",
"nice": true, "nice": true,
"zero": false,
"domain": { "domain": {
"data": "facet", "data": "facet",
"field": "x" "field": "x"

View File

@ -102,7 +102,7 @@ type rescriptDeclarationArg =
max: number; max: number;
} }
| { | {
TAG: 1; // Float TAG: 1; // Date
min: Date; min: Date;
max: Date; max: Date;
}; };