v1.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * 格式化坐标标签数据。
  3. * Format coordinate label data.
  4. *
  5. * @param object params
  6. * @access public
  7. * @return number
  8. */
  9. window.formatSeriesLabel = function(params)
  10. {
  11. return params?.value?.toFixed(2);
  12. }
  13. /**
  14. * 格式化图例名称。
  15. * Format the legend name.
  16. *
  17. * @param string name
  18. * @access public
  19. * @return string
  20. */
  21. window.formatLegend = function(name)
  22. {
  23. const parts = name.split('/');
  24. const reg = /[\u4E00-\u9FA5]/; // 检查字符串中是否包含汉字
  25. const threshold = !reg.test(name) ? 60 : 30;
  26. if(parts.length > 0) name = `{bolder|${parts[0]}}/${parts.slice(1).join(' ')}`;
  27. return name.length > threshold ? name.substr(0, threshold) + '...' : name;
  28. }
  29. /**
  30. * 初始化 $APPEALS 图表数据后的回调函数。
  31. * The callback function after initializing the $APPEALS chart data.
  32. *
  33. * @access public
  34. * @return void
  35. */
  36. window.initedAppealsChart = function()
  37. {
  38. const chartData = $('.appleals-chart div').data('zui.ECharts');
  39. const dataURL = chartData.chart.getDataURL({pixelRatio: 2});
  40. const img = new Image();
  41. img.onload = function()
  42. {
  43. $('.appleals-chart-content').append(img);
  44. $('.appleals-chart-content img').css({marginTop: '-45px'});
  45. $('.appleals-chart').addClass('hidden');
  46. };
  47. img.src = dataURL;
  48. }