2011-05-24 74 views
0

我正在開發一個需要圖表的iPhone應用程序。因此我使用稱爲iOSPlot的API來繪製折線圖。iOSPlot:如何在同一視圖中顯示多個圖表?

我從這個鏈接

https://github.com/honcheng/iOSPlot

圖表顯示正常下載API。

我想在同一個視圖下顯示一個圖下方的其他圖。

我該怎麼做?

我想這是打印出來的UIView圖表和按我的要求,圖表可能超過1

所以,我怎麼能顯示在同一視圖多個圖表?

+0

你可以嘗試使用'UIScrollView' – 2011-05-24 05:54:04

+0

@j_freyre:感謝您的輸入,但我想這不會是有用的,因爲我可能有10的UIView,甚至1 UIView的。此外,所有這些都是以編程方式創建的,還需要繪製不同圖表的不同數據。另外ScrollView的問題是我無法捕捉scrollview的整個內容的屏幕截圖。我需要通過電子郵件發送整個圖像,並允許它打印出任何連接的打印機。 – 2011-05-24 06:04:13

回答

2

它不工作?

PCHalfPieChart *pieChart1 = [[PCHalfPieChart alloc] initWithFrame:CGRectMake(10, 10, 50, 50)]; 
[self.view addSubview:pieChart1]; 
// adding dataset1 to pieChart1 

PCHalfPieChart *pieChart2 = [[PCHalfPieChart alloc] initWithFrame:CGRectMake(70, 10, 50, 50)]; 
[self.view addSubview:pieChart2]; 
// adding dataset2 to pieChart2 

或者這樣說:

PCLineChartView * lineChart; 

// you should find a way to define your x, y, width and height correctly. 
// I have not enough information about your project to find a solution 
// I admit that there is 4 var called x, y, width and height 

for (int i=0; i < numberOfChart; i++) { 
    lineChart = [[PCLineChartView alloc] initWithFrame:CGRectMake(x, y, width, height)]; 
    // Add some data 
    // it can be based on the index to define which data goes to which chart 
    // ... 

    [self.view addSubview: lineChart]; 
    [lineChart release]; 

    // Changing values of x, y, width and height 
    // should come here 
} 
+0

我正在繪製折線圖,​​而不是餅圖。此外,我必須以編程方式生成它們,因此無法按照您的指定來命名它們,因爲我無法預測將會有多少圖表。還有一個要求是,它需要全尺寸,就像你在回答中所說的那樣,它將劃分屏幕,因此圖形將縮小到更小的尺寸。在那種情況下可以做什麼? – 2011-05-24 06:17:29

+0

@PARTH我編輯我的答案;)希望這會幫助你 – 2011-05-24 06:27:49

+0

感謝您的輸入。但屏幕截圖呢?我無法捕捉到整個圖像,也正如我前面提到的,我不能只在視圖的可見部分保留addsubviews,因爲它可能會從1到任何數字。 – 2011-05-24 09:19:23

相關問題