Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/figures/chart/scorecard/chart_scorecard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export class ScorecardChart extends Component<Props, SpreadsheetChildEnv> {
getZoomedRect(1 / zoom, canvas.getBoundingClientRect()),
this.runtime
);
drawScoreChart(config, canvas);
drawScoreChart(config, canvas, zoom);
}
}
9 changes: 5 additions & 4 deletions src/helpers/figures/charts/scorecard_chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,17 +383,18 @@ type Canvas2DContext = CanvasRenderingContext2D | OffscreenCanvasRenderingContex

export function drawScoreChart(
structure: ScorecardChartConfig,
canvas: HTMLCanvasElement | OffscreenCanvas
canvas: HTMLCanvasElement | OffscreenCanvas,
zoom: number = 1
) {
const ctx = canvas.getContext("2d") as Canvas2DContext;
if (!ctx) {
throw new Error("Unable to retrieve 2D context from canvas");
}
const dpr = typeof globalThis.devicePixelRatio === "number" ? globalThis.devicePixelRatio : 1;

canvas.width = dpr * structure.canvas.width;
canvas.height = dpr * structure.canvas.height;
ctx.scale(dpr, dpr);
canvas.width = dpr * structure.canvas.width * zoom;
canvas.height = dpr * structure.canvas.height * zoom;
ctx.scale(dpr * zoom, dpr * zoom);
const availableWidth = structure.canvas.width - CHART_PADDING;

ctx.fillStyle = structure.canvas.backgroundColor;
Expand Down