import Plot from "react-plotly.js"; import { useState } from "react"; interface BenchmarkBarChartProps { title: string; data: ChartData[]; dataKey: keyof Pick< ChartData, "compression_ratio" | "encode_speed" | "decode_speed" >; color: string; xAxisTitle: string; } function BenchmarkBarChart({ title, data, dataKey, color, xAxisTitle, }: BenchmarkBarChartProps) { return (

{title}

d.algorithm), x: data.map((d) => d[dataKey]), marker: { color }, }, ]} layout={{ width: 700, height: Math.max(300, data.length * 23 + 40), margin: { t: 5, r: 30, l: 200, b: 30 }, xaxis: { title: xAxisTitle }, yaxis: { automargin: true, ticksuffix: " " }, dragmode: false, }} config={{ displayModeBar: false }} />
); } interface ChartData { algorithm: string; compression_ratio: number; encode_speed: number; decode_speed: number; } interface BenchmarkChartsProps { chartData: ChartData[]; } export function BenchmarkCharts({ chartData }: BenchmarkChartsProps) { const [sortByRatio, setSortByRatio] = useState(true); if (!chartData.length) return null; const sortedData = sortByRatio ? [...chartData].sort((a, b) => a.compression_ratio - b.compression_ratio) : chartData; return (
); }