diff --git a/packages/components/src/components/ErrorBox.tsx b/packages/components/src/components/ErrorBox.tsx
index 4e752ffd..e4f40062 100644
--- a/packages/components/src/components/ErrorBox.tsx
+++ b/packages/components/src/components/ErrorBox.tsx
@@ -1,5 +1,6 @@
import * as React from "react";
import { XCircleIcon } from "@heroicons/react/solid";
+import { InformationCircleIcon } from "@heroicons/react/solid";
export const ErrorBox: React.FC<{
heading: string;
@@ -18,4 +19,23 @@ export const ErrorBox: React.FC<{
);
+};
+
+export const MessageBox: React.FC<{
+ heading: string;
+ children: React.ReactNode;
+}> = ({ heading = "Note", children }) => {
+ return (
+
+
+
+
+
+
+
{heading}
+
{children}
+
+
+
+ );
};
\ No newline at end of file
diff --git a/packages/components/src/components/FunctionChart.tsx b/packages/components/src/components/FunctionChart.tsx
index bb5a9e24..56ba20ba 100644
--- a/packages/components/src/components/FunctionChart.tsx
+++ b/packages/components/src/components/FunctionChart.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
import { lambdaValue, environment, runForeign } from "@quri/squiggle-lang";
import { FunctionChart1Dist } from "./FunctionChart1Dist";
import { FunctionChart1Number } from "./FunctionChart1Number";
-import { ErrorBox } from "./ErrorBox";
+import { ErrorBox, MessageBox } from "./ErrorBox";
export type FunctionChartSettings = {
start: number;
@@ -23,52 +23,60 @@ export const FunctionChart: React.FC = ({
environment,
height,
}: FunctionChartProps) => {
- let result1 = runForeign(fn, [chartSettings.start], environment);
- let result2 = runForeign(fn, [chartSettings.stop], environment);
- let getValidResult = () => {
- if (result1.tag === "Ok") {
- return result1;
- } else if (result2.tag === "Ok") {
- return result2;
- } else {
- return result1;
- }
- };
- let validResult = getValidResult();
- let resultType = validResult.tag === "Ok" ? validResult.value.tag : "Error";
+ if (fn.parameters.length > 1) {
+ return (
+
+ Only functions with one parameter are displayed.
+
+ );
+ } else {
+ let result1 = runForeign(fn, [chartSettings.start], environment);
+ let result2 = runForeign(fn, [chartSettings.stop], environment);
+ let getValidResult = () => {
+ if (result1.tag === "Ok") {
+ return result1;
+ } else if (result2.tag === "Ok") {
+ return result2;
+ } else {
+ return result1;
+ }
+ };
+ let validResult = getValidResult();
+ let resultType = validResult.tag === "Ok" ? validResult.value.tag : "Error";
- let component = () => {
- switch (resultType) {
- case "distribution":
- return (
-
- );
- case "number":
- return (
-
- );
- case "Error":
- return (
- The function failed to be run
- );
- default:
- return (
-
- There is no function visualization for this type of function
-
- );
- }
- };
+ let component = () => {
+ switch (resultType) {
+ case "distribution":
+ return (
+
+ );
+ case "number":
+ return (
+
+ );
+ case "Error":
+ return (
+ The function failed to be run
+ );
+ default:
+ return (
+
+ There is no function visualization for this type of output
+
+ );
+ }
+ };
- return component();
+ return component();
+ }
};
diff --git a/packages/components/src/components/SquiggleChart.tsx b/packages/components/src/components/SquiggleChart.tsx
index 3b4232ce..3c3225d3 100644
--- a/packages/components/src/components/SquiggleChart.tsx
+++ b/packages/components/src/components/SquiggleChart.tsx
@@ -95,7 +95,9 @@ const SquiggleItem: React.FC = ({
case "number":
return (
-
+
+
+
);
case "distribution": {
@@ -124,10 +126,13 @@ const SquiggleItem: React.FC = ({
}
case "string":
return (
- {`"${expression.value}"`}
+
+ "
+
+ {expression.value}
+
+ "
+
);
case "boolean":
return (
@@ -138,7 +143,12 @@ const SquiggleItem: React.FC = ({
case "symbol":
return (
+
+ Undefined Symbol:
+
+
{expression.value}
+
);
case "call":
@@ -169,18 +179,22 @@ const SquiggleItem: React.FC = ({
return (
{Object.entries(expression.value).map(([key, r]) => (
-
-
{key}
-
+
))}
@@ -207,6 +221,9 @@ const SquiggleItem: React.FC
= ({
case "lambda":
return (
+ {`function(${expression.value.parameters.join(
+ ","
+ )})`}