index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 = [{name:"追溯产品",value:999,},{name:"非追溯产品",value:666,},]
  30. var fontSize = 10
  31. var fontColor = "#999999"
  32. return {
  33. color:["#7A4AFF","#FFAE36"],
  34. legend:{
  35. icon:"circle",
  36. itemWidth:fontSize*0.8,
  37. itemHeight:fontSize*0.8,
  38. textStyle:{
  39. fontSize:fontSize*0.9,
  40. color:fontColor,
  41. },
  42. data:list.map(item=>item.name)
  43. },
  44. series:[
  45. {
  46. type: 'pie',
  47. silent:1,
  48. radius:["35%", '75%'],
  49. center: ["50%", '55%'],
  50. label:{
  51. show:true,
  52. formatter:"{c}",
  53. fontSize:10,
  54. position:"inside",
  55. color:'#ffffff',
  56. },
  57. data: list,
  58. },
  59. ]
  60. }
  61. },
  62. },
  63. })