【问题标题】:How to show Pie Chart , Bar Chart and Line graph in single view in ios如何在 ios 的单一视图中显示饼图、条形图和折线图
【发布时间】:2013-03-21 06:21:41
【问题描述】:

我想在 iPad 上显示图表,如下图所示。请建议我如何做到这一点?

我参考了教程How To Draw Graphs with Core Plot, Part 1 & 2

在这里我可以看到它使用不同的视图控制器来执行所有三个图形。我只希望它在单个视图控制器中。

【问题讨论】:

    标签: iphone ios bar-chart pie-chart linechart


    【解决方案1】:

    新建SingleView Application的项目,拖放使用core plot所需的东西,也将这三个视图控制器拖到你的项目中。

    你有三个视图控制器

    1. CPDPieChartViewController
    2. CPDBarGraphViewController
    3. CPDScatterPlotViewConntroller
    

    让它们成为 UIView 的子类,就像它们的 .h 中一样,而不是 <UIViewController> 使用 <UIView>

    1. CPDPieChartView
    2. CPDBarGraphView
    3. CPDScatterPlotView
    

    并在他们的实现文件中删除与 UIViewController 相关的代码,例如方法 -(void)viewDidAppear 和不需要的合成对象,并添加 initwithframe 方法。

    现在在你的项目主视图控制器中导入这三个视图类。

    -(void)viewDidLoad
    {
      CPDPieChartView *CPDPieChartViewObj=[[CPDPieChartView alloc]initWithFrame:CGRectmake(give proper frame)];
    [CPDPieChartViewObj initPlot];
    
    CPDBarGraphView *CPDBarGraphViewObj=[[CPDBarGraphView alloc]initWithFrame:CGRectmake(give proper frame)];
    [CPDBarGraphViewObj initPlot];
    
    CPDScatterPlotView *CPDScatterPlotViewObj=[[CPDScatterPlotView alloc]initWithFrame:CGRectmake(give proper frame)];
    [CPDScatterPlotViewObj initPlot];
    
    [self.view addSubview:CPDPieChartViewObj];
    [self.view addSubview:CPDBarGraphViewObj];
    [self.view addSubview:CPDScatterPlotViewObj];
    
    
    }
    

    【讨论】:

      【解决方案2】:

      这是一个例子: CompositePlot in CorePlotGallary

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-11-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-24
        • 2012-10-16
        相关资源
        最近更新 更多