2011-08-11 30 views
1

我正在使用powerplot在iphone中創建動態圖。雖然經歷了http://www.field-theory.org/articles/powerplot/example.html我成功創建了一個圖,但我不知道如何刪除圖中的默認dec值。 enter image description here在iPhone中使用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]; 

任何意見理解謝謝:)

enter image description here

回答

2

WSChartlinePlotWithFrame:...方法情節-堆棧上產生的WSPlotAxis兩個單獨的實例。第一種情況僅用於網格,第二種用於軸線滴答和標籤。

方法WSPlotAxis *axis=[aView getPlotAxis]將返回類型爲WSPlotAxis的第一個視圖,該視圖最初沒有任何刻度標籤。如果你想手動更改現有軸刻度和標籤,您需要使用

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

,而不是WSPlotAxis *axis=[aView getPlotAxis];獲得第二個實例。

然後它會按預期工作。