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

How to show/hide Stacked Bar Chart yValue? #3175

Closed
kuldeep13990 opened this issue Jan 12, 2018 · 2 comments
Closed

How to show/hide Stacked Bar Chart yValue? #3175

kuldeep13990 opened this issue Jan 12, 2018 · 2 comments
Assignees

Comments

@kuldeep13990
Copy link

kuldeep13990 commented Jan 12, 2018

Currently it show all values like in 1st Image but I want to show only selected bar value like 2nd image, once i deselect it value is gone.

simulator screen shot - iphone 6 - 2018-01-12 at 19 11 10

pasted image at 2018_01_13 10_45 am

I tried but not able to do this.
Please help me to achieve this.

@liuxuan30
Copy link
Member

what you have tried..? You can disable drawValues and just show value when highlighted.
either override drawHighlighted or drawValues() in bar chart renderer.

@kuldeep13990
Copy link
Author

thanks for reply.

Initially, I hide bar values using this
set1.drawValuesEnabled = NO;

when user click on any bar, I unhide draw values like this.

- (void)chartValueSelected:(ChartViewBase * __nonnull)chartView entry:(ChartDataEntry * __nonnull)entry highlight:(ChartHighlight * __nonnull)highlight {
    BarChartDataSet *data = (BarChartDataSet *)[chartView.data.dataSets objectAtIndex:highlight.dataSetIndex];
    data.drawValuesEnabled = true;
    NSLog(@"chartValueSelected, stack-index %ld", (long)highlight.stackIndex);
    
}

this code show all bar values, I want to show only selected bar value.

I hide all value like below.

- (void)chartValueNothingSelected:(ChartViewBase * __nonnull)chartView {
    BarChartDataSet *set1 = nil;
    if (_chartView.data.dataSetCount > 0) {
        for (int i =0; i<_chartView.data.dataSetCount; i++) {
            set1 = (BarChartDataSet *)_chartView.data.dataSets[i];
            set1.drawValuesEnabled = NO;
        }
    }
    NSLog(@"chartValueNothingSelected");
}

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