F2.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. namespace hangyezhanbi {
  2. let { formmaterValueZhou } = require("../../../../utils/util")
  3. const chartCatch: antvChart = {
  4. toufangfenxiChart: undefined
  5. }
  6. module.exports = {
  7. upLine() {
  8. if (chartCatch.toufangfenxiChart === undefined) return
  9. chartCatch.toufangfenxiChart.clear()
  10. let total = 0;
  11. let key = this.data.select[this.data.select_act].proportionType;
  12. let data = this.data.DayList.map((v:any)=>{
  13. v.type = "1";
  14. total += Number(v[key] || 0)
  15. return v
  16. });
  17. data = data.map((v:any)=>{
  18. v.p = Number(v[key]/total*100).toFixed(2)
  19. return v
  20. })
  21. if (chartCatch.toufangfenxiChart === undefined) return;
  22. chartCatch.toufangfenxiChart.source(data);
  23. chartCatch.toufangfenxiChart.coord('polar', {
  24. transposed: true,
  25. innerRadius: 0.4,
  26. radius: 0.75
  27. });
  28. chartCatch.toufangfenxiChart.legend({
  29. position: 'bottom',
  30. align: 'center',
  31. itemFormatter: function itemFormatter(val: string) {
  32. let p :any= {};
  33. for (let i = 0; i < data.length; i++) {
  34. const v = data[i];
  35. if (v.industry === val) {
  36. p = v
  37. break
  38. }
  39. }
  40. return val + ' ' + p.p + "% ";
  41. }
  42. });
  43. chartCatch.toufangfenxiChart.axis(false);
  44. chartCatch.toufangfenxiChart.tooltip({
  45. showCrosshairs: false,
  46. triggerOn: ['touchstart', 'touchmove'],
  47. onShow: (ev: tooltipOnShow) => {
  48. const items = ev.items;
  49. const { tooltip: { title } } = ev;
  50. let index = Number(title || 0);
  51. index < 0 ? index = 0 : "";
  52. items[0].value = formmaterValueZhou(items[0].value, 2);
  53. }
  54. });
  55. // chartCatch.toufangfenxiChart.pieLabel({
  56. // sidePadding: 10,
  57. // label1: function label1(label1:any) {
  58. // return {
  59. // text: label1.industry,
  60. // fill: '#666'
  61. // };
  62. // },
  63. // label2: function label2(label1:any) {
  64. // return {
  65. // fill: '#000000',
  66. // text: formmaterValueZhou(label1[key], 2),
  67. // fontWeight: 500,
  68. // fontSize: 10
  69. // };
  70. // }
  71. // });
  72. chartCatch.toufangfenxiChart.interval().position('type*' + key)
  73. .color('industry', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  74. .adjust('stack')
  75. chartCatch.toufangfenxiChart.render();
  76. },
  77. line(F2: any, config: any) {
  78. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  79. let sys = wx.getSystemInfoSync();
  80. config.height = sys.windowWidth * 1.2;
  81. chartCatch.toufangfenxiChart = new F2.Chart(config);
  82. let total = 0;
  83. let key = this.data.select[this.data.select_act].proportionType;
  84. let data = this.data.DayList.map((v:any)=>{
  85. v.type = "1";
  86. total += Number(v[key] || 0)
  87. return v
  88. });
  89. data = data.map((v:any)=>{
  90. v.p = Number(v[key]/total*100).toFixed(2)
  91. return v
  92. })
  93. if (chartCatch.toufangfenxiChart === undefined) return;
  94. chartCatch.toufangfenxiChart.source(data);
  95. chartCatch.toufangfenxiChart.coord('polar', {
  96. transposed: true,
  97. innerRadius: 0.4,
  98. radius: 0.75
  99. });
  100. chartCatch.toufangfenxiChart.legend({
  101. position: 'bottom',
  102. align: 'center',
  103. itemFormatter: function itemFormatter(val: string) {
  104. let p :any= {};
  105. for (let i = 0; i < data.length; i++) {
  106. const v = data[i];
  107. if (v.industry === val) {
  108. p = v
  109. break
  110. }
  111. }
  112. return val + ' ' + p.p + "% ";
  113. }
  114. });
  115. chartCatch.toufangfenxiChart.axis(false);
  116. chartCatch.toufangfenxiChart.tooltip({
  117. showCrosshairs: false,
  118. triggerOn: ['touchstart', 'touchmove'],
  119. onShow: (ev: tooltipOnShow) => {
  120. const items = ev.items;
  121. const { tooltip: { title } } = ev;
  122. let index = Number(title || 0);
  123. index < 0 ? index = 0 : "";
  124. items[0].value = formmaterValueZhou(items[0].value, 2);
  125. }
  126. });
  127. // chartCatch.toufangfenxiChart.pieLabel({
  128. // sidePadding: 10,
  129. // label1: function label1(label1:any) {
  130. // return {
  131. // text: label1.industry,
  132. // fill: '#666'
  133. // };
  134. // },
  135. // label2: function label2(label1:any) {
  136. // return {
  137. // fill: '#000000',
  138. // text: formmaterValueZhou(label1[key], 2),
  139. // fontWeight: 500,
  140. // fontSize: 10
  141. // };
  142. // }
  143. // });
  144. chartCatch.toufangfenxiChart.interval().position('type*' + key)
  145. .color('industry', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  146. .adjust('stack')
  147. chartCatch.toufangfenxiChart.render();
  148. return chartCatch.toufangfenxiChart;
  149. }
  150. };
  151. }