F2.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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: 'left',
  31. nameStyle: {
  32. fill: '#404040', // 文本的颜色
  33. fontSize: 10, // 文本大小
  34. textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle
  35. height: 10, // 设置文本的高度
  36. },
  37. itemFormatter: function itemFormatter(val: string) {
  38. let p: any = {};
  39. for (let i = 0; i < data.length; i++) {
  40. const v = data[i];
  41. if (v.industry === val) {
  42. p = v
  43. break
  44. }
  45. }
  46. return val + '/' + p.p + "% ";
  47. }
  48. });
  49. chartCatch.toufangfenxiChart.axis(false);
  50. chartCatch.toufangfenxiChart.tooltip({
  51. showCrosshairs: false,
  52. triggerOn: ['touchstart', 'touchmove'],
  53. onShow: (ev: tooltipOnShow) => {
  54. const items = ev.items;
  55. const { tooltip: { title } } = ev;
  56. let index = Number(title || 0);
  57. index < 0 ? index = 0 : "";
  58. items[0].value = formmaterValueZhou(items[0].value, 2);
  59. }
  60. });
  61. // chartCatch.toufangfenxiChart.pieLabel({
  62. // sidePadding: 10,
  63. // label1: function label1(label1:any) {
  64. // return {
  65. // text: label1.industry,
  66. // fill: '#666'
  67. // };
  68. // },
  69. // label2: function label2(label1:any) {
  70. // return {
  71. // fill: '#000000',
  72. // text: formmaterValueZhou(label1[key], 2),
  73. // fontWeight: 500,
  74. // fontSize: 10
  75. // };
  76. // }
  77. // });
  78. chartCatch.toufangfenxiChart.interval().position('type*' + key)
  79. .color('industry', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  80. .adjust('stack')
  81. chartCatch.toufangfenxiChart.render();
  82. },
  83. line(F2: any, config: any) {
  84. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  85. let sys = wx.getSystemInfoSync();
  86. config.height = sys.windowWidth * 1.2;
  87. chartCatch.toufangfenxiChart = new F2.Chart(config);
  88. let total = 0;
  89. let key = this.data.select[this.data.select_act].proportionType;
  90. let data = this.data.DayList.map((v: any) => {
  91. v.type = "1";
  92. total += Number(v[key] || 0)
  93. return v
  94. });
  95. data = data.map((v: any) => {
  96. v.p = Number(v[key] / total * 100).toFixed(2)
  97. return v
  98. })
  99. if (chartCatch.toufangfenxiChart === undefined) return;
  100. chartCatch.toufangfenxiChart.source(data);
  101. chartCatch.toufangfenxiChart.coord('polar', {
  102. transposed: true,
  103. innerRadius: 0.4,
  104. radius: 0.75
  105. });
  106. chartCatch.toufangfenxiChart.legend({
  107. position: 'bottom',
  108. align: 'center',
  109. nameStyle: {
  110. fill: '#404040', // 文本的颜色
  111. fontSize: 10, // 文本大小
  112. textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle
  113. height: 10, // 设置文本的高度
  114. },
  115. itemFormatter: function itemFormatter(val: string) {
  116. let p: any = {};
  117. for (let i = 0; i < data.length; i++) {
  118. const v = data[i];
  119. if (v.industry === val) {
  120. p = v
  121. break
  122. }
  123. }
  124. return val + '/' + p.p + "% ";
  125. }
  126. });
  127. chartCatch.toufangfenxiChart.axis(false);
  128. chartCatch.toufangfenxiChart.tooltip({
  129. showCrosshairs: false,
  130. triggerOn: ['touchstart', 'touchmove'],
  131. onShow: (ev: tooltipOnShow) => {
  132. const items = ev.items;
  133. const { tooltip: { title } } = ev;
  134. let index = Number(title || 0);
  135. index < 0 ? index = 0 : "";
  136. items[0].value = formmaterValueZhou(items[0].value, 2);
  137. }
  138. });
  139. // chartCatch.toufangfenxiChart.pieLabel({
  140. // sidePadding: 10,
  141. // label1: function label1(label1:any) {
  142. // return {
  143. // text: label1.industry,
  144. // fill: '#666'
  145. // };
  146. // },
  147. // label2: function label2(label1:any) {
  148. // return {
  149. // fill: '#000000',
  150. // text: formmaterValueZhou(label1[key], 2),
  151. // fontWeight: 500,
  152. // fontSize: 10
  153. // };
  154. // }
  155. // });
  156. chartCatch.toufangfenxiChart.interval().position('type*' + key)
  157. .color('industry', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
  158. .adjust('stack')
  159. chartCatch.toufangfenxiChart.render();
  160. return chartCatch.toufangfenxiChart;
  161. }
  162. };
  163. }