helgasoft commented on issue #18253:
URL: https://github.com/apache/echarts/issues/18253#issuecomment-1426145098

   ok, I finally get it - function also **has to fix/adjust** font-size if user 
submits it numeric as requested by 
[ECharts](https://echarts.apache.org/en/option.html#tooltip.textStyle.fontSize).
   ```
   function getTooltipTextStyle(
       textStyle: TooltipOption['textStyle'],
       renderMode: TooltipRenderMode
   ): {
       nameStyle: TextStyle
       valueStyle: TextStyle
   } {
       const nameFontColor = textStyle.color || '#6e7079';
       const nameFontSize = textStyle.fontSize || '12px';
       const nameFontWeight = textStyle.fontWeight || '400';
       const valueFontColor = textStyle.color || '#464646';
       const valueFontSize = textStyle.fontSize || '14px';
       const valueFontWeight = textStyle.fontWeight || '900';
   
       if (!Number.isNaN(nameFontSize)) 
           nameFontSize += 'px';
       if (!Number.isNaN(valueFontSize)) 
           valueFontSize += 'px';
   
       if (renderMode === 'html') {
           // `textStyle` is probably from user input, should be encoded to 
reduce security risk.
           return {
               // eslint-disable-next-line max-len
               nameStyle:  `font-size:${encodeHTML(nameFontSize +'')}; 
color:${encodeHTML(nameFontColor)}; font-weight:${encodeHTML(nameFontWeight 
+'')}`,
               // eslint-disable-next-line max-len
               valueStyle: `font-size:${encodeHTML(valueFontSize 
+'')};color:${encodeHTML(valueFontColor)};font-weight:${encodeHTML(valueFontWeight
 +'')}`
           }
       }
       return {
           nameStyle: {
            fontSize: nameFontSize,
            fill: nameFontColor,
            fontWeight: nameFontWeight
        },
        valueStyle: {
            fontSize: valueFontSize,
            fill: valueFontColor,
            fontWeight: valueFontWeight
        }
       };
   }
   ```


-- 
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