Skip to content

Commit

Permalink
Improve some dotplot rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 12, 2023
1 parent 932ee42 commit dde351d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions plugins/dotplot-view/src/DotplotRenderer/DotplotRenderer.ts
Expand Up @@ -181,7 +181,7 @@ export default class DotplotRenderer extends ComparativeRenderer {
width: vview.width,
}
const t = createJBrowseTheme(theme)
hview.features?.forEach(feature => {
for (const feature of hview.features || []) {
const strand = feature.get('strand') || 1
const start = strand === 1 ? feature.get('start') : feature.get('end')
const end = strand === 1 ? feature.get('end') : feature.get('start')
Expand Down Expand Up @@ -240,6 +240,8 @@ export default class DotplotRenderer extends ComparativeRenderer {
ctx.beginPath()
ctx.moveTo(currX, height - currY)

let lastDrawnX = currX
let lastDrawnY = currX
for (let i = 0; i < cigarOps.length; i += 2) {
const val = +cigarOps[i]
const op = cigarOps[i + 1]
Expand All @@ -253,7 +255,16 @@ export default class DotplotRenderer extends ComparativeRenderer {
}
currX = clampWithWarnX(currX, b1, b2, feature)
currY = clampWithWarnY(currY, e1, e2, feature)
ctx.lineTo(currX, height - currY)

// only draw a line segment if it is bigger than 0.5px
if (
Math.abs(currX - lastDrawnX) > 0.5 ||
Math.abs(currY - lastDrawnY) > 0.5
) {
ctx.lineTo(currX, height - currY)
lastDrawnX = currX
lastDrawnY = currY
}
}

ctx.stroke()
Expand All @@ -279,7 +290,7 @@ export default class DotplotRenderer extends ComparativeRenderer {
}
}
}
})
}

return { warnings }
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

0 comments on commit dde351d

Please sign in to comment.