From fa4f48ece7ed59379fca7a08aed15d7d419b9185 Mon Sep 17 00:00:00 2001 From: wangzemei Date: Fri, 17 Jan 2025 14:33:38 +0800 Subject: [PATCH] * [task#136613 doing 0.6h 4h] add the formatLegend function. --- lib/zin/wg/thinkappeals/js/v1.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/zin/wg/thinkappeals/js/v1.js b/lib/zin/wg/thinkappeals/js/v1.js index d514a9f73e..02d403043f 100644 --- a/lib/zin/wg/thinkappeals/js/v1.js +++ b/lib/zin/wg/thinkappeals/js/v1.js @@ -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.