もっと、みやびちゃんぷりちー!

みやびちゃんぷりちー!

s7graphviewでグラフをプロット!

試しにiPadで書いてみました。

//
// GraphViewController.h
//
#import <UIKit/UIKit.h>
#import "S7GraphView.h"


@interface GraphViewController : UIViewController<S7GraphViewDataSource> {
@private
	S7GraphView* graphView_;
}

@property (nonatomic, retain) IBOutlet S7GraphView* graphView;

@end


//
// GraphViewController.c
//
#import "GraphViewController.h"


@implementation GraphViewController

@synthesize graphView = graphView_;

#pragma mark -
#pragma mark Private Methods

- (void)createYFormatter {
	NSNumberFormatter *numberFormatter = [[NSNumberFormatter new] autorelease];
	[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
	[numberFormatter setMinimumFractionDigits:0];
	[numberFormatter setMaximumFractionDigits:0];
	self.graphView.yValuesFormatter = numberFormatter;
}

- (void)createXFormatter {
	NSNumberFormatter *numberFormatter = [[NSNumberFormatter new] autorelease];
	[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
	[numberFormatter setMinimumFractionDigits:0];
	[numberFormatter setMaximumFractionDigits:0];
	self.graphView.xValuesFormatter = numberFormatter;
}

- (void)initGraphView {
	self.graphView.backgroundColor = [UIColor blackColor];
	self.graphView.drawAxisX = YES;
	self.graphView.drawAxisY = YES;
	self.graphView.drawGridX = YES;
	self.graphView.drawGridY = YES;
	self.graphView.xValuesColor = [UIColor whiteColor];
	self.graphView.yValuesColor = [UIColor whiteColor];
	self.graphView.gridXColor = [UIColor whiteColor];
	self.graphView.gridYColor = [UIColor whiteColor];
	self.graphView.drawInfo = NO;
	self.graphView.info = @"Load";
	self.graphView.infoColor = [UIColor whiteColor];
}


#pragma mark -
#pragma mark Inherit Methods

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
	self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
	if (self) {
		// Custom initialization.
	}
	return self;
}

- (id)init {
	return self = [super initWithNibName:nil bundle:nil];
}

- (void)loadView {
	[super loadView];
	self.graphView.dataSource = self;
}

- (void)viewDidLoad {
	[super viewDidLoad];
	[self createYFormatter];
	[self createXFormatter];
	[self initGraphView];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	return YES;
}


- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning];
}


- (void)viewDidUnload {
	[super viewDidUnload];
}


- (void)dealloc {
	self.view = nil;
	self.graphView = nil;
	[super dealloc];
}

#pragma mark -
#pragma mark protocol S7GraphViewDataSource

- (NSUInteger)graphViewNumberOfPlots:(S7GraphView *)graphView {
	return 1;

}

- (NSArray *)graphViewXValues:(S7GraphView *)graphView {
	NSMutableArray *array = [NSMutableArray arrayWithCapacity:101];
	for (int i = -50; i <= 50; i++) {
		[array addObject:[NSNumber numberWithInt:i]];
	}
	return array;

}

- (NSArray *)graphView:(S7GraphView *)graphView yValuesForPlot:(NSUInteger)plotIndex {
	NSMutableArray *array = [NSMutableArray arrayWithCapacity:101];
	switch (plotIndex) {
		case 0:
			for (int i = -50; i <= 50; i++) {
				[array addObject:[NSNumber numberWithInt:-i]]; // y = -x
			}
			break;
	}
	return array;
}

- (BOOL)graphView:(S7GraphView *)graphView shouldFillPlot:(NSUInteger)plotIndex {
	return NO;
}

@end

結果は

Y軸のマイナス値が表示されておりません。
設定がおかしいのか、もしくは制限事項か判らない状況です...

どなたかご教示願います。

iOSでグラフをプロット!

一先ず備忘録

まずは、s7graphview
iPhone用の高度なグラフライブラリ·s7graphview MOONGIFT
http://macisv.jp/blog/?p=485
個人的メモ
http://code.google.com/p/s7graphview/

続いて、core-plot
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
iPhoneアプリ超基礎開発備忘録 iPhoneでCore-Plotを使ってグラフを書いてみる
【アメーバ】core-plot その一|フレンチのブログ
【アメーバ】core-plot その二|フレンチのブログ
【アメーバ】core-plot その三|フレンチのブログ
【アメーバ】core-plot その四|フレンチのブログ
Google Code Archive - Long-term storage for Google Code Project Hosting.
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application

GitをSSHで運用する (Cont'd)

構築ができましたので、簡単な手順を

尚、gitはインストール済みであることを想定して書きます。

1.から3.はサーバ上で行います。

1. リポジトリアクセス用のユーザ(git)を作成

[root@server ~]$ useradd -m -U git
[root@server ~]$ passwd {anypassword}

2. パスの設定

  • gitユーザの.bashrcにパスを追加
export PATH="/home/gituser/bin:$PATH"
  • .cshrcなら
setenv PATH "/home/gituser/bin:$PATH"

3. gitoliteのインストール

  • 作業ディレクトリの作成
[git@server ~]$ mkdir -p $HOME/bin $HOME/gitolite/conf $HOME/gitolite/hooks
  • gitoliteのソースをチェックアウト(clone)
[git@server ~]$ git clone git://github.com/sitaramc/gitolite gitolite-source
  • rsaの公開/暗号鍵の作成
[git@server ~]$ ssh-keygen -t rsa -f ./admin -P "adminpassword"
  • gitoliteのセットアップ
[git@server ~]$ ./gitolite-sourcesrc/gl-system-install $HOME/bin $HOME/gitolite/conf $HOME/gitolite/hooks
[git@server ~]$ gl-setup $HOME/admin.pub
  • サーバ側に環境変数追加
    • gitユーザの.bashrcに以下を追加
export GL_RC=~/.gitolite.rc
export GL_ADMINDIR=~/.gitolite
export GL_BINDIR=~/bin
export GL_REPO=gitolite-admin
export GL_USER=git
export GL_TS=”$y-$m-$d.$h:$min:$s”
export GL_REPO_BASE_ABS=repositories # ここは~/.gitolite.rcの$REPO_BASEに合わせる

4. gitoliteの設定

1.から3.とは異なり、ここでの作業はローカルマシンで行います。

  • gitolite-adminのエクスポート
[user@local ~]$ git clone git@gitserver.domain:gitolite-admin
注意)
ローカルマシンに3.で作った秘密鍵をインポートするなど、ローカルからサーバにはSSHで繋げられるようにしておくこと!
  • ユーザの追加
    • rsaの公開/暗号鍵の作成
[user@local ~]$ ssh-keygen -t rsa -f ./user -P "userpassword"
    • 公開鍵の追加
[user@local ~]$ cp ./user.pub ./gitolite-admin/keydir
    • gitolite-admin/conf/gitolite.conf を修正
repo    gitolite-admin
        RW+     =   admin

repo    testing
        RW+     =   @all

# この様に追記・修正
repo    myrepo
        RW+     =   admin
        R       =   user

R: 読み込みのみ、RW: 読み込み/書き込み、RW+: 読み込み/書き込み/rewind

  • コミット
[user@local ~]$ cd ./gitolite-admin
[user@local ~]$ git add ./keydir/user.pub
[user@local ~]$ git commit -a -m "any comment Please!"
[user@local ~]$ git push

コミット後に、レポジトリ myrepo が作成されます。

追加ユーザの動作確認は、対象ユーザに秘密鍵(user)をインポートして貰い、以下のコマンドを実行します。

[another@machine ~]$ ssh git@gitserver.domain
PTY allocation request failed on channel 0
hello ogino, the gitolite version here is v1.5.8-17-gc8b1d8c
the gitolite config gives you the following access:
     R     	myrepo
     @R_ @W_	testing
Connection to gitserver.domain closed.

ユーザのグループ化も可能です。

gitolite-admin/conf/gitolite.conf を以下の様に設定すると

@group = aaron jacques hans roberto

repo    repo
        RW+     =   @group

ユーザ aaron、jacques、hans、robertoは、レポジトリ repoに「読み込み/書き込み/rewind」ができます。