antvis / wx-f2

F2 的微信小程序
MIT License
1.28k stars 185 forks source link

Hello, how can I solve the problem of chart.pieLabel is not a function when the pie chart reports an error? 你好,请问饼图报错 chart.pieLabel is not a function 怎么解决呢? #368

Open coderyqy opened 2 years ago

coderyqy commented 2 years ago

唉,我看了好多条Issues,好像都没有解决方案啊。 看文档说明,PieLabel 插件默认没有打包至 @antv/f2 模块包中。 按照文档操作引入:const F2 = require('@antv/f2/lib/index-all'); 但是这样引入又说找不到,怎么解决呢?

xiongchenxu commented 2 years ago

要修改源码,将PieLabel注册进去,然后npm重新打包,这样项目才能使用。 image

GzhiYi commented 2 years ago

试试替换这个js文件 -> 代码

xiongchenxu commented 2 years ago

你发的邮件,我已经收到了!~I have received the mail of you send!

xiongchenxu commented 2 years ago

看不到呀

---原始邮件--- 发件人: @.> 发送时间: 2021年12月23日(周四) 晚上10:08 收件人: @.>; 抄送: @.**@.>; 主题: Re: [antvis/wx-f2] Hello, how can I solve the problem of chart.pieLabel is not a function when the pie chart reports an error? 你好,请问饼图报错 chart.pieLabel is not a function 怎么解决呢? (#368)

试试替换这个js文件 -> 代码

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

lh147258 commented 2 years ago

我想问一下,替换那个文件的js代码呢

xiongchenxu commented 2 years ago

你发的邮件,我已经收到了!~I have received the mail of you send!

lh147258 commented 2 years ago

@xiongchenxu 可以给我说一下是替换那个文件里的么。或者把文件发给我一份谢谢啦

xiongchenxu commented 2 years ago

@xiongchenxu 可以给我说一下是替换那个文件里的么。或者把文件发给我一份谢谢啦

自己编译,重新构建就好了。 1.关闭微信小程序,进入 node_modules/@antv/wx-f2/src/index.js 注入代码: const PieLabel = require('@antv/f2/lib/plugin/pie-label'); F2.Chart.plugins.register(PieLabel); 2.node_modules@antv\wx-f2路径下,执行 npm install、npm run build,完成后删除node_modules@antv\wx-f2\node_modules 3.重新打开微信小程序,开启npm使用功能,构建npm包。 此时PieLabel已经被注册到F2中了,无需引入,直接使用。其实还可以等F2 4.x,新的F2组件更好,不过官方更新的慢了点,主要是ScrollBar在F2 3.x的小程序中引入有BUG,F2 4.x解决了,等待官方更新新版本后,直接用新的吧。