东东东东
东东东东
  • 发布:2020-10-29 17:03
  • 更新:2020-12-21 16:42
  • 阅读:923

renderjs引入echarts,函数失效

分类:uni-app

let option = {
color: colors,
legend: {
data: ['+2SD', '+1SD', '均值', '-1SD', '-2SD', '实测', '遗传'],
icon: 'roundRect',
bottom: 0,
itemWidth: 20,
itemGap: 15,
selected: {
'+2SD': false,
'+1SD': true,
'实测': true,
'-1SD': true,
'-2SD': false,
'遗传': true,
'均值': false
}
},

                grid: {  
                    top: "9%",  
                    left: "8%",  
                    right: "1%",  
                    bottom  
                },  
                parallel: {  
                    bottom: '22%'  
                },  

                xAxis:  

                {  
                    type: 'category',  
                    boundaryGap: false,  
                    axisLine: {  
                        onZero: false,  
                    },  
                    axisLabel: {  
                        textStyle: {  
                            fontSize: 11,  
                            color: '#4b4b4b'  
                        }  
                    },  
                    // type: 'category',  
                    data: now.xaxis  
                },  

                yAxis: [{  
                    max: function(value) {  
                        return parseInt(value.max) + 8;  
                    },  
                    min: function(value) {  
                        return parseInt(value.min) - 22;  
                    },  
                    type: 'value',  
                    name: 'CM',  
                    axisLabel: {  
                        textStyle: {  
                            fontSize: 11,  
                            color: '#4b4b4b'  
                        }  
                    },  
                    nameTextStyle: {  
                        padding: [0, 35, 0, 0],  
                        color: '#4b4b4b',  
                        fontSize: 11  
                    },  
                    splitLine: {  
                        lineStyle: {  
                            color: ['rgba(204,204,204,0.4)'],  
                            type: 'dotted'  
                        }  
                    }  
                }],  
                series: [  
                    // data: res.data.data.series_data  
                    {  
                        name: '实测',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.height,  
                        symbolSize: '5',  
                        lineStyle: {  
                            normal: {  
                                width: 4  
                                // shadowColor: 'rgba(0,0,0,0.34)',  
                                // shadowBlur: 3,  
                                // shadowOffsetY: 3  
                            }  
                        }  
                    }, {  
                        name: '遗传',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.heightInherit,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }, {  
                        name: '+2SD',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.positive2sd,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }, {  
                        name: '+1SD',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data:now.series_data.positive1sd,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }, {  
                        name: '均值',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.median,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }, {  
                        name: '-1SD',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.negative1sd,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }, {  
                        name: '-2SD',  
                        type: 'line',  
                        smooth: true,  
                        connectNulls: true,  
                        data: now.series_data.negative2sd,  
                        symbolSize: '0.5',  
                        lineStyle: {  
                            normal: {  
                                width: 1.5  
                            }  
                        }  
                    }  

                ],  
                tooltip: {  
                    trigger: 'axis',  
                    position: [35, 8],  
                    formatter: function(params) {  
                        let list = params.length  
                        let txt = params[0].name + "\n"  
                        for (var i = 0; i < list; i++) {  
                            if (i < list - 1) {  
                                txt += `${params[i].seriesName}:${params[i].data==null?'无数据':params[i].data}\n`  
                            } else {  
                                txt += `${params[i].seriesName}:${params[i].data==null?'无数据':params[i].data}`  
                            }  
                        }  
                        return txt  
                    }  
                },  
            };  

配置里面的所有function都失效了在app中,网页上没问题

2020-10-29 17:03 负责人:无 分享
已邀请:
只吃蛋糕的狐

只吃蛋糕的狐

最后解决了吗?

  • 东东东东 (作者)

    这个可以解决的,在最后使用setOption的时候,echarts的option里面,已经少了这些函数,这时候把函数在赋值给option就可以了

    2021-01-08 15:05

该问题目前已经被锁定, 无法添加新回复