添付画像のようなグラフ機能を実装したいと思います。誰もそれのためのフレームワークを提案することはできますか?iOSで線グラフを描画する
今は以下のコードを使用していますが、x、y軸を使用して線を描くことはできません。 以下は、線を描くために使用するサンプルコードです lineChart.addLine(data5)//ここでdata5はx値を動的に含む配列で、y値はゼロから始まるスタティックです。今私はY値を動的にしたい。事前のおかげで
func drawLine(lineIndex: Int) {
var data = self.dataStore[lineIndex]
let path = UIBezierPath()
var xValue = self.x.scale(0) + x.axis.inset
var yValue = self.bounds.height - self.y.scale(data[0]) - y.axis.inset
path.moveToPoint(CGPoint(x: xValue, y: yValue))
for index in 1..<data.count {
xValue = self.x.scale(CGFloat(index)) + x.axis.inset
yValue = self.bounds.height - self.y.scale(data[index]) - y.axis.inset
path.addLineToPoint(CGPoint(x: xValue, y: yValue))
}
let layer = CAShapeLayer()
layer.frame = self.bounds
layer.path = path.CGPath
layer.strokeColor = colors[lineIndex].CGColor
layer.fillColor = nil
layer.lineWidth = lineWidth
self.layer.addSublayer(layer)
// animate line drawing
if animation.enabled {
let anim = CABasicAnimation(keyPath: "strokeEnd")
anim.duration = animation.duration
anim.fromValue = 0
anim.toValue = 1
layer.addAnimation(anim, forKey: "strokeEnd")
}
// add line layer to store
lineLayerStore.append(layer)
}
:
addLine方法はとしてdrawline関数を呼び出します。
お客様の要件に応じて[このライブラリサンプル](https://github.com/DipenPanchasara/ChartView)を参照することができます。 –