Swift Chart
バーチャートの例
swift
import Charts
struct GraphData: Identifiable {
var id = UUID()
var title: String
var value: Double
}
@State var items: [GraphData] = [
GraphData(title: "OK", value: 80),
GraphData(title: "NG", value: 20),
]
Chart(items) { item in
BarMark(x: .value("Name", item.title), y: .value("Value", item.value))
}
固定で良け ればこんな感じ
swift
Chart {
BarMark(x: .value("Name", "OK"), y: .value("Value", 80))
BarMark(x: .value("Name", "NG"), y: .value("Value", 20))
}
円グラフ ( pie chart )
swift
Chart {
SectorMark(angle: .value("Value", 80), innerRadius: 5, outerRadius: 8).foregroundStyle(.green)
SectorMark(angle: .value("Value", 20), innerRadius: 5, outerRadius: 8).foregroundStyle(.gray)
}