Skip to content
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

Plotting the bar from top to bottom (in reverse manner) #3125

Closed
aravinth02 opened this issue Dec 21, 2017 · 4 comments
Closed

Plotting the bar from top to bottom (in reverse manner) #3125

aravinth02 opened this issue Dec 21, 2017 · 4 comments

Comments

@aravinth02
Copy link

Currently, in Horizontal bar chart, all bars are rendered from bottom to top ,i.e, first bar entry starts from bottom of the view. I need to plot the horizontal-bar from top to bottom along the x-axis.

Is there any way to change or reverse the rendering flow along x-axis ?

Current horizontal bar image

screen shot 2017-12-21 at 12 59 35 pm

Expected one as follows

screen shot 2017-12-21 at 12 59 56 pm

Any suggestions

Thanks !!!

@aravinth02 aravinth02 changed the title Reverse plotting the bar from top to bottom Plotting the bar from top to bottom (in reverse manner) Dec 21, 2017
@aravinth02
Copy link
Author

Any idea on plotting the bar reverse flow ? And interactions like zoom/pan ?

Thanks in advance !!

@jjatie
Copy link
Collaborator

jjatie commented Jan 3, 2018

Please provide your code sample.

@aravinth02
Copy link
Author

aravinth02 commented Jan 4, 2018

@jjatie

var barChartView:HorizontalBarChartView = = HorizontalBarChartView(frame: self.view.bounds)
barChartView.xAxis.labelRotationAngle = 0
barChartView.leftAxis.enabled = false
barChartView.rightAxis.enabled = true
barChartView.xAxis.wordWrapEnabled = true
barChartView.xAxis.labelPosition = .bottom
barChartView.xAxis.granularityEnabled = true
barChartView.xAxis.granularity = 1.0
barChartView.xAxis.labelCount = 5
        
let count = 20
let range = 54
var dataEntries1: [BarChartDataEntry] = []

for i in 0..<count {
    
    let lab = "Item " + String(Double(i+1))

    let val1 = arc4random_uniform(UInt32(range)) + 3    
    dataEntries1.append(BarChartDataEntry(y: Double(val1),data:lab as AnyObject))         
}
        
let set1:BarChartDataSet = BarChartDataSet(values: dataEntries1, label: "Set1")
set1.colors = [ChartColorTemplates.myColor()[6]]
set1.axisDependency = .right

let chartData = BarChartData(dataSet: set1)
chartData.barWidth = 0.6
    
barChartView.data = chartData

barChartView.animate(xAxisDuration: 1.0, yAxisDuration: 1.0)

By default, chart plots the bar data from viewport content bottom to content top. But i wanted to render the bars from viewport content top to content bottom .

Thanks

@liuxuan30
Copy link
Member

just reorgnize the order you add them, like using a sort. The order is fixed so far, so you have to do it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants