ChartsOrg / ChartsOrg/Charts

CombinedChartView: First and last bars are shown half only

Open
#2,105 3 comments 0 reactions 0 assignees View on GitHub
★★★ bug help wanted
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I migrated my existing code to Charts 3.0.1 now and have some issues with the combined chart view (bars and lines).

After the straight forward migration my diagram looks as shown in the following picture.
![bildschirmfoto 2017-01-22 um 11 21 01](https://cloud.githubusercontent.com/assets/13385716/22181857/a9745f06-e095-11e6-973c-b2471d20caf1.png)

When I add the following lines of code in order to show the bars completely the xAxis values gets corrupted completely.

``` Swift
combChart.xAxis.granularityEnabled = true
combChart.xAxis.granularity = 1.0
combChart.xAxis.spaceMin = 0.5
combChart.xAxis.spaceMax = 0.5
combChart.xAxis.valueFormatter = self
```

![bildschirmfoto 2017-01-22 um 11 23 47](https://cloud.githubusercontent.com/assets/13385716/22181864/def6ece8-e095-11e6-9166-5c6215389b29.png)

The Strings for the xAxis values are drawn with the following lines of code.

``` Swift
public func stringForValue(_ value: Double, axis: AxisBase?) -> String
{
if Int(value) < _xValues.count {
return _xValues[Int(value)]
} else {
return ""
}
}
```

I checked the output the `stringForValue`function. But the function gets called exactly 4 times and returns the correct Strings:

```
2017.01.22 11:23:43.460 [DEBUG] [DiagramCombinedCollectionViewCell stringForValue(_:axis:)](417): xValue: 0.000000 1. Serie
2017.01.22 11:23:43.461 [DEBUG] [DiagramCombinedCollectionViewCell stringForValue(_:axis:)](417): xValue: 1.000000 2. Serie
2017.01.22 11:23:43.462 [DEBUG] [DiagramCombinedCollectionViewCell stringForValue(_:axis:)](417): xValue: 2.000000 3. Serie
2017.01.22 11:23:43.463 [DEBUG] [DiagramCombinedCollectionViewCell stringForValue(_:axis:)](417): xValue: 3.000000 4. Serie
```

Any idea whats going wrong? Or do I forget to set any relevant axis parameter?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CombinedChartView with the reported bar and xAxis settings, then trace how the xAxis values and bar boundaries are rendered. Use the provided stringForValue implementation and logged values to compare label positions with the displayed chart; done means both end bars are fully visible and the four xAxis labels remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data-visualization, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.