F21.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. namespace hangyejiegou {
  2. const chartCatch: antvChart = {
  3. toufangfenxiChart: undefined
  4. }
  5. module.exports = {
  6. upLine1() {
  7. if (chartCatch.toufangfenxiChart === undefined) return
  8. chartCatch.toufangfenxiChart.clear()
  9. let key = this.data.select[this.data.select_act].proportionType;
  10. let total = 0;
  11. this.data.DayList1.map((v: any) => {
  12. total += Number(v[key] || 0) * 1000
  13. })
  14. total /= 1000;
  15. const data = this.data.DayList1.map((v: any) => {
  16. v.p = Number((Number(v[key] / (total || 1)) * 100).toFixed(2));
  17. return v
  18. });
  19. if (chartCatch.toufangfenxiChart === undefined) return;
  20. chartCatch.toufangfenxiChart.source(data);
  21. chartCatch.toufangfenxiChart.legend({
  22. position: 'bottom',
  23. nameStyle: {
  24. fill: '#404040', // 文本的颜色
  25. fontSize: 12, // 文本大小
  26. textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle
  27. height: 12, // 设置文本的高度
  28. },
  29. itemFormatter: function itemFormatter(val: string) {
  30. let p :any= {};
  31. for (let i = 0; i < data.length; i++) {
  32. const v = data[i];
  33. if (v.name === val) {
  34. p = v
  35. break
  36. }
  37. }
  38. return val + ' ' + p.p + "% ";
  39. }
  40. });
  41. chartCatch.toufangfenxiChart.tooltip(false);
  42. chartCatch.toufangfenxiChart.coord('polar', {
  43. transposed: true,
  44. radius: 1
  45. });
  46. chartCatch.toufangfenxiChart.axis(false);
  47. chartCatch.toufangfenxiChart.interval()
  48. .position('type*p')
  49. .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack');
  50. chartCatch.toufangfenxiChart.render();
  51. },
  52. line1(F2: any, config: any) {
  53. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  54. let sys = wx.getSystemInfoSync();
  55. config.height = sys.windowHeight *0.7;
  56. chartCatch.toufangfenxiChart = new F2.Chart(config);
  57. let key = this.data.select[this.data.select_act].proportionType;
  58. let total = 0;
  59. this.data.DayList1.map((v: any) => {
  60. total += Number(v[key] || 0) * 1000
  61. })
  62. total /= 1000;
  63. const data = this.data.DayList1.map((v: any) => {
  64. v.p = Number((Number(v[key] / (total || 1)) * 100).toFixed(2));
  65. return v
  66. });
  67. if (chartCatch.toufangfenxiChart === undefined) return;
  68. chartCatch.toufangfenxiChart.source(data);
  69. chartCatch.toufangfenxiChart.legend({
  70. position: 'bottom',
  71. nameStyle: {
  72. fill: '#404040', // 文本的颜色
  73. fontSize: 12, // 文本大小
  74. textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle
  75. height: 12, // 设置文本的高度
  76. },
  77. itemFormatter: function itemFormatter(val: string) {
  78. let p :any= {};
  79. for (let i = 0; i < data.length; i++) {
  80. const v = data[i];
  81. if (v.name === val) {
  82. p = v
  83. break
  84. }
  85. }
  86. return val + ' ' + p.p + "% ";
  87. }
  88. });
  89. chartCatch.toufangfenxiChart.tooltip(false);
  90. chartCatch.toufangfenxiChart.coord('polar', {
  91. transposed: true,
  92. radius: 1
  93. });
  94. chartCatch.toufangfenxiChart.axis(false);
  95. chartCatch.toufangfenxiChart.interval()
  96. .position('type*' + key)
  97. .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack');
  98. chartCatch.toufangfenxiChart.render();
  99. return chartCatch.toufangfenxiChart;
  100. },
  101. clearchart1(){
  102. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  103. }
  104. };
  105. }