-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
different Bar color based on values #2342
Comments
Currently, im doing as below: func loadBarChart(_ count: Int, range: Double)
|
You can overwrite the colorForIndex
Or set two yValues for each entry. and colors.first for one yValues[0] the last for yValues[1]
发自我的 iPhone
… 在 2017年4月9日,下午2:02,gsolanki1509 ***@***.***> 写道:
Currently, im doing as below:
func loadBarChart(_ count: Int, range: Double)
{
var yVals = BarChartDataEntry
for i in 0..<count //).reversed()
{
let val = Double((arrBarValues[i]))
yVals.append(BarChartDataEntry(x: Double(i), y: val!))
}
var set1 = BarChartDataSet()
if barChartView.data == nil
{
set1.colors = [UIColor(red: 255.0/255.0, green: 245.0/255.0, blue: 118.0/255.0, alpha: 1.0) ]
set1.drawValuesEnabled = false
var dataSets = [ChartDataSet]()
dataSets.append(set1)
let data = BarChartData(dataSets: dataSets)
let groupSpace = 0.1 // space between bar groups
let barSpace = 0.09 // space between bars within a group
data.barWidth = (1.0 - groupSpace) / 1.75 - barSpace // 2 = number of bars within a group
data.groupBars(fromX: 0.0, groupSpace: groupSpace, barSpace: barSpace)
let marker = YMarkerView( color: NSUIColor.black,
font: NSUIFont.systemFont(ofSize: 12.0),
textColor: NSUIColor.white,
insets: UIEdgeInsets(top: 8.0, left: 0.0, bottom: 8.0, right: 0.0),
yAxisValueFormatter: HourValueFormatter())
marker.minimumSize = CGSize(width: CGFloat(80.0), height: CGFloat(40.0))
barChartView.marker = marker
barChartView.data = data
barChartView.fitBars = true
}
else
{
set1 = (barChartView.data!.dataSets[0] as! BarChartDataSet )
set1.values = yVals
barChartView.data?.notifyDataChanged()
barChartView.notifyDataSetChanged()
}
barChartView.setNeedsDisplay()
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
can you please elaborate ??? |
My concern is to show bar color as blue if its timing is after 9:00 AM. how can i get the value of that particular bar in that function? |
Got it... thanks ..!! :) |
@gsolanki1509 Would be nice if you can share the solution |
@anasimtiaz look at #2334 It is the same principle |
@thierryH91200 Thanks! |
Hi @anasimtiaz , Please find my code as below: I'm using an Array for colors "arrBarColors". And then adding colors to it based on chart Values. func loadBarChart(_ count: Int, range: Double)
Hope it helps us :) |
Thank you. That helped a lot! |
Dear all,
Can anyone help me please...!!
The text was updated successfully, but these errors were encountered: