Open Hermanverschooten opened 8 months ago
Thanks @Hermanverschooten - I'll take a look. I think the way the x-axis is drawn may require a bit of code shuffling to solve this.
I experience the same problem, while I was expecting the graph to do this: It was doing this:
As far as I can see... in addition to 0 being 0, the negative numbers are linked to a minimum as you can see in my previous message, I think it's starting here:
https://github.com/mindok/contex/blob/master/lib/chart/barchart.ex#L507-L513
It could be changed for this code:
scale_zero = Scale.domain_to_range(scale, 0.0)
results =
Enum.reduce(series_values, [], fn data_val, points ->
range_val = Scale.domain_to_range(scale, data_val)
cond do
data_val != 0 ->
[{scale_zero, range_val} | points]
:else ->
[{scale_zero, scale_zero} | points]
end
end)
And it worked for me:
I just made my first grouped BarChart and I immediately noticed an oddity. I have 2 series and I had 1 value in a serie that was below 0. This causes all the bars that are 0 to display a bar from the bottom up to 0.
In a regular barchart, 0 would always be the baseline and the negative would be shown below it.