2022-06-20 05:35:48 +00:00
|
|
|
import React from "react";
|
|
|
|
// import { SquiggleChart } from "@quri/squiggle-components";
|
|
|
|
|
|
|
|
import dynamic from "next/dynamic";
|
|
|
|
|
|
|
|
const SquiggleChart = dynamic(
|
|
|
|
() => import("@quri/squiggle-components").then((mod) => mod.SquiggleChart),
|
|
|
|
{
|
|
|
|
loading: () => <p>Loading...</p>,
|
|
|
|
ssr: false,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
/*
|
|
|
|
const SquiggleChart = dynamic(
|
|
|
|
() => import("@quri/squiggle-components").then((mod) => mod.SquiggleChart),
|
|
|
|
{
|
|
|
|
suspense: true,
|
|
|
|
ssr: false,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
*/
|
|
|
|
|
|
|
|
const effectButtonStyle =
|
|
|
|
"bg-transparent m-2 hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded mt-5";
|
|
|
|
|
2022-06-25 01:38:07 +00:00
|
|
|
export function DynamicSquiggleChart({ element, stopShowing }) {
|
|
|
|
if (element == null) {
|
2022-06-20 05:47:11 +00:00
|
|
|
return "";
|
|
|
|
} else {
|
2022-06-25 01:38:07 +00:00
|
|
|
let usefulElement = {
|
|
|
|
name: element.id,
|
|
|
|
squiggleString: element.fn,
|
|
|
|
formula: element.formula
|
2022-06-20 05:47:11 +00:00
|
|
|
};
|
|
|
|
return (
|
|
|
|
<div className="">
|
2022-06-25 01:38:07 +00:00
|
|
|
<h3 className="text-2xl font-bold mb-5">{usefulElement.name}</h3>
|
2022-06-20 05:47:11 +00:00
|
|
|
<textarea
|
2022-06-25 01:38:07 +00:00
|
|
|
value={JSON.stringify(usefulElement, null, 4)}
|
2022-06-20 05:47:11 +00:00
|
|
|
//onChange={handleChange}
|
|
|
|
disabled={true}
|
2022-06-25 01:38:07 +00:00
|
|
|
rows={JSON.stringify(usefulElement, null, 4).split("\n").length}
|
2022-06-20 05:47:11 +00:00
|
|
|
cols={37}
|
|
|
|
className="text-left text-gray-600 bg-white rounded text-normal p-6 border-0 shadow outline-none focus:outline-none focus:ring mb-4"
|
|
|
|
/>
|
|
|
|
<SquiggleChart
|
2022-06-25 01:38:07 +00:00
|
|
|
squiggleString={element.squiggleString}
|
|
|
|
width={500}
|
2022-06-20 05:47:11 +00:00
|
|
|
height={200}
|
|
|
|
showSummary={true}
|
|
|
|
showTypes={true}
|
|
|
|
/>
|
|
|
|
{/*
|
|
|
|
SquiggleChart props:
|
|
|
|
squiggleString?: string;
|
|
|
|
sampleCount?: number;
|
|
|
|
environment?: environment;
|
|
|
|
chartSettings?: FunctionChartSettings;
|
|
|
|
onChange?(expr: squiggleExpression): void;
|
|
|
|
width?: number;
|
|
|
|
height?: number;
|
|
|
|
bindings?: bindings;
|
|
|
|
jsImports?: jsImports;
|
|
|
|
showSummary?: boolean;
|
|
|
|
showTypes?: boolean;
|
|
|
|
showControls?: boolean;
|
|
|
|
*/}
|
2022-06-20 05:35:48 +00:00
|
|
|
|
2022-06-20 05:47:11 +00:00
|
|
|
<button className={effectButtonStyle} onClick={() => stopShowing()}>
|
|
|
|
Hide chart
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
2022-06-20 05:35:48 +00:00
|
|
|
}
|
|
|
|
}
|