气泡图,散点图,使用核心图的烛台图表

时间:2013-06-05 06:14:02

标签: ios ipad core-graphics core-plot

我的一个ipad项目需要有8种图形和图表,其中包括3个变量气泡图,散点图,烛台图等。快速搜索给我的结果作为核心图,这是目前最常用的图形和图表解决方案在ios.But当我进入页面时,我没有看到任何类型的气泡图或散点图实现。我的问题是......

  • 是否可以在coreplot中绘制3个可变气泡图,散点图或烛台图?或者我需要使用核心图形绘制整个图形?

提前致谢

3 个答案:

答案 0 :(得分:3)

Core Plot本身支持散点图和烛台图表。您可以使用散点图的自定义绘图符号并更改绘图符号的大小来表示第三个变量,从而轻松制作气泡图。

答案 1 :(得分:0)

如果你只想实现散点图,这里的代码在 swift 3.1 Xcode 8.3.2

中效果很好
func setChart(dataPoints:[String] , value1 :[Double] , value2:[Double])
 {
    var dataEntries1:[ChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(x:value1[i] , y : Double(i))
        dataEntries1.append(dataEntry)
    }

    var dataEntries2:[ChartDataEntry] = []

    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(x:value2[i] , y : Double(i))
        dataEntries2.append(dataEntry)
    }

    let dataSet1 = ScatterChartDataSet(values: dataEntries1, label: "Value1" )
    dataSet1 .setColor(UIColor.blue)
    let dataSet2 = ScatterChartDataSet(values: dataEntries2 ,label: "Value2")
    dataSet2.setColor(UIColor.green)

    var dataSets = [ScatterChartDataSet]()
    dataSets.append(dataSet1)
    dataSets.append(dataSet2)

    let barChartData = ScatterChartData(dataSets: dataSets)

    scatterChart.xAxis.labelPosition = .bottom
    scatterChart.rightAxis.enabled=false
    scatterChart.legend.enabled=false
    scatterChart.descriptionText = ""
    scatterChart.data = barChartData

}

答案 2 :(得分:0)

以下是在您的应用中添加气泡图的代码

此代码适用于 Swift 3.1和Xcode 8.3.2

<ul class="list-group" style="border: none">
<li class="list-group-item" style="background-color:#f2f2f2"><strong>Search by Category</strong></li>
@foreach($categoryCount as $category) 
<li class="list-group-item">{{$category->category_title}} 
<span class="badge badge-pill badge-primary">{{$category->totall</span> 
</li> 
@endforeach
</ul>