微信小程序使用f2绘图真的一言难尽,各种坑...
使用饼图绘图时,需要加上饼图文本,此时提示chart.pieLabel is not a function,原因是官方说PieLabel插件默认没有打包至@antv/f2模块包中,而官方提供的解决方法也并不能使用,害我白白浪费了好多时间,如果你们尝试成功了请告诉我,万分感谢!
下面是在参考issue后自己解决这个问题的方法:
1.打开@antv/wx-f2/index.js发现没有注册PieLabel,但是有默认的Legend、Guide等,可以找到下面这段代码:
var Legend = /*#__PURE__*/Object.freeze({
__proto__: null,
init: init$2,
beforeGeomDraw: beforeGeomDraw,
afterGeomDraw: afterGeomDraw$2,
clearInner: clearInner$1,
'default': legend
});
2.相应的,去node_monules/@antv/f2/dist/f2-all.js,在文件中找到PieLabel的这一段,复制到上面的文件中
var PieLabel = /*#__PURE__*/Object.freeze({
__proto__: null,
init: init$4,
afterGeomDraw: afterGeomDraw$4,
clearInner: clearInner$3,
'default': pieLabel
});