import { defineChart, link } from "@tanstack/charts"
import { scaleLinear } from "@tanstack/charts/scales/linear"
import { tooltip } from "@tanstack/charts/tooltip"
import { scaleUtc } from "d3-scale"
import { Chart, chartColors } from "@/components/ui/tanstack-chart"
{ date: "2013-05-13", open: 64.5, high: 65.41, low: 64.5, close: 64.96 },
{ date: "2013-05-14", open: 64.84, high: 65.03, low: 63.16, close: 63.41 },
{ date: "2013-05-15", open: 62.74, high: 63, low: 60.34, close: 61.26 },
].map((session) => ({ ...session, date: new Date(session.date) }))
const gains = sessions.filter((session) => session.close >= session.open)
const losses = sessions.filter((session) => session.close < session.open)
const definition = defineChart(
x1: "date", y1: "low", x2: "date", y2: "high",
stroke: chartColors.label,
x1: "date", y1: "open", x2: "date", y2: "close",
stroke: chartColors.positive,
x1: "date", y1: "open", x2: "date", y2: "close",
stroke: chartColors.negative,
y: { scale: scaleLinear, grid: true, axis: { label: "Price (USD)" } },
title: point?.datum.date.toLocaleDateString("en-US", { timeZone: "UTC" }) ?? "",
{ label: "Open", value: `$${point?.datum.open}` },
{ label: "High", value: `$${point?.datum.high}` },
{ label: "Low", value: `$${point?.datum.low}` },
{ label: "Close", value: `$${point?.datum.close}` },
export function PriceChart() {
ariaLabel="Apple daily open, high, low and close prices, May 13 to 15, 2013"