グラフ作成ライブラリ「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
}
}