rusackas commented on code in PR #43189:
URL: https://github.com/apache/superset/pull/43189#discussion_r4129119176


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -68,7 +68,7 @@ const LEGEND_MARGIN_GUTTER = 45;
 // ECharts does not expose pre-render measurements for plain legends, so these
 // values intentionally overestimate selector space to avoid clipping.
 const ESTIMATED_LEGEND_SELECTOR_WIDTH = 112;
-const LEGEND_TEXT_WIDTH_CACHE = new Map<string, number>();
+const TEXT_WIDTH_CACHE = new Map<string, number>();
 

Review Comment:
   Fixed with an LRU cap at 2000 entries, confirmed in the diff and covered by 
the new eviction test in series.test.ts.



##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -94,9 +94,9 @@ function getLegendLabel(item: LegendDataItem): string {
   return String(item.name);
 }
 
-function measureLegendTextWidth(text: string, theme: SupersetTheme): number {
+export function measureTextWidth(text: string, theme: SupersetTheme): number {
   const cacheKey = `${theme.fontFamily}:${theme.fontSizeSM}:${text}`;
-  const cachedWidth = LEGEND_TEXT_WIDTH_CACHE.get(cacheKey);
+  const cachedWidth = TEXT_WIDTH_CACHE.get(cacheKey);
   if (cachedWidth !== undefined) {
     return cachedWidth;
   }

Review Comment:
   Fixed with an LRU cap at 2000 entries, confirmed in the diff and covered by 
the new eviction test in series.test.ts.



##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -112,7 +112,7 @@ function measureLegendTextWidth(text: string, theme: 
SupersetTheme): number {
     }
   }
 
-  LEGEND_TEXT_WIDTH_CACHE.set(cacheKey, width);
+  TEXT_WIDTH_CACHE.set(cacheKey, width);

Review Comment:
   Fixed with an LRU cap at 2000 entries, confirmed in the diff and covered by 
the new eviction test in series.test.ts.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to