实现效果:

第一步:在uni_modules文件夹下找到config-ucharts.js和u-charts.js文件

第二步:在config-ucharts.js文件中配置换行格式

// 换行格式
"wrapTooltip":function(item, category, index, opts){
return item.name+':'+item.data
},
第三步:在u-charts.js文件中找到getToolTipData函数,修改换行文本

var wrapTitleText = null;
var textList = seriesData.map(function(item) {
let titleText = null;
if (opts.categories && opts.categories.length>0) {
titleText = categories[index];
};
wrapTitleText = titleText;
return {
text: option.formatter ? option.formatter(item, titleText, index, opts) : item.name + ': ' + item.data,
color: item.color,
legendShape: opts.extra.tooltip.legendShape == 'auto'? item.legendShape : opts.extra.tooltip.legendShape
};
});
textList.unshift({text:wrapTitleText,color:null})
var offset = {
x: Math.round(points.x),
y: Math.round(points.y)
};
// console.log("文本"+JSON.stringify(textList))
return {
textList: textList,
offset: offset
};
第五步:在图表页面引入提示框格式,tooltipFormat="wrapTooltip"
