0

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

For example :

Watch Os app with charts

How can I do that ?

Pol
  • 1,132
  • 1
  • 11
  • 35
  • 1
    Good to know, thanks for the info. – sɐunıɔןɐqɐp Jun 25 '18 at 07:41
  • Welcome to Stack Overflow! Unfortunately [questions asking for: books, libraries, tutorials, tools, or other off-site resource are off-topic](https://stackoverflow.com/help/on-topic) and should be closed. Stack Overflow is a [Questions](https://stackoverflow.com/help/how-to-ask) & [Answers](https://stackoverflow.com/help/how-to-answer) website for specific programming questions. – sɐunıɔןɐqɐp Jun 25 '18 at 07:42

1 Answers1

16

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

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

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

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

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

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

Pol
  • 1,132
  • 1
  • 11
  • 35