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

StackedBarChart Value on middle of each stacked bar chart #3162

Closed
avjiang opened this issue Jan 8, 2018 · 4 comments
Closed

StackedBarChart Value on middle of each stacked bar chart #3162

avjiang opened this issue Jan 8, 2018 · 4 comments

Comments

@avjiang
Copy link

avjiang commented Jan 8, 2018

Hi, very great library!

Btw, how can I set the chart value position on the middle of it?

i try to dig and found this code, but i dont know how to make it appear on the middle of the each barchart. Currently, the value will be displayed on the top of the chart (still inside the chart)

barChartView.drawValueAboveBarEnabled = false

               if dataSet.isDrawValuesEnabled
                        {
                            drawValue(
                                    context: context,
                                    value: formatter.stringForValue(
                                        e.y,
                                        entry: e,
                                        dataSetIndex: dataSetIndex,
                                        viewPortHandler: viewPortHandler),
                                    xPos: x,
                                    yPos: y,
                                    font: valueFont,
                                    align: .center,
                                    color: dataSet.valueTextColorAt(index))
                        }
@avjiang avjiang changed the title Stacked bar chart on tap Stacked bar chart's value on tap Jan 8, 2018
@avjiang avjiang changed the title Stacked bar chart's value on tap BarChart Value on middle of chart Jan 8, 2018
@avjiang avjiang changed the title BarChart Value on middle of chart StackedBarChart Value on middle of each stacked bar chart Jan 8, 2018
@jjatie
Copy link
Collaborator

jjatie commented Jan 8, 2018

To clarify, are you asking how to draw a bar's value label in the middle of the bar OR are you asking how to draw all the value labels in the middle of the chart?

@avjiang
Copy link
Author

avjiang commented Jan 9, 2018

hi, what I mean is how to draw a bar's value label in the middle of a bar. so if there is 5 bars in 1 bar chart, the value of 5 bars will be drawn in the middle of each bar. thanks!

@jjatie
Copy link
Collaborator

jjatie commented Jan 11, 2018

@liuxuan30 ?

@liuxuan30
Copy link
Member

I think you already found the right place to override. Just pass the desired y position to draw the labels. use barRect calculation to calculate where is your half bar y position.

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

3 participants