releasestatisticblock.html.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /**
  3. * The releasestatistic block view file of block module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Yuting Wang <wangyuting@easycorp.ltd>
  7. * @package block
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. $annualMaxReleases = !empty($releases) ? max($releases) : 0;
  12. $releaseProgressData = array();
  13. $spanWidth = (strlen((string)($annualMaxReleases)) * 0.425 + 0.125) . 'rem';
  14. $i = 1;
  15. foreach($releases as $productName => $releaseCount)
  16. {
  17. $progress = ($annualMaxReleases ? ($releaseCount / $annualMaxReleases * 100) : 0) . '%';
  18. $nameClass = '';
  19. $labelClass = 'primary';
  20. if($i == 1) $labelClass = $nameClass = 'danger';
  21. if($i == 2 || $i == 3) $labelClass = $nameClass = 'warning';
  22. $releaseProgressData[] = div
  23. (
  24. set::className('flex justify-between'),
  25. cell
  26. (
  27. set::width('calc(30% - 0.5rem)'),
  28. set::className('clip py-1.5'),
  29. label
  30. (
  31. set::className($labelClass . '-pale px-1.5 circle'),
  32. $i
  33. ),
  34. span
  35. (
  36. set::className('pl-2 text-' . $nameClass),
  37. set::title($productName),
  38. $productName
  39. )
  40. ),
  41. cell
  42. (
  43. set::width('70%'),
  44. setClass('flex items-center py-1.5 border-l'),
  45. div
  46. (
  47. width("calc(calc(100% - {$spanWidth}) * " . ($annualMaxReleases ? $releaseCount / $annualMaxReleases : 0) . ')'),
  48. setClass('progress progress-bar h-3'),
  49. set('role', 'progressbar'),
  50. setStyle(array('background' => 'var(--color-primary-300)'))
  51. ),
  52. span
  53. (
  54. setClass('pl-0.5'),
  55. $releaseCount
  56. )
  57. )
  58. );
  59. $i ++;
  60. }
  61. blockPanel
  62. (
  63. to::titleSuffix
  64. (
  65. icon
  66. (
  67. setClass('text-light text-sm cursor-pointer'),
  68. toggle::tooltip
  69. (
  70. array
  71. (
  72. 'title' => sprintf($lang->block->tooltips['metricTime'], $metricTime),
  73. 'placement' => 'bottom',
  74. 'type' => 'white',
  75. 'className' => 'text-dark border border-light leading-5'
  76. )
  77. ),
  78. 'help'
  79. )
  80. ),
  81. div
  82. (
  83. set::className('flex flex-wrap justify-between'),
  84. cell
  85. (
  86. set::width($longBlock ? '49%' : '100%'),
  87. set::className($longBlock ? '' : 'pb-2'),
  88. div
  89. (
  90. set::className('px-2 pb-2'),
  91. $lang->block->releasestatistic->monthly
  92. ),
  93. echarts
  94. (
  95. set::color(array('#2B80FF')),
  96. set::width('100%'),
  97. set::height($longBlock ? 200 : 175),
  98. set::grid(array('left' => '10px', 'top' => '30px', 'right' => '0', 'bottom' => '0', 'containLabel' => true)),
  99. set::xAxis(array('type' => 'category', 'data' => array_keys($releaseData), 'axisTick' => array('alignWithLabel' => true))),
  100. set::yAxis(array('type' => 'value', 'name' => $app->getClientLang() == 'en' ? $lang->release->common : $lang->number, 'splitLine' => array('show' => false), 'axisLine' => array('show' => true, 'color' => '#DDD'))),
  101. set::series
  102. (
  103. array
  104. (
  105. array
  106. (
  107. 'type' => 'line',
  108. 'name' => $lang->product->releases,
  109. 'data' => array_values($releaseData),
  110. 'emphasis' => array('label' => array('show' => true))
  111. )
  112. )
  113. )
  114. )
  115. ),
  116. cell
  117. (
  118. set::width($longBlock ? '49%' : '100%'),
  119. div
  120. (
  121. set::className('px-2 pb-2'),
  122. icon('chart-bar pr-1'),
  123. sprintf($lang->block->releasestatistic->annual, date('Y'))
  124. ),
  125. div
  126. (
  127. set::className('p-2 overflow-y-auto'),
  128. setStyle('height', $longBlock ? '200px' : '175px'),
  129. $releaseProgressData
  130. )
  131. )
  132. )
  133. );
  134. render();