2011-05-24 75 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

相关问题