2011-08-11 18 views
1

私はpowerplotを使ってiphoneで動的グラフを作成しています。 http://www.field-theory.org/articles/powerplot/example.html私は正常にグラフを作成するが、私はグラフ内のデフォルトのdec値を削除する方法を知らない。 enter image description hereiPhoneでpowerplotを使用した線グラフを作成する

私はmockappsから概念的に考えているこのようなものを作成したいと考えています。

float sourceData[7] = {33, 17, 24, 11, 11, 4, 10}; 
    self.allData = [WSData dataWithValues:[WSData arrayWithFloat:sourceData withLen:7]]; 
self.allData = [self.allData indexedData]; 

WSChart *tmp; 
tmp = [WSChart linePlotWithFrame:[aView frame] 
           withData:self.allData 
           withStyle:kChartLineFilled 
           withAxisStyle:kCSGrid 
           withColorScheme:kColorGray 
           withLabelX:@"Days" 
           withLabelY:@"Drinks"]; 
      [aView removeAllPlots]; 
      [aView addPlotsFromChart:tmp]; 

[aView scaleAllAxisYD:NARangeMake(-10, 45)]; 
[aView setAllAxisLocationYD:0]; 
[aView setAllAxisLocationXD:-0.5]; 


WSPlotAxis *axis = [aView getPlotAxis]; 

[[axis ticksX] setTicksStyle:kTicksLabels]; 
[[axis ticksY] setTicksStyle:kTicksLabels]; 
[[axis ticksY] ticksWithNumbers:[NSArray arrayWithObjects: 
           [NSNumber numberWithFloat:0], 
           [NSNumber numberWithFloat:10], 
           [NSNumber numberWithFloat:20], 
           [NSNumber numberWithFloat:20], 
           nil] 
        withLabels:[NSArray arrayWithObjects:@"", 
           @"10%", @"20%", @"30%", nil]]; 

[axis.ticksX setTickLabelsWithStrings:[NSArray arrayWithObjects:@"Mon", @"Tue", @"Wed", 
             @"Thur", @"Fri", @"Sat", @"Sun", nil]]; 



[aView setNeedsDisplay]; 

コメントはWSChartlinePlotWithFrame:...方法プロットスタックにWSPlotAxis 2つの別々のインスタンスを生成するおかげ:)

enter image description here

答えて

2

を理解しています。最初のインスタンスはグリッド専用で、2番目のインスタンスは軸のティックとラベルです。

WSPlotAxis *axis=[aView getPlotAxis]メソッドは最初に目盛りラベルを持たないタイプWSPlotAxisの最初のビューを返します。手動で既存の軸の目盛りとラベルを変更したい場合は、

WSPlotAxis *axis = (WSPlotAxis *)[self.chart plotAtIndex:2].view; 

代わりのWSPlotAxis *axis=[aView getPlotAxis];を使用して2つ目のインスタンスを取得する必要があります。

それは期待どおりに動作します。

関連する問題