diff --git a/packages/components/src/components/SquiggleChart.tsx b/packages/components/src/components/SquiggleChart.tsx index ab6fbb9c..15400d3f 100644 --- a/packages/components/src/components/SquiggleChart.tsx +++ b/packages/components/src/components/SquiggleChart.tsx @@ -10,6 +10,7 @@ import { jsImports, defaultImports, defaultBindings, + defaultEnvironment, } from "@quri/squiggle-lang"; import { NumberShower } from "./NumberShower"; import { DistributionChart } from "./DistributionChart"; @@ -204,7 +205,7 @@ export interface SquiggleChartProps { /** If the output requires monte carlo sampling, the amount of samples */ sampleCount?: number; /** The amount of points returned to draw the distribution */ - environment: environment; + environment?: environment; /** If the result is a function, where the function starts, ends and the amount of stops */ chartSettings?: FunctionChartSettings; /** When the environment changes */ @@ -245,6 +246,7 @@ export const SquiggleChart: React.FC = ({ chartSettings = defaultChartSettings, }: SquiggleChartProps) => { let expressionResult = run(squiggleString, bindings, environment, jsImports); + let e = environment ? environment : defaultEnvironment; let internal: JSX.Element; if (expressionResult.tag === "Ok") { let expression = expressionResult.value; @@ -258,7 +260,7 @@ export const SquiggleChart: React.FC = ({ showTypes={showTypes} showControls={showControls} chartSettings={chartSettings} - environment={environment} + environment={e} /> ); } else { diff --git a/packages/components/src/components/SquiggleEditor.tsx b/packages/components/src/components/SquiggleEditor.tsx index 4b17b585..c4ac1876 100644 --- a/packages/components/src/components/SquiggleEditor.tsx +++ b/packages/components/src/components/SquiggleEditor.tsx @@ -21,9 +21,7 @@ export interface SquiggleEditorProps { /** The input string for squiggle */ initialSquiggleString?: string; /** If the output requires monte carlo sampling, the amount of samples */ - sampleCount?: number; - /** The amount of points returned to draw the distribution */ - outputXYPoints?: number; + environment?: environment; /** If the result is a function, where the function starts */ diagramStart?: number; /** If the result is a function, where the function ends */ @@ -55,8 +53,7 @@ const Input = styled.div` export let SquiggleEditor: React.FC = ({ initialSquiggleString = "", width, - sampleCount = 1000, - outputXYPoints = 1000, + environment, diagramStart = 0, diagramStop = 10, diagramCount = 100, @@ -73,10 +70,6 @@ export let SquiggleEditor: React.FC = ({ stop: diagramStop, count: diagramCount, }; - let env: environment = { - sampleCount: sampleCount, - xyPointLength: outputXYPoints, - }; return (
@@ -90,9 +83,8 @@ export let SquiggleEditor: React.FC = ({ = ({ initialSquiggleString = "", onChange, bindings = defaultBindings, - sampleCount = 1000, - outputXYPoints = 1000, + environment, jsImports = defaultImports, }: SquigglePartialProps) => { - let samplingInputs: environment = { - sampleCount: sampleCount, - xyPointLength: outputXYPoints, - }; let [expression, setExpression] = React.useState(initialSquiggleString); let [error, setError] = React.useState(null); @@ -181,7 +164,7 @@ export let SquigglePartial: React.FC = ({ let squiggleResult = runPartial( expression, bindings, - samplingInputs, + environment, jsImports ); if (squiggleResult.tag == "Ok") {