Skip to content

Commit

Permalink
Revert "Render counter widgets using relative font size" (#6566)
Browse files Browse the repository at this point in the history
  • Loading branch information
eradman authored Oct 31, 2023
1 parent ae77e72 commit 8b8dd4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/app/components/dashboards/dashboard-grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
right: 10px;
bottom: 15px;
height: auto;
overflow: hidden;
padding: 0;
}
}
Expand Down
15 changes: 7 additions & 8 deletions viz-lib/src/visualizations/counter/Renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ import "./render.less";

function getCounterStyles(scale: any) {
return {
fontSize: `${scale}pt`,
msTransform: `scale(${scale})`,
MozTransform: `scale(${scale})`,
WebkitTransform: `scale(${scale})`,
transform: `scale(${scale})`,
};
}

function getCounterScale(container: any) {
// size of font in base container
// children use a relative font size (em)
if (container.closest('.visualization-preview') || container.closest('.ant-tabs-tabpane')) {
return "60";
}
const fontSize = 12 + container.clientHeight / 5;
return fontSize > 60 ? "60" : fontSize.toFixed();
const inner = container.firstChild;
const scale = Math.min(container.offsetWidth / inner.offsetWidth, container.offsetHeight / inner.offsetHeight);
return Number(isFinite(scale) ? scale : 1).toFixed(2); // keep only two decimal places
}

export default function Renderer({ data, options, visualizationName }: any) {
Expand Down
5 changes: 3 additions & 2 deletions viz-lib/src/visualizations/counter/render.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
display: block;
text-align: center;
padding: 15px 10px;
position: relative;
overflow: hidden;
position: relative;

.counter-visualization-content {
margin: 0;
padding: 0;
font-size: 2em;
font-size: 80px;
line-height: normal;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
Expand Down

0 comments on commit 8b8dd4f

Please sign in to comment.