F2.ts 4.4 KB

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