rise.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import * as echarts from '../../ec-canvas/echarts';
  2. var app = getApp()
  3. function initChart(canvas, width, height, dpr, data) {
  4. const chart = echarts.init(canvas, null, {
  5. width: width,
  6. height: height,
  7. devicePixelRatio: dpr // new
  8. });
  9. canvas.setChart(chart);
  10. console.log(dpr)
  11. console.log(data)
  12. var option = {
  13. xAxis : {
  14. type : 'category',
  15. splitNumber: 2,
  16. scale: true,
  17. show:false,
  18. splitLine:{
  19.     show:false
  20.   }
  21. },
  22. yAxis : {
  23. type : 'value',
  24. splitNumber: 2,
  25. scale: true,
  26. show:false,
  27. splitLine:{
  28.     show:false
  29.    }
  30. },
  31. series: [{
  32. type: 'line',
  33. smooth: true,
  34. data:data,
  35. areaStyle: {},
  36. }]
  37. };
  38. chart.setOption(option);
  39. return chart;
  40. }
  41. Page({
  42. data: {
  43. // 页面配置
  44. winWidth: 0,
  45. winHeight: 0,
  46. // tab切换
  47. currentTab: 0,
  48. ec: {
  49. onInit: initChart
  50. },
  51. array:[
  52. {
  53. title:'AppL',
  54. subtitle:"APPL INC",
  55. Increase:"1.22",
  56. digital:"33",
  57. data:[52,56,355,444]
  58. },
  59. {
  60. title:'AppL',
  61. subtitle:"APPL INC",
  62. Increase:"1.22",
  63. digital:"33",
  64. data:[52,56,355,444]
  65. },
  66. {
  67. title:'AppL',
  68. subtitle:"APPL INC",
  69. Increase:"1.22",
  70. digital:"33",
  71. data:[52,56,355,44554]
  72. }
  73. ],
  74. },
  75. onLoad: function() {
  76. var that = this;
  77. // 获取系统信息
  78. wx.getSystemInfo({
  79. success: function(res) {
  80. that.setData({
  81. winWidth: res.windowWidth,
  82. winHeight: res.windowHeight
  83. });
  84. }
  85. });
  86. },
  87. // 滑动切换tab
  88. bindChange: function(e) {
  89. var that = this;
  90. that.setData({
  91. currentTab: e.detail.current
  92. });
  93. },
  94. // 点击tab切换
  95. swichNav: function(e) {
  96. var that = this;
  97. if (this.data.currentTab === e.target.dataset.current) {
  98. return false;
  99. } else {
  100. that.setData({
  101. currentTab: e.target.dataset.current
  102. })
  103. }
  104. }
  105. })