Ios 气泡图、散点图、烛台图(使用核心图)

Ios 气泡图、散点图、烛台图(使用核心图),ios,ipad,core-graphics,core-plot,Ios,Ipad,Core Graphics,Core Plot,我的一个ipad项目需要8种图形和图表,包括3个变量气泡图、散点图、,烛台图等。一个快速搜索给了我一个核心图的结果,这是目前ios中最常用的图形和图表解决方案。但当我进入那个页面时,我没有看到任何类型的气泡图或散点图实现。我的问题是 是否可以在coreplot中绘制3个变量的气泡图、散点图或烛台图?或者我需要使用core graphics绘制整个图形 提前感谢Core Plot本机支持散点图和烛台图。通过使用散点图的自定义绘图符号并改变绘图符号的大小以表示第三个变量,您可以轻松制作气泡图。如

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

  • 是否可以在
    coreplot
    中绘制3个变量的气泡图、散点图或烛台图?或者我需要使用core graphics绘制整个图形

提前感谢

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

如果您只想实现散点图,下面是在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

}
func设置图(数据点:[String],值1:[Double],值2:[Double])
{
var dataEntries1:[ChartDataEntry]=[]

对于0中的i..以下是在应用程序中添加气泡图的代码

该代码适用于Swift 3.1和Xcode 8.3.2

func setBubbleChart(dataPoints: [Int], values: [Int], amounts: [Int]) {

        var dataEntries: [BubbleChartDataEntry] = []

        for i in 0..<dataPoints.count {
            let dataEntry = BubbleChartDataEntry(x: Double(dataPoints[i]), y: Double(values[i]), size: 15.0)
            dataEntries.append(dataEntry)
        }

        let format = NumberFormatter()
        format.generatesDecimalNumbers = false
        format.zeroSymbol = ""
        _ = DefaultValueFormatter(formatter: format)

        let chartDataSet = BubbleChartDataSet(values: dataEntries, label: "Prashant")
        let chartData = BubbleChartData(dataSet: chartDataSet)



        chartDataSet.colors.append(setColor(value:30))

        bubbleChartView.doubleTapToZoomEnabled = true
        bubbleChartView.scaleXEnabled = true
        bubbleChartView.scaleYEnabled = true
        bubbleChartView.highlightPerTapEnabled = true
        bubbleChartView.highlightPerDragEnabled = true

        let firstLegend = LegendEntry.init(label: "Below 50", form: .default, formSize: CGFloat.nan, formLineWidth: CGFloat.nan, formLineDashPhase: CGFloat.nan, formLineDashLengths: nil, formColor: UIColor.black)
        let secondLegend = LegendEntry.init(label: "Between 50 and 75", form: .default, formSize: CGFloat.nan, formLineWidth: CGFloat.nan, formLineDashPhase: CGFloat.nan, formLineDashLengths: nil, formColor: UIColor.black)
        let thirdLegend = LegendEntry.init(label: "Over 75", form: .default, formSize: CGFloat.nan, formLineWidth: CGFloat.nan, formLineDashPhase: CGFloat.nan, formLineDashLengths: nil, formColor: UIColor.black)

        bubbleChartView.chartDescription = nil
        bubbleChartView.legend.entries = [firstLegend, secondLegend, thirdLegend]
        bubbleChartView.data = chartData
        bubbleChartView.drawBordersEnabled = true
        bubbleChartView.animate(xAxisDuration: 5.0, yAxisDuration: 5.0)

        let xAxis: XAxis = bubbleChartView.xAxis
        xAxis.drawAxisLineEnabled = true
        xAxis.drawGridLinesEnabled = true
        xAxis.drawLabelsEnabled = true
        xAxis.axisMinimum = 0
        xAxis.axisMaximum = 10

        let leftAxis: YAxis = bubbleChartView.leftAxis
        leftAxis.drawAxisLineEnabled = true
        leftAxis.drawGridLinesEnabled = true
        leftAxis.setLabelCount(2, force: true)
        leftAxis.axisMinimum = 0
        leftAxis.axisMaximum = 120

        let rightAxis: YAxis = bubbleChartView.rightAxis
        rightAxis.drawAxisLineEnabled = false
        rightAxis.drawGridLinesEnabled = true
        rightAxis.drawLabelsEnabled = false
    }
func setubbleChart(数据点:[Int],值:[Int],金额:[Int]){
变量数据项:[BubbleChartDataEntry]=[]
因为我在0。。