show either result or bindings in viewer
This commit is contained in:
parent
4a3c982c57
commit
59ed741f33
|
@ -1,5 +1,12 @@
|
|||
import * as React from "react";
|
||||
import { SqValue, environment, defaultEnvironment } from "@quri/squiggle-lang";
|
||||
import {
|
||||
SqValue,
|
||||
environment,
|
||||
defaultEnvironment,
|
||||
resultMap,
|
||||
SqValueLocation,
|
||||
SqValueTag,
|
||||
} from "@quri/squiggle-lang";
|
||||
import { useSquiggle } from "../lib/hooks";
|
||||
import { SquiggleViewer } from "./SquiggleViewer";
|
||||
|
||||
|
@ -97,28 +104,20 @@ export const SquiggleChart: React.FC<SquiggleChartProps> = React.memo(
|
|||
count: diagramCount,
|
||||
};
|
||||
|
||||
const resultToRender = resultMap(result, (value) =>
|
||||
value.tag === SqValueTag.Void ? bindings.asValue() : value
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SquiggleViewer
|
||||
result={result}
|
||||
width={width}
|
||||
height={height}
|
||||
distributionPlotSettings={distributionPlotSettings}
|
||||
chartSettings={chartSettings}
|
||||
environment={environment ?? defaultEnvironment}
|
||||
enableLocalSettings={enableLocalSettings}
|
||||
/>
|
||||
<hr className="my-4" />
|
||||
<SquiggleViewer
|
||||
result={{ tag: "Ok", value: bindings.asValue() }}
|
||||
width={width}
|
||||
height={height}
|
||||
distributionPlotSettings={distributionPlotSettings}
|
||||
chartSettings={chartSettings}
|
||||
environment={environment ?? defaultEnvironment}
|
||||
enableLocalSettings={enableLocalSettings}
|
||||
/>
|
||||
</div>
|
||||
<SquiggleViewer
|
||||
result={resultToRender}
|
||||
width={width}
|
||||
height={height}
|
||||
distributionPlotSettings={distributionPlotSettings}
|
||||
chartSettings={chartSettings}
|
||||
environment={environment ?? defaultEnvironment}
|
||||
enableLocalSettings={enableLocalSettings}
|
||||
/>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -18,4 +18,4 @@ export type MergedItemSettings = {
|
|||
};
|
||||
|
||||
export const locationAsString = (location: SqValueLocation) =>
|
||||
location.path.root + "/" + location.path.items.join(".");
|
||||
location.path.items.join(".");
|
||||
|
|
|
@ -20,4 +20,11 @@ export class SqModule {
|
|||
this.location
|
||||
);
|
||||
}
|
||||
|
||||
get(k: string) {
|
||||
const v = RSModuleValue.get(this._value, k);
|
||||
return v === undefined || v === null
|
||||
? undefined
|
||||
: wrapValue(v, this.location.extend(k));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,3 +11,6 @@ let toString = (v: squiggleValue_Module): string =>
|
|||
|
||||
@genType
|
||||
let toSquiggleValue = (v: squiggleValue_Module): squiggleValue => IEvBindings(v)
|
||||
|
||||
@genType
|
||||
let get = ReducerInterface_InternalExpressionValue.nameSpaceGet
|
||||
|
|
|
@ -239,3 +239,9 @@ let nameSpaceToKeyValuePairs = (nameSpace: nameSpace): array<(string, t)> => {
|
|||
let NameSpace(container) = nameSpace
|
||||
container->Belt.Map.String.toArray
|
||||
}
|
||||
|
||||
let nameSpaceGet = (nameSpace: nameSpace, key: string): option<t> => {
|
||||
let NameSpace(container) = nameSpace
|
||||
container->Belt.Map.String.get(key)
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user