LoginSignup
1
1

More than 5 years have passed since last update.

【メモ】Chart - ScatterChartDataSetのShapeの書き方と例

Last updated at Posted at 2017-05-12

グラフ作成ライブラリ「Charts」の点グラフ(散布図)「ScatterChart」の点の形の書き方

Shapeの種類

ScatterChartDataSet.swift
@objc(ScatterShape)
    public enum Shape: Int
    {
        case square
        case circle
        case triangle
        case cross
        case x
        case chevronUp
        case chevronDown
    }

書き方の例

ViewController.swift
import Charts

class ViewController: UIViewController {
    var chartView: ScatterChartView!
    var dataSets: NSMutableArray = []
    var data: ScatterChartData!

    override func viewDidLoad() {
        var entries: [BarChartDataEntry] = []
        entries.append(BarChartDataEntry(x: 0, y: 0))
        entries.append(BarChartDataEntry(x: 1, y: 1))

        var exampleSet = ScatterChartDataSet(values: entries, label: "entries")
        exampleSet.setScatterShape(ScatterChartDataSet.Shape.circle) //entriesの点を指定(circle)
        exampleSet.setColor(NSUIColor.red) //entriesの点の色を指定(red)

        self.dataSets.addObjects(from: [exampleSet])

        self.data = ScatterChartData(dataSets: self.dataSets as! [IChartDataSet])

        self.chartView.data = self.data
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1