iOSPlot:如何在同一视图上显示多个图表?

时间:2011-05-24 05:31:24

标签: iphone objective-c cocoa-touch ios4

我正在开发一款需要图表的iPhone应用程序。因此我使用名为iOSPlot的API绘制折线图。

我已从此链接下载API

https://github.com/honcheng/iOSPlot

图表显示正常。

我想在同一视图下方显示另一张图。

我该怎么做?

我想它是打印UIView上的图表,根据我的要求,图表可能超过1。

那么如何在同一个视图上显示多个图表呢?

1 个答案:

答案 0 :(得分: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
}