* [task#136613 doing 0.6h 4h] add the formatLegend function.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user