Minor fixes
This commit is contained in:
parent
c5673fd1b1
commit
5d8f07c1b4
|
@ -12,7 +12,6 @@ import {
|
||||||
defaultBindings,
|
defaultBindings,
|
||||||
defaultEnvironment,
|
defaultEnvironment,
|
||||||
continuousDeclaration,
|
continuousDeclaration,
|
||||||
declarationContinuousArg,
|
|
||||||
} from "@quri/squiggle-lang";
|
} from "@quri/squiggle-lang";
|
||||||
import { NumberShower } from "./NumberShower";
|
import { NumberShower } from "./NumberShower";
|
||||||
import { DistributionChart } from "./DistributionChart";
|
import { DistributionChart } from "./DistributionChart";
|
||||||
|
@ -20,23 +19,29 @@ import { ErrorBox } from "./ErrorBox";
|
||||||
import { FunctionChart, FunctionChartSettings } from "./FunctionChart";
|
import { FunctionChart, FunctionChartSettings } from "./FunctionChart";
|
||||||
|
|
||||||
function getRange<a>(x: continuousDeclaration<a>) {
|
function getRange<a>(x: continuousDeclaration<a>) {
|
||||||
let first = x.args[0]
|
let first = x.args[0];
|
||||||
switch(first.tag){
|
switch (first.tag) {
|
||||||
case "Float": {return{floats: {min: first.value.min, max: first.value.max}}}
|
case "Float": {
|
||||||
case "Time": {return{time: {min: first.value.min, max: first.value.max}}}
|
return { floats: { min: first.value.min, max: first.value.max } };
|
||||||
|
}
|
||||||
|
case "Time": {
|
||||||
|
return { time: { min: first.value.min, max: first.value.max } };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getChartSettings<a>(x: continuousDeclaration<a>):FunctionChartSettings {
|
function getChartSettings<a>(
|
||||||
console.log("HERE")
|
x: continuousDeclaration<a>
|
||||||
let foo = getRange(x)
|
): FunctionChartSettings {
|
||||||
console.log("HIHI", foo)
|
console.log("HERE");
|
||||||
let min = foo.floats ? foo.floats.min : 0
|
let foo = getRange(x);
|
||||||
let max = foo.floats ? foo.floats.max : 10
|
console.log("HIHI", foo);
|
||||||
return ({
|
let min = foo.floats ? foo.floats.min : 0;
|
||||||
|
let max = foo.floats ? foo.floats.max : 10;
|
||||||
|
return {
|
||||||
start: min,
|
start: min,
|
||||||
stop: max,
|
stop: max,
|
||||||
count: 20,
|
count: 20,
|
||||||
})
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const variableBox = {
|
const variableBox = {
|
||||||
|
@ -230,7 +235,7 @@ const SquiggleItem: React.FC<SquiggleItemProps> = ({
|
||||||
return (
|
return (
|
||||||
<FunctionChart
|
<FunctionChart
|
||||||
fn={expression.value.value.fn}
|
fn={expression.value.value.fn}
|
||||||
chartSettings={chartSettings}
|
chartSettings={getChartSettings(expression.value.value)}
|
||||||
environment={{
|
environment={{
|
||||||
sampleCount: environment.sampleCount / 10,
|
sampleCount: environment.sampleCount / 10,
|
||||||
xyPointLength: environment.xyPointLength / 10,
|
xyPointLength: environment.xyPointLength / 10,
|
||||||
|
|
|
@ -33,8 +33,9 @@ let registry = [
|
||||||
Function.make(
|
Function.make(
|
||||||
~name="FnMake",
|
~name="FnMake",
|
||||||
~definitions=[
|
~definitions=[
|
||||||
FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) =>
|
FnDefinition.make(~name="declareFn", ~inputs=[Declaration.frType], ~run=(inputs, _) => {
|
||||||
inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue
|
inputs->E.A.unsafe_get(0)->Declaration.fromExpressionValue
|
||||||
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user