You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "helgasoft (via GitHub)" <gi...@apache.org> on 2023/02/10 17:53:00 UTC
[GitHub] [echarts] helgasoft commented on issue #18253: [Feature] relative length units in the tooltip
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: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org