グラフを描画するためにコアプロットを使用しています。私の問題は、凡例の文字色を線の色に合わせて設定したいのです。私は1つのグラフに4つの散布図があり、各散布図は異なる線の色を持っています。コアプロットを使用して凡例に異なる色のテキストを設定する方法
凡例では線の色が正しく表示されますが、散布図の各タイトルの線の色に合わせてテキストの色を変更したいと思います。私は伝説のために次のコードを書いています。伝説凡例内のすべてのテキストは、白色であるので、唯一のスタイルすなわちnewGraph.legend?.textStyle = dataSourceLabelStyle
を取ることができることが理解される上記コードを形成するよう
newGraph.legend = CPTLegend(graph: newGraph)
newGraph.legend?.numberOfRows = UInt(2.0)
let dataSourceLabelStyle = CPTMutableTextStyle()
dataSourceLabelStyle.color = CPTColor.white()
newGraph.legend?.textStyle = dataSourceLabelStyle
newGraph.legend?.fill = CPTFill(color: CPTColor.init(componentRed: 50/244, green: 43/244, blue: 87/244, alpha: 1.0))
newGraph.legend?.cornerRadius = 5.0
newGraph.legendDisplacement = CGPoint.init(x: -50, y: 210)
let fadeInAnimation = CABasicAnimation(keyPath: "opacity")
fadeInAnimation.duration = 1.0
fadeInAnimation.isRemovedOnCompletion = false
fadeInAnimation.fillMode = kCAFillModeForwards
fadeInAnimation.toValue = 1.0
dataSourceLinePlot.add(fadeInAnimation, forKey: "animateOpacity")
self.scatterGraph = newGraph
。
凡例のテキストの色を線の色に合わせて変更したいと思います。
私はこれを手伝ってくれますか?
ありがとうございました。 – Gyanendra