Skip to content

Commit cf669b4

Browse files
committed
feat: set percentage for graph markers
1 parent f60eacd commit cf669b4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/index.mjs

+5-3
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,12 @@ export const graph = (
504504

505505
ctx.strokeStyle = "rgba(50,50,50, 0.8)";
506506
for (const marker of markers) {
507-
ctx.moveTo(lOffset, top_offset);
508-
ctx.lineTo(lOffset, top_offset + work_height);
507+
const text = Array.isArray(marker) ? marker[1] : marker;
508+
const xOffset = Array.isArray(marker) ? (work_width * marker[0]) + padding : lOffset;
509+
ctx.moveTo(xOffset, top_offset);
510+
ctx.lineTo(xOffset, top_offset + work_height);
509511
ctx.stroke();
510-
ctx.fillText(marker, lOffset, top_offset + work_height - 14);
512+
ctx.fillText(text, xOffset, top_offset + work_height - 14);
511513
lOffset += marker_len;
512514
}
513515
}

0 commit comments

Comments
 (0)