Skip to content

Commit e0e0c6d

Browse files
author
Tom Sharp
committed
Reduce default chart size to 80% of available screen
Reduce chart size to be 80% of the available height or width, whichever is smaller
1 parent cc019bb commit e0e0c6d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/notebooks/logic/chartJs.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export function generateChartHTMLEmbedded(id: number, detail: ChartDetail, label
4141
if (!theChart) {
4242
const chartEle = document.getElementById('myChart${id}');
4343
if (chartEle) {
44+
const maxHeight = window.innerHeight * 0.8;
45+
const maxWidth = window.innerWidth * 0.8;
46+
const targetSize = Math.min(maxHeight, maxWidth);
47+
chartEle.style.maxHeight = `${targetSize}px`;
48+
chartEle.style.maxWidth = `${targetSize}px`;
4449
try {
4550
window.ibmicharts['myChart${id}'] = new Chart(chartEle.getContext('2d'), {
4651
type: '${detail.type}',

0 commit comments

Comments
 (0)