item.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. // pages/item/item.js
  2. import * as echarts from '../../ec-canvas/echarts';
  3. var timeData = [
  4. '2020/6/1', '2009/6/2', '2009/6/3', '2009/6/4', '2009/6/5', '2009/6/6', '2009/6/7', '2009/6/8', '2009/6/9', '2009/6/10',
  5. ];
  6. timeData = timeData.map(function (str) {
  7. return str.replace('2009/', '');
  8. });
  9. var app = getApp()
  10. function initChart(canvas, width, height, dpr, data) {
  11. const chart = echarts.init(canvas, null, {
  12. width: width,
  13. height: height,
  14. devicePixelRatio: dpr // new
  15. });
  16. canvas.setChart(chart);
  17. var option = {
  18. title: {//标题
  19. text: '',
  20. left: 'center'
  21. },
  22. renderAsImage: true, //支持渲染为图片模式
  23. color: ["#DF3E3E", "#80CDF8"],//图例图标颜色
  24. legend: {
  25. show: true,
  26. itemGap: 25,//每个图例间的间隔
  27. top: 30,
  28. x: 30,//水平安放位置,离容器左侧的距离 'left'
  29. z: 100,
  30. textStyle: {
  31. color: '#383838'
  32. },
  33. },
  34. grid: {//网格
  35. // left: 30,
  36. // top:100,
  37. containLabel: true,//grid 区域是否包含坐标轴的刻度标签
  38. },
  39. xAxis: {//横坐标
  40. type: 'category',
  41. nameTextStyle: {//在name值存在下,设置name的样式
  42. color: 'white',
  43. fontStyle: 'normal'
  44. },
  45. nameLocation:'end',
  46. splitLine: {//坐标轴在 grid 区域中的分隔线。
  47. show: true,
  48. lineStyle: {
  49. type: 'dashed',
  50. color: ['#2B2B2B']
  51. }
  52. },
  53. boundaryGap: false,//1.true 数据点在2个刻度直接 2.fals 数据点在分割线上,即刻度值上
  54. data: timeData,
  55. axisLine: {onZero: true},
  56. axisLabel: {
  57. textStyle: {
  58. fontSize: 13,
  59. color: '#5D5D5D'
  60. }
  61. }
  62. },
  63. dataZoom: [
  64. {
  65. type: 'slider',
  66. xAxisIndex: 0,
  67. filterMode: 'empty'
  68. },
  69. ],
  70. yAxis: {//纵坐标
  71. type: 'value',
  72. position:'right',
  73. nameTextStyle:{//在name值存在下,设置name的样式
  74. color:'red',
  75. fontStyle:'normal'
  76. },
  77. splitNumber: 5,//坐标轴的分割段数
  78. splitLine: {//坐标轴在 grid 区域中的分隔线。
  79. show: true,
  80. lineStyle: {
  81. type: 'dashed',
  82. color: ['#2B2B2B']
  83. }
  84. },
  85. axisLabel: {//坐标轴刻度标签
  86. // formatter: function (value) {
  87. // var xLable = [];
  88. // if (value == 20) {
  89. // xLable.push('25,883');
  90. // }
  91. // if (value == 40) {
  92. // xLable.push('26,035');
  93. // }
  94. // if (value == 60) {
  95. // xLable.push('26,187');
  96. // }
  97. // if (value == 80) {
  98. // xLable.push('26,339');
  99. // }
  100. // return xLable
  101. // },
  102. textStyle: {
  103. fontSize: 13,
  104. color: '#5D5D5D',
  105. }
  106. },
  107. min: 0,
  108. max: 100,
  109. },
  110. series: [{
  111. name: '实际',
  112. type: 'line',
  113. // smooth:true,
  114. data: [18, 36, 65, 30, 78, 40, 33],
  115. symbol: 'none',
  116. areaStyle: {
  117. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  118. offset: 0,
  119. color: '#DF3E3E'
  120. }, {
  121. offset: 1,
  122. color: '#1C1C1C'
  123. }])
  124. },
  125. itemStyle: {
  126. normal: {
  127. lineStyle: {
  128. color: '#DF3E3E'
  129. }
  130. }
  131. }
  132. }, {
  133. name: '预测',
  134. type: 'line',
  135. data: [10, 30, 31, 50, 40, 20, 10],
  136. symbol: 'none',
  137. itemStyle: {
  138. normal: {
  139. lineStyle: {
  140. color: '#80CDF8'
  141. }
  142. }
  143. }
  144. }],
  145. };
  146. chart.setOption(option);
  147. return chart;
  148. }
  149. Page({
  150. /**
  151. * 页面的初始数据
  152. */
  153. data: {
  154. // 页面配置
  155. winWidth: 0,
  156. winHeight: 0,
  157. // tab切换
  158. currentTab: 0,
  159. button:"关注",
  160. ec: {
  161. onInit: initChart
  162. },
  163. chartData:[52,56,355,444,52,56,355,444,52,56,355,444,2],
  164. object:{
  165. title:"appl",
  166. Withtitle:"appl inc",
  167. Volume:"545455",
  168. float:"-5555"
  169. }
  170. },
  171. catchTouchMove:function(res){
  172. return false
  173. },
  174. // 滑动切换tab
  175. bindChange: function(e) {
  176. var that = this;
  177. that.setData({
  178. currentTab: e.detail.current
  179. });
  180. },
  181. // 点击tab切换
  182. swichNav: function(e) {
  183. var that = this;
  184. if (this.data.currentTab === e.target.dataset.current) {
  185. return false;
  186. } else {
  187. that.setData({
  188. currentTab: e.target.dataset.current
  189. })
  190. }
  191. },
  192. /**
  193. * 生命周期函数--监听页面加载
  194. */
  195. onLoad: function (options) {
  196. },
  197. /**
  198. * 生命周期函数--监听页面初次渲染完成
  199. */
  200. onReady: function () {
  201. },
  202. /**
  203. * 生命周期函数--监听页面显示
  204. */
  205. onShow: function () {
  206. },
  207. /**
  208. * 生命周期函数--监听页面隐藏
  209. */
  210. onHide: function () {
  211. },
  212. /**
  213. * 生命周期函数--监听页面卸载
  214. */
  215. onUnload: function () {
  216. },
  217. /**
  218. * 页面相关事件处理函数--监听用户下拉动作
  219. */
  220. onPullDownRefresh: function () {
  221. },
  222. /**
  223. * 页面上拉触底事件的处理函数
  224. */
  225. onReachBottom: function () {
  226. },
  227. /**
  228. * 用户点击右上角分享
  229. */
  230. onShareAppMessage: function () {
  231. }
  232. })