diff --git a/src/QuantitativeSequenceRenderer/QuantitativeSequenceRenderer.ts b/src/QuantitativeSequenceRenderer/QuantitativeSequenceRenderer.ts index 813c948..3208071 100644 --- a/src/QuantitativeSequenceRenderer/QuantitativeSequenceRenderer.ts +++ b/src/QuantitativeSequenceRenderer/QuantitativeSequenceRenderer.ts @@ -34,7 +34,6 @@ export default function rendererFactory(pluginManager: PluginManager) { const scale = getScale(opts) if (region.end - region.start > 5000) { - console.log('using super') super.draw(ctx, props) return } @@ -42,18 +41,27 @@ export default function rendererFactory(pluginManager: PluginManager) { const toY = (n: number) => height - scale(n) + YSCALEBAR_LABEL_OFFSET const toHeight = (n: number) => toY(originY) - toY(n) - console.log({ features }) ctx.textAlign = 'center' + ctx.font = 'bold 10px sans-serif' for (const feature of features.values()) { const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx) const w = rightPx - leftPx + 0.4 // fudge factor for subpixel rendering const score = feature.get('score') as number const base = feature.get('base') ctx.fillStyle = getColor(base) - ctx.fillRect(leftPx, toY(score), w, toHeight(score)) - ctx.fillStyle = '#000' - if (1 / bpPerPx > 5) { - ctx.fillText(base, leftPx + (rightPx - leftPx) / 2, toY(score) - 2) + if (1 / bpPerPx < 5) { + ctx.fillRect(leftPx, toY(score), w, toHeight(score)) + } else { + ctx.setTransform( + w / 10, + 0, + 0, + toHeight(score) / 4, + leftPx * 2 + (rightPx - leftPx), + height + toY(0) / 2 + YSCALEBAR_LABEL_OFFSET, + ) + + ctx.fillText(base, 0, 0) } } diff --git a/yarn.lock b/yarn.lock index 9b34d0b..3aba93b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1292,7 +1292,7 @@ resolved "https://registry.yarnpkg.com/@librpc/ee/-/ee-1.0.4.tgz#ce73a36279dc4cf93efa43f7e3564ec165947522" integrity sha512-vhPlbRwAKQC80h0k74tsOkMKIidZtqlFSOHRzCvC8n7Va9rzMDwpG26Pm84dAt0ZuGK0g1UEfPzxDiYo9ZQBrg== -"@librpc/web@github:rbuels/librpc-web#737bb9706762a52a87169a12c9b59fb241febab0": +"@librpc/web@rbuels/librpc-web#737bb9706762a52a87169a12c9b59fb241febab0": version "1.1.0" resolved "https://codeload.github.com/rbuels/librpc-web/tar.gz/737bb9706762a52a87169a12c9b59fb241febab0" dependencies: