import { useData, usePublish, type PanelRef } from '@jaspers-ai/sdk' import './styles.css' interface Bar { time: string open: number high: number low: number close: number volume: number | null [field: string]: unknown } interface State { ticker?: string multiplier?: number timespan?: string from?: string to?: string style?: 'candles' | 'line' } const W = 800 const PRICE_H = 250 const VOL_TOP = 262 const VOL_H = 60 const H = VOL_TOP + VOL_H + 18 const RIGHT = 56 const day = (n: number) => new Date(Date.now() - n * 86_400_000).toISOString().slice(0, 10) export function PriceView({ panel }: { panel: PanelRef }) { const state = useData(`workspaces/${panel.workspaceId}/panels/${panel.id}/state`) as State | undefined if (state === undefined) return
Loading…
const args = { ticker: (state.ticker ?? 'AAPL').trim().toUpperCase(), multiplier: state.multiplier ?? 1, timespan: state.timespan ?? 'day', from: state.from || day(182), to: state.to || day(0), sort: 'asc', limit: 5000, } return{error}
: null} {!data && !error ?Loading…
: null} {data && !bars.length ?No bars in that range.
: null} {bars.length ? : null}