Closed adamalbrecht closed 7 years ago
Hi Adam, thanks for pointing out. I'll change the numeric check to a is_a? Numeric
instead of casting to Float which also affects strings containing only numbers. Let me do a couple of tests to make sure it doesn't break something else, before I release a patch. Think will be able to publish the gem by end of the week.
Cheers Manuel
sorry for the delay, was quite busy the last few months.. will release a new version the next days, beta is already available.
gem install svg-graph --pre
there are some more changes, see https://github.com/lumean/svg-graph2/blob/master/History.txt Strings should no longer be autoformatted.
After I updated to the latest, I noticed that the years along the x axis in one of my graphs were now displaying as 2015.00, 2016.00, etc even though I was passing them in as strings ("2015", "2016", etc).
I think the issue is this line of code: https://github.com/lumean/svg-graph2/blob/master/lib/SVG/Graph/Graph.rb#L592
which is formatting anything that can be parsed as a float as a number with decimal places, including strings. I fixed it by setting the
number_format
option to"%g"
, but I could see other people getting tripped up by this as the default behavior. I think this is a perfectly fine default for numeric data types, but strings should probably be displayed as-is.Thanks!