Hello,
Is it possible change the color of the circle highlight point? Thank you!
here's my logic
init array of circle Colors
var circleColors = [NSUIColor]()
chartView.delegate = self
func colorPicker(value : Double) -> NSUIColor {
//input your own logic for how you actually want to color
if value > 100 || value < 50 {
return NSUIColor.red
}
else {
return NSUIColor.black
}
}
func setDataCount(_ count: Int, range: Double)
{
// MARK: ChartDataEntry
var values = [ChartDataEntry]()
var valueColors = [NSUIColor]()
for i in 0..<count {
let val: Double = Double(arc4random_uniform(UInt32(range)) + 3)
values.append(ChartDataEntry(x: Double(i), y: val))
valueColors.append(colorPicker(value: val))
circleColors.append(colorPicker(value: val))
}
// MARK: LineChartDataSet
var set1 = LineChartDataSet()
set1 = LineChartDataSet(values: values, label: "DataSet 1")
set1.circleRadius = 6.0
set1.circleColors = circleColors
set1.valueColors = valueColors
set1.highlightLineDashLengths = [5.0, 2.5]
set1.highlightColor = NSUIColor.black
set1.highlightLineWidth = 2.0
var dataSets = [LineChartDataSet]()
dataSets.append(set1)
// MARK: LineChartData
let data = LineChartData(dataSets: dataSets)
chartView.data = data
}
}
the most important
// MARK: - ChartViewDelegate
extension LineChart1ViewController: ChartViewDelegate
{
public func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight)
{
print("chartValueSelected : x = \(highlight.x) y = \(highlight.y)")
var set1 = LineChartDataSet()
set1 = (chartView.data?.dataSets[0] as? LineChartDataSet)!
let values = set1.values
let index = values.index(where: {$0.x == highlight.x}) // search index
set1.circleColors = circleColors
set1.circleColors[index!] = NSUIColor.cyan
chartView.data?.notifyDataChanged()
chartView.notifyDataSetChanged()
}
public func chartValueNothingSelected(_ chartView: ChartViewBase)
{
print("chartValueNothingSelected")
var set1 = LineChartDataSet()
set1 = (chartView.data?.dataSets[0] as? LineChartDataSet)!
set1.circleColors = circleColors
chartView.data?.notifyDataChanged()
chartView.notifyDataSetChanged()
}
}

@thierryH91200 thanks!
How can we change icon image if we set icon in the place of the circle?
Hlo,
How can i auto select bar graph bar according to current month or day?
Most helpful comment
here's my logic
init array of circle Colors
the most important