Skip to content

Instantly share code, notes, and snippets.

@yoxisem544
Created April 27, 2022 13:59
Show Gist options
  • Save yoxisem544/63b1863912ab8fd9cdad7f23bec740b5 to your computer and use it in GitHub Desktop.
Save yoxisem544/63b1863912ab8fd9cdad7f23bec740b5 to your computer and use it in GitHub Desktop.
重構 77~147 行
var previous: LineChartDataSet?
let lineSets = [PE14, PE16, PE18, PE20, PE22, PE24]
let colors = [
UIColor(displayP3Red: 18/255, green: 31/255, blue: 29/255, alpha: 0.5),
UIColor(displayP3Red: 41/255, green: 196/255, blue: 180/255, alpha: 1),
UIColor(displayP3Red: 162/255, green: 212/255, blue: 209/255, alpha: 1),
UIColor(displayP3Red: 231/255, green: 197/255, blue: 105/255, alpha: 1),
UIColor(displayP3Red: 242/255, green: 162/255, blue: 110/255, alpha: 1),
UIColor(displayP3Red: 241/255, green: 129/255, blue: 97/255, alpha: 1)
]
zip(lineSets, colors).forEach { lineSet, color in
lineSet.mode = .linear
lineSet.drawCirclesEnabled = false
lineSet.lineWidth = 3
lineSet.setColor(color)
lineSet.fill = Fill(color: color)
// fill
if let previous = previous {
lineSet.fillAlpha = 1
lineSet.drawFilledEnabled = true
lineSet.fillFormatter = areaGraph(fillLineDataSet: previous)
}
previous = lineSet
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment