fix zero and negative value for grouped barcharts#93
fix zero and negative value for grouped barcharts#93manuel-rubio wants to merge 3 commits intomindok:masterfrom
Conversation
|
Thanks @manuel-rubio - I'll bundle this up with a fix to move the axis to the correct spot too. |
… values for grouped barcharts
|
you're welcome, @mindok I've just refactored the code to keep it simpler. I was unable (at the moment) to localise the part where the axis line is drawn. Could you shed light on where is the code in charge of that part? |
|
Hi @manuel-rubio - I was thinking about that over the weekend. I think the simplest approach is to just draw a zero line and leave the axes as they are. This would be done in This will be pretty similar to So in axis.ex, we could have something like: |
|
@mindok two things... I changed the code based on what you suggested and it's not working: I was trying to run the tests and locally they're not working, but it's not broken because of my changes, are they working for you? |
|
Hi @manuel-rubio - the original tests rely on order of map keys (not a good idea). They broke with an upgrade of Elixir. It's on the to-do list... I'll create a gallery item for the barchart that handles the zero case and see what's going on... Could you maybe share the code that you used to generate the chart above. |
|
@manuel-rubio I made a basic bar chart with a negative value in the data based on the existing plain sample in the gallery. There are a couple of issues around labels etc that still need to be considered, and the value scale doesn't seem to reset. Issues in the sample below:
Your sample looks a lot closer - are you happy to share the code used to generate it please. If you're happy for it to appear in the docs, I'll use it as a gallery example. |
|
@mindok my code is here: https://github.com/altenwald/conta/blob/main/apps/conta/lib/conta/stats.ex#L166-L196 It's in charge of giving you the data about Profits & Losses from your accounting via Telegram. It's still under development. |
If the order isn't important you can perform a defmacro assert_lists(a, b) do
quote do
assert Enum.sort(unquote(a)) == Enum.sort(unquote(b))
end
end |
|
Any news on the status of this PR? I would really like to be able to create BarCharts with negative values |
|
Hi @Zurga - getting there - I'm moving house this week. I've got in my calendar to look early next week. |


Closes #91