帮酷LOGO
  • 显示原文与译文双语对照的内容
文章标签:Apple  chart  ios-charts  BASE  苹果手表  监听  CHAR  
A chart library for Apple Watch based on PNChart.

  • 源代碼名稱:NKWatchChart
  • 源代碼網址:http://www.github.com/NilStack/NKWatchChart
  • NKWatchChart源代碼文檔
  • NKWatchChart源代碼下載
  • Git URL:
    git://www.github.com/NilStack/NKWatchChart.git
  • Git Clone代碼到本地:
    git clone http://www.github.com/NilStack/NKWatchChart
  • Subversion代碼到本地:
    $ svn co --depth empty http://www.github.com/NilStack/NKWatchChart
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • #NKWatchChart#

    VerisionPlatformLicense

    一個基於PNChart的蘋果手錶(Apple Watch) 圖表庫。 我們現在支持線,酒吧,餡餅,圓和雷達圖表,並將集成更多的圖表類型的 ios圖表。

    gif

    ##Usage##

    watchOS目標中的###Cocoapods###

    pod 'NKWatchChart'

    然後

    pod install

    #import"NKWatchChart.h"

    使用Cocoapods和 watchOS 2,Justin Ehlert

    查看應用程序擴展 ###的###Copy NKWatchChart文件夾

    ##Requirements##

    • watchOS ~> 2.0
    • Xcode> = 7.0

    ##Examples##

    ####Line Chart####

    Line Chart

     NKLineChart *chart = [[NKLineChart alloc] initWithFrame:frame];
     chart.yLabelFormat = @"%1.1f";
     [chart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
     chart.showCoordinateAxis = YES;
     //Use yFixedValueMax and yFixedValueMin to Fix the Max and Min Y Value//Only if you needed chart.yFixedValueMax = 300.0;
     chart.yFixedValueMin = 0.0;
     [chart setYLabels:@[
     @"0",
     @"50",
     @"100",
     @"150",
     @"200",
     @"250",
     @"300",
     ]
     ];
     chart.yLabelFont = [UIFont systemFontOfSize:6.f];
     chart.xLabelFont = [UIFont systemFontOfSize:6.f];
     chart.xLabelWidth = 10.f;
     chart.yLabelColor = NKGreen;
     chart.xLabelColor = NKGreen;
     chart.axisColor = NKLightGrey;
     chart.axisWidth = 1.f;
     chart.xUnit = @"Day";
     chart.yUnit = @"Min";
     // Line Chart #1NSArray * data01Array = @[@60.1, @160.1, @126.4, @0.0, @186.2, @127.2, @176.2];
     NKLineChartData *data01 = [NKLineChartData new];
     data01.color = NKGreen;
     data01.alpha = 0.9f;
     data01.itemCount = data01Array.count;
     data01.inflexionPointStyle = NKLineChartPointStyleTriangle;
     data01.getData = ^(NSUInteger index) {
     CGFloat yValue = [data01Array[index] floatValue];
     return [NKLineChartDataItem dataItemWithY:yValue];
     };
     // Line Chart #2NSArray * data02Array = @[@0.0, @180.1, @26.4, @202.2, @126.2, @167.2, @276.2];
     NKLineChartData *data02 = [NKLineChartData new];
     data02.color = NKTwitterColor;
     data02.alpha = 0.5f;
     data02.itemCount = data02Array.count;
     data02.inflexionPointStyle = NKLineChartPointStyleCircle;
     data02.getData = ^(NSUInteger index) {
     CGFloat yValue = [data02Array[index] floatValue];
     return [NKLineChartDataItem dataItemWithY:yValue];
     };
     chart.chartData = @[data01,data02];
     image = [chart drawImage];
     [self.chartImage setImage:image];

    ####Bar Chart####

    Bar Chart

     NKBarChart *chart = [[NKBarChart alloc] initWithFrame:frame];
     chart.yLabelFormatter = ^(CGFloat yValue){
     CGFloat yValueParsed = yValue;
     NSString * labelText = [NSStringstringWithFormat:@"%0.f",yValueParsed];
     return labelText;
     };
     chart.labelMarginTop = 5.0;
     chart.showChartBorder = YES;
     [chart setXLabels:@[@"2",@"3",@"4",@"5",@"2",@"3",@"4",@"5"]];
     // self.barChart.yLabels = @[@-10,@0,@10]; [chart setYValues:@[@10.82,@1.88,@6.96,@33.93,@10.82,@1.88,@6.96,@33.93]];
     [chart setStrokeColors:@[NKGreen,NKGreen,NKRed,NKGreen,NKGreen,NKGreen,NKRed,NKGreen]];
     image = [chart drawImage];
     [self.chartImage setImage:image];

    ####Pie Chart####

    Pie Chart

    NSArray *items = @[[NKPieChartDataItem dataItemWithValue:10color:NKLightGreen],
     [NKPieChartDataItem dataItemWithValue:20color:NKFreshGreen description:@"WWDC"],
     [NKPieChartDataItem dataItemWithValue:40color:NKDeepGreen description:@"GOOG I/O"],
     ];
     NKPieChart *chart = [[NKPieChart alloc] initWithFrame:frame items:items];
     chart.descriptionTextColor = [UIColor whiteColor];
     chart.descriptionTextFont = [UIFont systemFontOfSize:12.0];
     chart.showAbsoluteValues = NO;
     chart.showOnlyValues = NO;
     image = [chart drawImage];
     [self.chartImage setImage:image];

    ####Circle Chart####

    Circle Chart

     UIColor *shadowColor = [UIColor colorWithRed:225.0/255.0green:225.0/255.0blue:225.0/255.0alpha:0.5f];
     NKCircleChart *chart = [[NKCircleChart alloc] initWithFrame:frame total:@100current:@60clockwise:YESshadow:YESshadowColor:shadowColor displayCountingLabel:YESoverrideLineWidth:@5];
     chart.strokeColor = NKGreen;
     chart.strokeColorGradientStart = NKLightGreen;
     image = [chart drawImage];
     [self.chartImage setImage:image];

    ####Radar Chart####

    Radar Chart

    NSArray *items = @[[NKRadarChartDataItem dataItemWithValue:3description:@"Art"],
     [NKRadarChartDataItem dataItemWithValue:2description:@"Math"],
     [NKRadarChartDataItem dataItemWithValue:8description:@"Sports"],
     [NKRadarChartDataItem dataItemWithValue:5description:@"Liter"],
     [NKRadarChartDataItem dataItemWithValue:4description:@"Other"],
     ];
     NKRadarChart *chart = [[NKRadarChart alloc] initWithFrame:frame items:items valueDivider:1];
     image = [chart drawImage];
     [self.chartImage setImage:image];

    ##TODO##

    ##Apps 使用 NKWatchChart##

    請在 guoleii@gmail.com 告訴我,如果你在應用程序中使用 NKWatchChart 。

    medias##上的##NKWatchChart

    • maniacdev.com

    https://maniacdev.com/2015/08/open-source-library-for-drawing-charts-on-the-apple-watch

    • watchkitresources.com

    http://watchkitresources.com/issues/9

    • 朝鮮語中的iphonedev.co.kr

    http://iphonedev.co.kr/sampleSource/24204

    • 中文 toutiao.io

    http://toutiao.io/posts/qga8e

    ##License## 這裡代碼是根據MIT許可證的條款和條件分發的。

    ##Thanks## Awesome圖表庫 PNChart @kevinzhow



    文章标签:BASE  CHAR  Apple  chart  监听  苹果手表  ios-charts  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语