F2.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. namespace pindaofenbu {
  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;
  11. if (chartCatch.toufangfenxiChart === undefined) return;
  12. let key = this.data.select[this.data.select_act].proportionType;
  13. chartCatch.toufangfenxiChart.legend('gender', {
  14. position: 'right'
  15. });
  16. chartCatch.toufangfenxiChart.source(data);
  17. chartCatch.toufangfenxiChart.scale(key, {
  18. tickCount: 3
  19. });
  20. chartCatch.toufangfenxiChart.axis('channelName', {
  21. label: (text: string, index: number, total: number) => {
  22. let names = "";
  23. let li = text.split("")
  24. li.map((v:string,i:number)=>{
  25. names += v;
  26. i != li.length - 1 && i !== 0 && i % 2 === 1 && ( names += '\n')
  27. })
  28. return {
  29. text: names
  30. }
  31. }
  32. });
  33. chartCatch.toufangfenxiChart.axis(key, {
  34. label: (text: string, index: number, total: number) => {
  35. return {
  36. text: formmaterValueZhou(text, 0)
  37. }
  38. }
  39. });
  40. chartCatch.toufangfenxiChart.tooltip({
  41. showCrosshairs: true,
  42. triggerOn: ['touchstart', 'touchmove'],
  43. onShow: (ev: tooltipOnShow) => {
  44. const items = ev.items;
  45. items[0].name = items[0].title;
  46. items[0].value = formmaterValueZhou(items[0].value, 2) + this.data.select[this.data.select_act].unit;
  47. }
  48. });
  49. chartCatch.toufangfenxiChart.interval().position('channelName*' + key).shape('smooth').color(["#1b9ade", "#fd5555"]);
  50. chartCatch.toufangfenxiChart.render();
  51. },
  52. line(F2: any, config: any) {
  53. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  54. let sys = wx.getSystemInfoSync();
  55. config.height = sys.windowWidth / 16 * 9;
  56. chartCatch.toufangfenxiChart = new F2.Chart(config);
  57. const data = this.data.DayList;
  58. if (chartCatch.toufangfenxiChart === undefined) return;
  59. let key = this.data.select[this.data.select_act].proportionType;
  60. chartCatch.toufangfenxiChart.legend('gender', {
  61. position: 'right'
  62. });
  63. chartCatch.toufangfenxiChart.source(data);
  64. chartCatch.toufangfenxiChart.scale(key, {
  65. tickCount: 3
  66. });
  67. chartCatch.toufangfenxiChart.axis('channelName', {
  68. label: (text: string, index: number, total: number) => {
  69. let names = "";
  70. let li = text.split("")
  71. li.map((v:string,i:number)=>{
  72. names += v;
  73. i != li.length - 1 && i !== 0 && i % 2 === 1 && ( names += '\n')
  74. })
  75. return {
  76. text: names
  77. }
  78. }
  79. });
  80. chartCatch.toufangfenxiChart.axis(key, {
  81. label: (text: string, index: number, total: number) => {
  82. return {
  83. text: formmaterValueZhou(text, 0)
  84. }
  85. }
  86. });
  87. chartCatch.toufangfenxiChart.tooltip({
  88. showCrosshairs: true,
  89. triggerOn: ['touchstart', 'touchmove'],
  90. onShow: (ev: tooltipOnShow) => {
  91. const items = ev.items;
  92. items[0].name = items[0].title;
  93. items[0].value = formmaterValueZhou(items[0].value, 2) + this.data.select[this.data.select_act].unit;
  94. }
  95. });
  96. chartCatch.toufangfenxiChart.interval().position('channelName*' + key).shape('smooth').color(["#1b9ade", "#fd5555"]);
  97. chartCatch.toufangfenxiChart.render();
  98. return chartCatch.toufangfenxiChart;
  99. },
  100. clearchart(){
  101. if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined;
  102. }
  103. };
  104. }