Skip to content

Commit

Permalink
Fix legend font initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
neesjanvaneck committed Mar 16, 2024
1 parent 11a4309 commit 4237aa6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/components/ui/ClusterColorLegend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ const ClusterColorLegend = observer(({ showTopClustersOnly, canvasWidth, legendW
const visualizationStore = useContext(VisualizationStoreContext);
const canvasEl = useRef(null);
const [ctx, setCtx] = useState(null);
const [font, setFont] = useState('Roboto');
const [font, setFont] = useState(customFont);
const [mouseCoord, setMouseCoord] = useState([]);

useEffect(() => {
setFont(customFont || 'Roboto');
if (document.fonts) {
document.fonts.ready.then(() => {
setFont(customFont || 'Roboto');
});
} else {
setTimeout(() => {
setFont(customFont || 'Roboto');
}, 250);
}
setCtx(canvasEl.current.getContext('2d'));
visualizationStore.setGetClusterLegendCanvasImage(() => canvasEl.current);
select(canvasEl.current)
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/ScoreColorLegend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ScoreColorLegend = observer(({
const visualizationStore = useContext(VisualizationStoreContext);
const canvasEl = useRef(null);
const [ctx, setCtx] = useState(null);
const [font, setFont] = useState('Roboto');
const [font, setFont] = useState(customFont);

useEffect(() => {
if (document.fonts) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/SizeLegend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const SizeLegend = observer(({ canvasWidth, canvasHeight, customFont }) => {
const visualizationStore = useContext(VisualizationStoreContext);
const canvasEl = useRef(null);
const [ctx, setCtx] = useState(null);
const [font, setFont] = useState('Roboto');
const [font, setFont] = useState(customFont);
const [ticks, setTicks] = useState([]);

useEffect(() => {
Expand Down

0 comments on commit 4237aa6

Please sign in to comment.