diff --git a/frontend/app/block/block.tsx b/frontend/app/block/block.tsx index 0140912b3b..698f640429 100644 --- a/frontend/app/block/block.tsx +++ b/frontend/app/block/block.tsx @@ -9,7 +9,6 @@ import { FullSubBlockProps, SubBlockProps, } from "@/app/block/blocktypes"; -import { PlotView } from "@/app/view/plotview/plotview"; import { PreviewModel, PreviewView, makePreviewModel } from "@/app/view/preview/preview"; import { SysinfoView, SysinfoViewModel, makeSysinfoViewModel } from "@/app/view/sysinfo/sysinfo"; import { VDomView, makeVDomModel } from "@/app/view/vdom/vdom"; @@ -88,9 +87,6 @@ function getViewElem( /> ); } - if (blockView === "plot") { - return ; - } if (blockView === "web") { return ; } diff --git a/frontend/app/view/plotview/plotview.scss b/frontend/app/view/plotview/plotview.scss deleted file mode 100644 index 9f12d37a40..0000000000 --- a/frontend/app/view/plotview/plotview.scss +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2024, Command Line Inc. -// SPDX-License-Identifier: Apache-2.0 - -.plot-view { - width: 100%; - - .plot-window { - display: flex; - justify-content: center; - } - - .plot-config { - width: 100%; - margin: 0; - padding: 0; - resize: none; - height: 50vh; - background-color: var(--panel-bg-color); - color: var(--main-text-color); - font: var(--fixed-font); - } -} diff --git a/frontend/app/view/plotview/plotview.tsx b/frontend/app/view/plotview/plotview.tsx deleted file mode 100644 index e3261758fd..0000000000 --- a/frontend/app/view/plotview/plotview.tsx +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2025, Command Line Inc. -// SPDX-License-Identifier: Apache-2.0 - -import { Button } from "@/element/button"; -import { WaveModal } from "@/element/modal"; -import * as Plot from "@observablehq/plot"; -import * as d3 from "d3"; -import * as React from "react"; - -import "./plotview.scss"; - -function PlotWindow() { - return
; -} - -function PlotConfig() { - return ; -} - -const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; - -function evalAsync(Plot: any, d3: any, funcText: string): Promise { - return new Promise((resolve, reject) => { - new AsyncFunction( - "resolve", - "reject", - "Plot", - "d3", - `try { await ${funcText}; resolve(); } catch(e) { reject(e); } }` - )(resolve, reject, Plot, d3); - }); -} - -function PlotView() { - const containerRef = React.useRef(); - const [plotDef, setPlotDef] = React.useState(); - const [savedDef, setSavedDef] = React.useState(); - const [modalUp, setModalUp] = React.useState(false); - /* - const [data, setData] = React.useState(); - - React.useEffect(() => { - d3.csv("/plotdata/congress.csv", d3.autoType).then(setData); - }, []); - */ - - React.useEffect(() => { - // replace start - /* - d3.csv("/plotdata/congress.csv", d3.autoType).then((out) => data = out); - return Plot.plot({ - aspectRatio: 1, - x: { label: "Age (years)" }, - y: { - grid: true, - label: "← Women · Men →", - labelAnchor: "center", - tickFormat: Math.abs, - }, - marks: [ - Plot.dot( - data, - Plot.stackY2({ - x: (d) => 2023 - d.birthday.getUTCFullYear(), - y: (d) => (d.gender === "M" ? 1 : -1), - fill: "gender", - title: "full_name", - }) - ), - Plot.ruleY([0]), - ], - }); - */ - // replace end - let plot; - let plotErr; - try { - console.log(plotDef); - plot = new Function("Plot", "d3", plotDef)(Plot, d3); - //plot = new Function("Plot", "data", "d3", plotDef)(Plot, data, d3); - //evalAsync(Plot, d3, plotDef).then((out) => (plot = out)); - } catch (e) { - plotErr = e; - console.log("error: ", e); - return; - } - console.log(plot); - - if (plot !== undefined) { - containerRef.current.append(plot); - } else { - // todo - } - - return () => { - if (plot !== undefined) { - plot.remove(); - } - }; - }, [plotDef]); - - const handleOpen = React.useCallback(() => { - setSavedDef(plotDef); - setModalUp(true); - }, []); - - const handleCancel = React.useCallback(() => { - setPlotDef(savedDef); - setModalUp(false); - }, []); - - const handleSave = React.useCallback(() => { - setModalUp(false); - }, []); - - return ( -
- -
- {modalUp && ( - -