Parth Bhatt
Parth Bhatt

Reputation: 19469

iOSPlot: How to display multiple charts on the same view?

I am developing an iPhone app which requires charts. Hence I am using API called iOSPlot to draw line charts.

I have downloaded API from this link

https://github.com/honcheng/iOSPlot

Graph appears fine.

I want to display one graph below the other on the same view.

How can I do that?

I suppose it is printing out the charts on UIView and as per my requirement the charts could be more than 1.

So how can I display more than one chart on the same view?

Upvotes: 0

Views: 1076

Answers (1)

j_freyre
j_freyre

Reputation: 4738

It is not working?

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

Or this way:

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
}

Upvotes: 2

Related Questions