index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const app = getApp();
  2. import * as echarts from '../../../../ec-canvas/echarts' // 这个是自己实际的目录
  3. Component({
  4. data:{
  5. Ec: { lazyLoad: true, },
  6. },
  7. lifetimes: {
  8. attached: function () {
  9. this.init()
  10. },
  11. moved: function () { },
  12. detached: function () { },
  13. },
  14. methods:{
  15. init(){
  16. var that = this;
  17. that.selectComponent('#chartConDom').init((canvas, width, height, dpr) => {
  18. const chart = echarts.init(canvas, null, {
  19. width: width,
  20. height: height,
  21. devicePixelRatio: dpr
  22. });
  23. var option = that.getOrderWarnOption();
  24. chart.setOption(option);
  25. return chart;
  26. });
  27. },
  28. getOrderWarnOption(){
  29. var list = [
  30. {name:"生产",data:[{name:"2022",value:30,},{name:"2021",value:30,},{name:"2020",value:20,},{name:"2019",value:30,}]},
  31. {name:"销售",data:[{name:"2022",value:50,},{name:"2021",value:30,},{name:"2020",value:30,},{name:"2019",value:30,}]},
  32. {name:"在途",data:[{name:"2022",value:50,},{name:"2021",value:30,},{name:"2020",value:30,},{name:"2019",value:30,}]},
  33. {name:"交付",data:[{name:"2022",value:50,},{name:"2021",value:30,},{name:"2020",value:30,},{name:"2019",value:30,}]},
  34. ]
  35. var fontSize = 10
  36. var fontColor = "#999999"
  37. return {
  38. color:["#583DC8","#D1B645","#31CE7B","#5B7DEB"],
  39. title:{
  40. text:"产品年报数据",
  41. show:false,
  42. textStyle:{
  43. color:fontColor,
  44. fontSize:fontSize,
  45. },
  46. left:'10%',
  47. top:0,
  48. },
  49. grid: {
  50. top: '10%',
  51. left: '6%',
  52. right: '10%',
  53. bottom: '3%',
  54. containLabel: true
  55. },
  56. tooltip: {
  57. trigger: 'axis',
  58. axisPointer: {
  59. type: 'cross',
  60. }
  61. },
  62. legend:{
  63. show:0,
  64. icon:"circle",
  65. right:'10%',
  66. top:0,
  67. itemWidth:fontSize*0.8,
  68. itemHeight:fontSize*0.8,
  69. textStyle:{
  70. fontSize:fontSize,
  71. color:fontColor,
  72. },
  73. data:list.map(item=>item.name)
  74. },
  75. yAxis: {
  76. type: 'value',
  77. axisTick:{show:false,},
  78. axisLabel:{
  79. fontSize:fontSize,
  80. color:fontColor,
  81. },
  82. },
  83. xAxis: {
  84. type: 'category',
  85. boundaryGap: false,
  86. axisTick:{show:false,},
  87. axisLabel:{
  88. fontSize:fontSize,
  89. color:fontColor,
  90. },
  91. data: list[0].data.map(item=>item.name)
  92. },
  93. series:this.setOptItem(list),
  94. }
  95. },
  96. setOptItem(list){
  97. var data = []
  98. for(var i in list){
  99. data.push({
  100. type: 'line',
  101. stack: 'Total',
  102. areaStyle: {},
  103. lineStyle: { width:1,},
  104. silent:1,
  105. symbolSize:1,
  106. name:list[i].name,
  107. data:list[i].data
  108. })
  109. }
  110. return data
  111. },
  112. },
  113. })