小程序
小游戏
企业微信
微信支付
扫描小程序码分享
5 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
import * as echarts from '../../components/ec-canvas/echarts' let chart = null Page({ data: { studentdata: { lazyLoad: true }, //折线图 subject: '', term: [], point: [] }, onLoad: function () { this.echartsComponnet = this.selectComponent('#mathtest'); this.getData(); //获取数据 }, getData: function () { this.setData({ subject: '数学', term: [1, 2, 3, 4, 5, 6, ], point: [123, 125, 145, 136, 124, 142] }), this.initChart() }, initChart: function () { this.echartsComponnet.init((canvas, width, height) => { const Chart = echarts.init(canvas, null, { width: width, height: height }) Chart.setOption(this.getOption()) return Chart }) }, getOption: function () { return { title: { left:'center', show:true, text:'数学' //this.data.subject, }, xAxis: { name:'学期', data: this.data.term }, yAxis: { name:'分数', type: 'value' }, series: [{ data: this.data.point, type: 'line' }] } } })
同样的配置网页上试试能不能显示
改成数组试试
来个代码片段
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
import * as echarts from '../../components/ec-canvas/echarts' let chart = null Page({ data: { studentdata: { lazyLoad: true }, //折线图 subject: '', term: [], point: [] }, onLoad: function () { this.echartsComponnet = this.selectComponent('#mathtest'); this.getData(); //获取数据 }, getData: function () { this.setData({ subject: '数学', term: [1, 2, 3, 4, 5, 6, ], point: [123, 125, 145, 136, 124, 142] }), this.initChart() }, initChart: function () { this.echartsComponnet.init((canvas, width, height) => { const Chart = echarts.init(canvas, null, { width: width, height: height }) Chart.setOption(this.getOption()) return Chart }) }, getOption: function () { return { title: { left:'center', show:true, text:'数学' //this.data.subject, }, xAxis: { name:'学期', data: this.data.term }, yAxis: { name:'分数', type: 'value' }, series: [{ data: this.data.point, type: 'line' }] } } })
同样的配置网页上试试能不能显示
改成数组试试
来个代码片段