ventutil.ts 1010 B

123456789101112131415161718192021222324252627282930313233343536
  1. export function toEchartsData(list, option) {
  2. option.legend['data'] = [];
  3. option.yAxis.length = list.length;
  4. option.yAxis.series = list.length;
  5. list.forEach((item: any, index) => {
  6. option.legend['data'].push(`${item['legend']}(${item['unit']})`);
  7. const yAxiObj = {
  8. type: 'value',
  9. position: item['yaxispos'],
  10. axisLabel: { formatter: `{value} ${item['unit']}` },
  11. };
  12. const serieObj = {
  13. name: `${item['legend']}(${item['unit']})`,
  14. type: item['linetype'],
  15. yAxisIndex: item['sort'],
  16. };
  17. if (!option.yAxis[index]) {
  18. option.yAxis[index] = yAxiObj;
  19. } else {
  20. Object.assign(option.yAxis[index], yAxiObj);
  21. }
  22. if (!option.series[index]) {
  23. option.series[index] = serieObj;
  24. } else {
  25. Object.assign(option.series[index], serieObj);
  26. }
  27. });
  28. return option;
  29. }
  30. export function formatNum(data) {
  31. return new Intl.NumberFormat('ja-JP', {
  32. minimumFractionDigits: 2,
  33. maximumFractionDigits: 2,
  34. }).format(data);
  35. }