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

chartView does't overlay with dark color highlighted value in bar chart #449

Closed
cooler333 opened this issue Oct 6, 2015 · 11 comments
Closed

Comments

@cooler333
Copy link

let chartHighlight = ChartHighlight(xIndex: 0, dataSetIndex: 0, stackIndex: 0)
strongSelf.chartView.highlightValue(highlight: chartHighlight, callDelegate: true)

when bar was selected by tap all works well, but when select from code, overlay do not drown as expected

@danielgindi
Copy link
Collaborator

What do you see drawn instead?

@cooler333
Copy link
Author

Nothing. ChartView call highlight delegate method. But does not draw overlay for bar section. Color stay same

Wednesday 7 October 2015 09:55 +0300 from Daniel Cohen Gindi notifications@github.com:

What do you see drawn instead?

Reply to this email directly or view it on GitHub .

@danielgindi
Copy link
Collaborator

There may be a missing setNeedsDisplay call. I'll look into it. In the mean
time, try to add a setNeedsDisplay call.

On Wed, Oct 7, 2015 at 10:53 AM, Dmitry Coolerov notifications@github.com
wrote:

Nothing. ChartView call highlight delegate method. But does not draw
overlay for bar section. Color stay same

Wednesday 7 October 2015 09:55 +0300 from Daniel Cohen Gindi <
notifications@github.com>:

What do you see drawn instead?


Reply to this email directly or view it on GitHub .


Reply to this email directly or view it on GitHub
#449 (comment)
.

@danielgindi
Copy link
Collaborator

Well I couldn't reproduce this problem. I'm guessing your Highlight object is not configured well

@danielgindi
Copy link
Collaborator

If it's not a stacked bar chart, set stackIndex to -1 (Or use a different constructor)

@cooler333
Copy link
Author

@danielgindi i can't highlight segment on stacked bar chart without ChartRange param. But all methods which return correct ChartRange are Internal func.

let entry = dataSet.entryForXIndex(_xIndex)
let point = chartView.getPosition(entry!, axis: dataSet.axisDependency)
let chartHighlight = chartView.getHighlightByTouchPoint(point)
chartView.highlightValue(highlight: chartHighlight, callDelegate: true)

the code above doesn't allow to change yVal. Always return last(top) segment from ChartDataEntry

@cooler333
Copy link
Author

The problem in range.

let chartHighlight = ChartHighlight(xIndex: _xIndex, dataSetIndex: 0, stackIndex: _yIndex, range: ChartRange(from: ???, to: ???))

if range exist (in internal func called by gesture recogniser) chart is highlighted, but if I pass nil range nothing happens.

@cooler333
Copy link
Author

fixed:

let entry = dataSet.entryForXIndex(_xIndex) as! BarChartDataEntry

let x = Double(_xIndex)

var y = 0.0
for (var i = 0; i <= _yIndex; i++) {
    y += entry.values![i]
}

let pixel = chartView.getPixelForValue(x, y: y, axis: dataSet.axisDependency)
let chartHighlight = chartView.getHighlightByTouchPoint(pixel)
chartView.highlightValue(highlight: chartHighlight, callDelegate: true)

// _xIndex, _yIndex - private property

@danielgindi
Copy link
Collaborator

@PhilJay It seems like the stackIndex is not used at all when drawing highlights for stacked bar, but the range property. It is only used for determining a boolean of isStacked... Are you planning on "fixing" this or should the users rely on the range instead?

@liuxuan30
Copy link
Member

@danielgindi I just answered question #504 yesterday, to use stackIndex -1 to highlight the whole stacked bar, instead of the segments. Is this valid?

@raghunath44
Copy link

I want to show yValue in AnotherBarChart.This is my Code:
-(void)setUpAnotherBarViewOptions:(BarChartView *)anotherBarChart
{

anotherBarChart.descriptionText = @"";
anotherBarChart.noDataTextDescription = @"You need to provide data for the chart.";

anotherBarChart.maxVisibleValueCount = 60;
anotherBarChart.pinchZoomEnabled = NO;
anotherBarChart.drawBarShadowEnabled = NO;
anotherBarChart.drawGridBackgroundEnabled = NO;

ChartXAxis *xAxis = anotherBarChart.xAxis;
xAxis.labelPosition = XAxisLabelPositionBottom;
xAxis.spaceBetweenLabels = 0.0;
xAxis.drawGridLinesEnabled = NO;


ChartLegend *legend = anotherBarChart.legend;
legend.position = ChartLegendPositionBelowChartCenter;
legend.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:14.f];

anotherBarChart.leftAxis.drawGridLinesEnabled = NO;
anotherBarChart.rightAxis.drawGridLinesEnabled = NO;
anotherBarChart.leftAxis.enabled = NO;
anotherBarChart.rightAxis.enabled = NO;

anotherBarChart.legend.enabled = YES;    

}

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

4 participants