import React from "react"; import { useWidgetStore } from "../../../../../store/useWidgetStore"; import { ChartType } from "chart.js/auto"; import ChartComponent from "./ChartComponent"; import { StockIncreseIcon } from "../../../../icons/RealTimeVisulationIcons"; const chartTypes: ChartType[] = [ "bar", "line", "pie", "doughnut", "polarArea", ]; const sampleData = { labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"], datasets: [ { data: [65, 59, 80, 81, 56, 55, 40], backgroundColor: "#6f42c1", borderColor: "#ffffff", borderWidth: 1, }, ], }; interface WidgetProps { type: ChartType; index: number; title: string; } const ChartWidget: React.FC = ({ type, index, title }) => { const { setDraggedAsset } = useWidgetStore((state) => state); return (
{ setDraggedAsset({ type, id: `widget-${index + 1}`, title, panel: "top", data: sampleData, }); }} onDragEnd={() => setDraggedAsset(null)} >
); }; const ProgressBarWidget = ({ id, title, data, }: { id: string; title: string; data: any; }) => { const { setDraggedAsset } = useWidgetStore((state) => state); return (
{ setDraggedAsset({ type: "progress", id, title, panel: "top", data, }); }} onDragEnd={() => setDraggedAsset(null)} >
{title}
{data.stocks.map((stock: any, index: number) => (
{stock.key}
{stock.value}
{stock.description}
))}
); }; const Widgets2D = () => { return (
{chartTypes.map((type, index) => { const widgetTitle = `Widget ${index + 1}`; return ( ); })}
); }; export default Widgets2D;