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

Bar shapes are overlapped with other bars #2248

Closed
aravinth02 opened this issue Mar 15, 2017 · 1 comment
Closed

Bar shapes are overlapped with other bars #2248

aravinth02 opened this issue Mar 15, 2017 · 1 comment

Comments

@aravinth02
Copy link

aravinth02 commented Mar 15, 2017

When X set are continuous ordered value like the dataset provided below, each bars are getting overlapped as figure 1.

let xValues = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2]
let yValues = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]

Figure 1:

overlappedbar

But bars are not overlapped when the X values are as follows. See figure 2.
let xValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Figure 2:

non-overlapping

Following snippet was used to draw the chart data

for i in 0..<xValues.count { let dataEntry = BarChartDataEntry(x: xValues[i], y: yValues[i]) dataEntries.append(dataEntry) } let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold") let chartData = BarChartData(dataSet: chartDataSet) barChartView?.data = chartData

Please help on how to resolve the bar overlapping on first test case.

@liuxuan30
Copy link
Member

how about you zoom in your first chart or change bar width?

I think you don't think about your data first
Your x value is [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] which only has 0.1 interval, while your bar width is overwhelming - that seems like a overlap situation.
Either you change your bar width or make x axis has smaller granularity to give a try.

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

2 participants