You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.js 3.8 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /** Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. * =============================================================
  15. */
  16. import { round } from 'lodash';
  17. // 公共默认配置
  18. export const defaultOption = {
  19. // x轴
  20. xAxis: {
  21. type: 'category',
  22. boundaryGap: false,
  23. },
  24. // y轴
  25. yAxis: {
  26. splitLine: {
  27. show: false,
  28. },
  29. min(value) {
  30. // 如果图中没有值,y轴最小值默认设为 0
  31. if (value.min === Infinity) {
  32. return 0;
  33. }
  34. // y轴最小值不小于 0; y轴最小值与数据最小值的距离不大于 10,且不大于数据最大值与 100 之间的距离
  35. return round(Math.max(value.min - Math.min(100 - value.max, 10), 0), 2);
  36. },
  37. max(value) {
  38. // 如果图中没有值,y轴最大值默认设为 100
  39. if (value.max === -Infinity) {
  40. return 100;
  41. }
  42. // y轴最大值不大于 100; y轴最大值与数据最大值的距离不大于 10,且不大于数据最小值与 0 之间的距离
  43. return round(Math.min(value.max + Math.min(value.min, 10), 100), 2);
  44. },
  45. },
  46. grid: {
  47. right: '5%',
  48. },
  49. // 图例,涉及多节点展示
  50. legend: {
  51. show: true,
  52. width: 400,
  53. data: [],
  54. },
  55. series: {
  56. type: 'line',
  57. data: [],
  58. },
  59. tooltip: {
  60. trigger: 'axis',
  61. backgroundColor: 'rgba(245, 245, 245, 0.8)',
  62. borderWidth: 1,
  63. borderColor: '#ccc',
  64. textStyle: {
  65. color: '#000',
  66. },
  67. formatter(params) {
  68. const toolTips = params.map(({ seriesName, value }) => {
  69. return `${seriesName}: <strong>${value === undefined ? '-' : value}</strong>`;
  70. });
  71. return toolTips.join('<br />');
  72. },
  73. },
  74. toolbox: {
  75. right: 30,
  76. feature: {
  77. dataZoom: {
  78. yAxisIndex: 'none',
  79. },
  80. restore: {},
  81. },
  82. },
  83. dataZoom: [
  84. {
  85. start: 0,
  86. },
  87. {
  88. type: 'inside',
  89. },
  90. ],
  91. };
  92. export const cpuOption = {
  93. title: {
  94. text: 'CPU',
  95. },
  96. // y轴
  97. yAxis: {
  98. name: 'CPU 占用率(%)',
  99. },
  100. };
  101. export const memOption = {
  102. title: {
  103. text: '内存',
  104. },
  105. // y轴
  106. yAxis: {
  107. name: '内存使用量(Gi)',
  108. min(value) {
  109. if (value.min === Infinity) {
  110. return 0;
  111. }
  112. // 内存 y轴最小值不小于 0; y轴最小值与数据最小值的距离不大于 1。内存理论上不设置内存上限
  113. return round(Math.max(value.min - 1, 0), 2);
  114. },
  115. max(value) {
  116. // 内存无数据时默认设置 y 轴上限为 8
  117. if (value.max === -Infinity) {
  118. return 8;
  119. }
  120. // 内存 y轴最大值与数据最大值的距离不大于 1,且不大于数据最小值与 0 之间的距离; 理论上不设置上限
  121. return round(value.max + Math.min(1, value.min), 2);
  122. },
  123. },
  124. };
  125. export const gpuOption = {
  126. title: {
  127. text: 'GPU',
  128. },
  129. // y轴
  130. yAxis: {
  131. name: 'GPU 占用率(%)',
  132. },
  133. tooltip: {
  134. formatter(params) {
  135. const toolTips = params.map(({ seriesName, value }) => {
  136. const [podName, accId] = seriesName.split(': ');
  137. return `${podName}: <br />${accId}: <strong>${value === undefined ? '-' : value}</strong>`;
  138. });
  139. return toolTips.join('<br />');
  140. },
  141. },
  142. };

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能

Contributors (1)