最近因项目需求,需要自己定制一个绘图的功能。开始也在网上找了现成的、开源的组件,但是应为样式差别太大、功能不能够满足、修改难度大,所以决定自己实现一个适用项目需求的绘图组件。现在给大家分享一下这个组件,希望能够帮助的上有需要的朋友,代码量不多,修改起来非常容易,使用也很简单。
demo地址(求Star😝)
先上个效果图
使用方法非常的简单
- 添加一条折线图
self.chartView?.drawLine(values: [188.8,165,177.7,155,155,190], xDescribe: ["1","2","3","4","5","6"], lineColor: .blue, type: .line)
- 添加一条曲线图
self.chartView?.drawLine(values: [111.1,148,100,135.5,120,105,132,121], xDescribe: ["1","2","3","4","5","6","7","8"], lineColor: .orange, type: .curve)
- 添加柱状图
self.chartView?.drawPost(values: [23,46.5,67,23.7,98,75,88,66,4,18], xDescribe: ["1","2","3","4","5","6","7","8","9","10"], colors: [UIColor.red, UIColor.yellow], locations: [0, 0.5, 1])