diff --git a/src/notebooks/logic/chartJs.ts b/src/notebooks/logic/chartJs.ts index f486cb1c..5eccc9e9 100644 --- a/src/notebooks/logic/chartJs.ts +++ b/src/notebooks/logic/chartJs.ts @@ -31,7 +31,7 @@ export function generateChartHTMLEmbedded(id: number, detail: ChartDetail, label const hasYaxis = detail.type === `bar` || detail.type === `line`; - const script = /*javascript*/` + const script = /*javascript*/ ` if (!window.ibmicharts) { window.ibmicharts = {}; } @@ -41,6 +41,11 @@ export function generateChartHTMLEmbedded(id: number, detail: ChartDetail, label if (!theChart) { const chartEle = document.getElementById('myChart${id}'); if (chartEle) { + const maxHeight = window.innerHeight * 0.8; + const maxWidth = window.innerWidth * 0.8; + const targetSize = Math.min(maxHeight, maxWidth); + chartEle.style.maxHeight = targetSize + 'px'; + chartEle.style.maxWidth = targetSize + 'px'; try { window.ibmicharts['myChart${id}'] = new Chart(chartEle.getContext('2d'), { type: '${detail.type}',