ios - 在 WatchOs 中添加图表
解决方案
我发现了YOChartImageKit。使用这个库,您可以在 watch os 中创建图表。
安装
可可豆荚
use_frameworks!
pod 'YOChartImageKit', '~> 1.1'
迦太基
github "yasuoza/YOChartImageKit" ~> 1.1
可可种子
# For both iOS and watchOS framework
target 'YOChartImageKit' do
github 'yasuoza/YOChartImageKit', '1.1.0', files: 'Source/YOChartImageKit/*.{h,m}'
end
配置
折线图实心
let image = YOLineChartImage()
image.strokeWidth = 4.0 // width of line
image.strokeColor = randomColor() // color of line
image.values = [0.0, 1.0, 2.0] // chart values
image.smooth = false // disable smooth line
image.drawImage(frame, scale: scale) // draw an image
折线图平滑
let image = YOLineChartImage()
image.strokeWidth = 4.0 // width of line
image.fillColor = randomColor() // color of area
image.values = [0.0, 1.0, 2.0] // chart values
// image.smooth = true // [default] draws a smooth line
image.drawImage(frame, scale: scale) // draw an image
条形图垂直
let image = YOBarChartImage()
image.values = [0.0, 1.0, 2.0] // chart values
image.fillColor = randomColor() // color of bars
// image.barPadding = 2.0 // [optional] padding of bars
// image.barStyle = .Vertical // [default] draws a vertical bars
image.drawImage(frame, scale: scale) // draw an image
条形图水平
let image = YOBarChartImage()
image.values = [0.0, 1.0, 2.0] // chart values
image.fillColor = randomColor() // color of bars
// image.barPadding = 2.0 // [optional] padding of bars
image.barStyle = .Horizontal // draws a horizontal bars
image.drawImage(frame, scale: scale) // draw an image
甜甜圈图
let image = YODonutChartImage()
image.donutWidth = 16.0 // width of donut
// image.labelText = "LABEL" // [optional] center label text
// image.labelColor = UIColor.whiteColor() // [optional] center label color
image.values = [10.0, 20.0, 70.0] // chart values
image.colors = (0..<3).map { _ in randomColor() } // colors of pieces
image.drawImage(frame, scale: scale) // draw an image
框架要求
watchOS ~> 2.0
构建要求
Xcode >= 7.1
示例应用程序
示例应用程序适用于 iOS 和 watchOS。你可以在这里找到所有文件
pod try YOChartImageKit
或YOChartImageKit.xcodeproj
使用 Xcode 打开并构建演示应用程序。
您可以在GitHub 自述文件中找到所有文档。
推荐阅读
- c# - 在 EF Core 3.1 中包含 FromSqlRaw 和存储过程
- r - 以最短的计算时间遍历每一行和每一列
- mysql - 要添加哪些 MySQL 索引,其中只有两列中的一列是非空的
- node.js - 如何使用 node.js 从数据库中获取特殊字符?
- celery - 使用 Pytest,是否可以从 celery 运行的子进程中获取覆盖信息?
- c++ - 为什么 gdb 不能在带有 Visual Studio Code 的 Linux 中工作?
- terraform - lambda-source-mapping 的 Terraform 导入
- python - 如何在数据框中按月增加日期列?
- spring-mvc - 使用 RestTemplate 调用 WebFlux 微服务
- tensorflow - 在heroku上部署我的应用程序时出错 - tensorflow