Charts: ChartMaker work wrong in a Combined Chart
Summary:
ChartMaker work wrong in a Combined Chart. CombinedChartData got a line data , a bar data, the line data highlightEnabled is NO , the bar data highlightEnabled is YES, then set a ChartMaker to Combined Chart. The maker is always reveal the line data value, even the bar data is selected in this situation.
Expected Results:
The maker is reveal the line data value when the line data selected(highlighted), reveal the bar data value when the bar data selected(highlighted).
Steps to Reproduce:
In the example project, ChartDemo
- In the CombinedChartViewController add code in func viewDidLoad
BalloonMarker *marker = [[BalloonMarker alloc] initWithColor:[UIColor colorWithWhite:180/255. alpha:1.0] font:[UIFont systemFontOfSize:12.0] insets: UIEdgeInsetsMake(8.0, 8.0, 20.0, 8.0)]; marker.minimumSize = CGSizeMake(80.f, 40.f); _chartView.marker = marker; - add code in func -(LineChartData *)generateLineData
set.highlightEnabled = NO; - add code in func -(BarChartData *)generateBarData
set.highlightEnabled = YES; - build and run
Bug in Code
when I debug for this, I found the call stack :
tapGestureRecognized in BarLineChartViewBase.swift ->
getHighlightByTouchPoint in BarLineChartViewBase.swift ->
getHighlight in ChartHighlighter.swift ->
getDataSetIndex in ChartHighlighter.swift ->
i think there is some wrong in code below
let dataSetIndex = ChartUtils.closestDataSetIndex(valsAtIndex, value: y, axis: axis)
if a chart not a combine chart , this func result dataSetIndex is right , but In a Combined Chart , dataSetIndex is wrong ,
can anybody recheck this
ps: in my Objective-c project, debug swift is so difficult , any good skills?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (12 by maintainers)
I just updated from Charts v2.2.4 to v2.2.5. With the latest version I got same problems in my App using a combine chart with bar and line data. highlightEnabled is set to false for line data and true for bar data.
Unfortunately my debugger does not work correctly with Charts. I don’t know why but I cannot get any attribute values. Outside of Charts the debugger works almost fine for Swift.
Charts crashed at the following line:
let data = dataObjects[highlight.dataIndex]in the functionpublic override func getEntryForHighlight(highlight: ChartHighlight) -> ChartDataEntry?It seems that the indexhighlight.dataIndexis out of range.Any ideas?