Skip to content

Commit

Permalink
Fix issue when worker has negative width to draw
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Mar 28, 2024
1 parent 9666aca commit 8e089e8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions view/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ function startWorkForComponent(
chartsToChange,
messages =>
messages.map((_, i) => {
let step = Math.ceil(canvas.width / messages.length)
let step = Math.floor(canvas.width / messages.length)
let from = step * i + (i === 0 ? 0 : 1)
let to = Math.min(step * (i + 1), canvas.width)
if (i === messages.length - 1) to = canvas.width
return {
borderP3,
borderRec2020,
from: step * i + (i === 0 ? 0 : 1),
from,
height: canvas.height,
showP3: showP3.get(),
showRec2020: showRec2020.get(),
to: Math.min(step * (i + 1), canvas.width),
to,
type,
value,
width: canvas.width
Expand Down

0 comments on commit 8e089e8

Please sign in to comment.