在WatchOs中添加图表[关闭]

问题描述 投票:-3回答:1

我正在开发一个POC来实现Apple Watch中的图表(商业/企业数据分析)。

例如 :

Watch Os app with charts

我怎样才能做到这一点 ?

ios watchkit apple-watch
1个回答
8
投票

我发现YOChartImageKit。使用此库,您可以在watch os中创建图表。

Installation

的CocoaPods

use_frameworks!

pod 'YOChartImageKit', '~> 1.1'

迦太基

github "yasuoza/YOChartImageKit" ~> 1.1

CocoaSeeds

# For both iOS and watchOS framework
target 'YOChartImageKit' do
   github 'yasuoza/YOChartImageKit', '1.1.0', files: 'Source/YOChartImageKit/*.{h,m}'
end

Configuration

折线图固体

Line chart solid

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

折线图平滑

Line chart smooth

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

条形图垂直

Bar chart vertical

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

条形图水平

Bar chart horizontal

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

甜甜圈图表

Donut chart

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

Framework Requirements

watchOS ~> 2.0

Build Requirements

Xcode >= 7.1

Example Application

示例应用程序可用于iOS和watchOS。你可以找到所有文件here

pod try YOChartImageKit

或使用Xcode打开YOChartImageKit.xcodeproj并构建演示应用程序。


您可以在GitHub readme上找到所有文档。

Sources

© www.soinside.com 2019 - 2024. All rights reserved.