F21.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. itemFormatter: function itemFormatter(val: string) {
  24. let p :any= {};
  25. for (let i = 0; i < data.length; i++) {
  26. const v = data[i];
  27. if (v.name === val) {
  28. p = v
  29. break
  30. }
  31. }
  32. return val + ' ' + p.p + "% ";
  33. }
  34. });
  35. chartCatch.toufangfenxiChart.tooltip(false);
  36. chartCatch.toufangfenxiChart.coord('polar', {
  37. transposed: true,
  38. radius: 1
  39. });
  40. chartCatch.toufangfenxiChart.axis(false);
  41. chartCatch.toufangfenxiChart.interval()
  42. .position('type*p')
  43. .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack');
  44. chartCatch.toufangfenxiChart.render();
  45. },
  46. line1(F2: any, config: any) {
  47. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  48. let sys = wx.getSystemInfoSync();
  49. config.height = sys.windowHeight *0.7;
  50. chartCatch.toufangfenxiChart = new F2.Chart(config);
  51. let key = this.data.select[this.data.select_act].proportionType;
  52. let total = 0;
  53. this.data.DayList1.map((v: any) => {
  54. total += Number(v[key] || 0) * 1000
  55. })
  56. total /= 1000;
  57. const data = this.data.DayList1.map((v: any) => {
  58. v.p = Number((Number(v[key] / (total || 1)) * 100).toFixed(2));
  59. return v
  60. });
  61. if (chartCatch.toufangfenxiChart === undefined) return;
  62. chartCatch.toufangfenxiChart.source(data);
  63. chartCatch.toufangfenxiChart.legend({
  64. position: 'bottom',
  65. itemFormatter: function itemFormatter(val: string) {
  66. let p :any= {};
  67. for (let i = 0; i < data.length; i++) {
  68. const v = data[i];
  69. if (v.name === val) {
  70. p = v
  71. break
  72. }
  73. }
  74. return val + ' ' + p.p + "% ";
  75. }
  76. });
  77. chartCatch.toufangfenxiChart.tooltip(false);
  78. chartCatch.toufangfenxiChart.coord('polar', {
  79. transposed: true,
  80. radius: 1
  81. });
  82. chartCatch.toufangfenxiChart.axis(false);
  83. chartCatch.toufangfenxiChart.interval()
  84. .position('type*' + key)
  85. .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack');
  86. chartCatch.toufangfenxiChart.render();
  87. return chartCatch.toufangfenxiChart;
  88. }
  89. };
  90. }