Skip to content

Commit

Permalink
fix: add highcharts wrapper div with explicit height and width to ens…
Browse files Browse the repository at this point in the history
…ure chart fills the canvas
  • Loading branch information
HendrikThePendric committed Nov 7, 2024
1 parent 0988585 commit b635a2d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/VisualizationPlugin/ChartPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const ChartPlugin = ({
animation: defaultAnimation,
onToggleContextualMenu,
}) => {
const wrapperRef = useRef(null)
const canvasRef = useRef(undefined)
const prevStyle = useRef(style)
const prevRenderCounter = useRef(renderCounter)
Expand Down Expand Up @@ -74,7 +75,21 @@ const ChartPlugin = ({
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [style])

return <div ref={canvasRef} style={style} />
return (
<div ref={wrapperRef} style={style}>
<div
ref={canvasRef}
style={{
width: wrapperRef.current
? wrapperRef.current.offsetWidth
: style.width,
height: wrapperRef.current
? wrapperRef.current.offsetHeight
: style.height,
}}
/>
</div>
)
}

ChartPlugin.defaultProps = {
Expand Down

0 comments on commit b635a2d

Please sign in to comment.