import type { IFinal } from "../../api/Channel"; interface IWidget { data?: IFinal[]; width?: number; } const ProgressSvgWidget = ({ data, width = 300 }: IWidget) => { //绘制句子进度 if (typeof data === "undefined" || data.length === 0) { return <>; } //进度 let svg_width = 0; if (data) { for (const iterator of data) { svg_width += iterator[0]; } } const svg_height = svg_width / 10; let curr_x = 0; let finished = 0; const innerBar = data?.map((item, id) => { const stroke_width = item[0]; curr_x += stroke_width; finished += item[1] ? stroke_width : 0; return ( ); }); const finishedBar = ( ); const progress = ( {innerBar} {finishedBar} ); return
{progress}
; }; export default ProgressSvgWidget;