* [task#136613 doing 0.6h 4h] add the formatLegend function.

This commit is contained in:
wangzemei
2025-01-17 15:41:51 +08:00
committed by 孙浩
parent 263016e757
commit fa4f48ece7
+17
View File
@@ -11,6 +11,23 @@ window.formatSeriesLabel = function(params)
return params?.value?.toFixed(2);
}
/**
* 格式化图例名称。
* Format the legend name.
*
* @param string name
* @access public
* @return string
*/
window.formatLegend = function(name)
{
const parts = name.split('/');
if(parts.length > 0) name = `{bolder|${parts[0]}}/${parts.slice(1).join(' ')}`;
const reg = /[\u4E00-\u9FA5]/;
const threshold = !reg.test(name) ? 60 : 30;
return name.length > threshold ? name.substr(0, threshold) + '...' : name;
}
/**
* 初始化 $APPEALS 图表数据后的回调函数。
* The callback function after initializing the $APPEALS chart data.