在WatchOs中添加图表 [英] Adding charts in WatchOs

查看:67
本文介绍了在WatchOs中添加图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究POC,以在Apple Watch(商业/企业数据分析)中实施图表.

例如:

我该怎么做?

解决方案

我发现

 让图片= YOLineChartImage()image.strokeWidth = 4.0//线宽image.strokeColor = randomColor()//线条颜色image.values = [0.0,1.0,2.0]//图表值image.smooth = false//禁用平滑线image.drawImage(frame,scale:scale)//绘制图像 

折线图平滑

 让图片= YOLineChartImage()image.strokeWidth = 4.0//线宽image.fillColor = randomColor()//区域颜色image.values = [0.0,1.0,2.0]//图表值//image.smooth = true//[默认]绘制一条平滑线image.drawImage(frame,scale:scale)//绘制图像 

垂直条形图

 让图片= YOBarChartImage()image.values = [0.0,1.0,2.0]//图表值image.fillColor = randomColor()//条形颜色//image.barPadding = 2.0//[可选]条形填充//image.barStyle = .Vertical//[默认]绘制竖线image.drawImage(frame,scale:scale)//绘制图像 

水平条形图

 让图片= YOBarChartImage()image.values = [0.0,1.0,2.0]//图表值image.fillColor = randomColor()//条形颜色//image.barPadding = 2.0//[可选]条形填充image.barStyle = .Horizo​​ntal//绘制水平条image.drawImage(frame,scale:scale)//绘制图像 

甜甜圈图

 让图片= YODonutChartImage()image.donutWidth = 16.0//甜甜圈的宽度//image.labelText ="LABEL"//[可选]中心标签文本//image.labelColor = UIColor.whiteColor()//[可选]中心标签颜色image.values = [10.0,20.0,70.0]//图表值image.colors =(0 ..< 3).map {_ in randomColor()}//片段的颜色image.drawImage(frame,scale:scale)//绘制图像 


框架要求

  watchOS〜>2.0 

构建要求

  Xcode> = 7.1 


示例应用程序

示例应用程序可用于iOS和watchOS.您可以在此处

找到所有文件

pod尝试YOChartImageKit

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


您可以在 GitHub自述文件上找到所有文档.

来源

I am working on a POC to implement charts in Apple Watch (Analytics for Business/Enterprise data).

For example :

How can I do that ?

解决方案

I found that YOChartImageKit. With this library you can create charts in watch os.

Installation

CocoaPods

use_frameworks!

pod 'YOChartImageKit', '~> 1.1'

Carthage

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

Example applications are available for both iOS and watchOS. You can find all file here

pod try YOChartImageKit

or open YOChartImageKit.xcodeproj with Xcode and build demo app.


You can find all the documentation on the GitHub readme.

Sources

这篇关于在WatchOs中添加图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆