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
bar color different for negative values #2
Comments
Unfortunately I didn't design the graph to handle negative values. I probably should've. As for the bar color, there's a delegate method so that you can set the color of each bar individually by returning the color you want it to be. |
Thanks for the reply. |
If you have a graph that is specifically just for negative values then yah, you can probably just flip some logic in the methods where it'll draw the bars going down (or still up but with negative values). But I thought you meant something like where the x-axis is in the center and you can have both positive and negative values. If you can help by reformatting the logic to be flexible for both negative and positive that'd be great. |
Thanks for the reply. |
The width of the Y label I made so that it's flexible (sort of) to whatever text is going there. Probably not the best choice for proper charting methods. Again you're totally invited to go in there and fix it up and make a Pull Request to me. The codes open to change. |
Thanks for the reply. I could fix your code but i don't understand what are the methods that you've used for y label's width and for Y values. Can you help me? |
Sure. I can try. Anyways. If you want to set your own custom widths, what you could do is create a property in SimpleBarChart.h that says something like customMaxYLabelWidth. And you can initialize it as 0 on the initWithFrame in SimpleBarChart.m. Would that help you? It'd be cool if you could branch off the current SimbleBarChart master, and then create a pull request so that we keep this up to date for everybody. |
Sorry but in reloadData i don't see _yLabelView.frame...:( |
It's in And by the way. If you're doing this just so that you can fit a larger data sets, have you tried setting incrementValue property to a large number? The incrementValue determines the increments in which the y-axis labels are calculated. For data sets un the thousands, you should set the incrementValue to 100 or more depending on the maximum value in your data set. |
Hi and thanks for the reply! Yes it works, i attach here another screenshot, but i'll try with modify _yLabelView.frame. About the values on Y-axis labels, it could be very interesting to see only some values of _values array (like the first, the third and the last).. I've tried to modify _topValue and i've seen some negative values. Can you explain me, how you assign to Y-axis label the values? |
Actually there is a known bug with that where it'll show -1.0 or something instead of 0. I think that's mainly due to the problem with floating point comparison. I tried putting in some extra logic around it but I think the way I did all this just needs to be refactored honestly. If you're willing to do it that'd be super awesome. |
What are you talking about, in this words: "Actually there is a known bug with that where it'll show -1.0 or something instead of 0. I think that's mainly due to the problem with floating point comparison. I tried putting in some extra logic around it but I think the way I did all this just needs to be refactored honestly. If you're willing to do it that'd be super awesome." |
Oh don't worry about that, I mis-read what you wrote. |
No problem! I've another question. Can i modify the frame of bar if they have a negative values? |
Absolutely, do whatever you need to do. What would be nice is if you could make the x-axis flexible so that (based on what kind of values are in the data set) it will move up and down so that it can account for negative values with bars going down from the x-axis line and bars going the usual up from the x-axis line. |
thanks for the reply,and good idea... If you see the previous image that i've uploaded, you can see that the first label is on first bar...and it could be better if the bar is under the value label... |
hmm. That would require you to do a lot of refactoring that includes positioning the start of the rectangle for each bar be at a different value for negative numbers than positive numbers. |
And I apologize that I didn't comment this code properly the first time. I'll make sure to do that from now on so that collaboration can be easier. |
Yes, you've understand my problem. Please let me know when you have commented the code... |
Hello!
My compliments for the project.
Two questions: is possible to change bar color only for negative values? How i can insert negative values for Y column?
Thanks
The text was updated successfully, but these errors were encountered: