Skip to content

Commit

Permalink
Counter not properly scaled in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko committed Aug 30, 2019
1 parent 9e1fc01 commit b54b23c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/app/visualizations/counter/Renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ export default function Renderer({ data, options, visualizationName }) {

useEffect(() => {
if (container) {
setScale(getCounterScale(container)); // initial update
const unwatch = resizeObserver(container, () => {
setScale(getCounterScale(container));
});
return unwatch;
}
}, [container, setScale]);

useEffect(() => {
if (container) {
// update scaling when options or data change (new formatting, values, etc.
// may change inner container dimensions which will not be tracked by `resizeObserver`);
setScale(getCounterScale(container));
}
}, [data, options, container, setScale]);

const {
showTrend, trendPositive,
counterValue, counterValueTooltip,
Expand Down

0 comments on commit b54b23c

Please sign in to comment.