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

Warnings are produced if a comma is used for the decimal part of a number #33

Open
mchehab opened this issue Nov 4, 2020 · 1 comment

Comments

@mchehab
Copy link

mchehab commented Nov 4, 2020

In US, a decimal number is represented like:
1.23
But on lots of other Countries, a comma is used:
1,23

It sounds that some part of SVG::TT:Graph package is assuming that the fractional part of the number is represented using a dot, instead of a comma.


Running with a non-US LANG environment var causes it to produce warnings:

$ LANG=pt_BR.UTF-8 ./foo.pl
Argument "67,7404935030" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "99,0516306780" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "106,1340172149" isn't numeric in numeric ge (>=) at input text line 328, <DATA> line 417.
Argument "55,9961640635" isn't numeric in numeric le (<=) at input text line 321, <DATA> line 417.
Argument "-14,6486767439" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "-119,1025451855" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "-112,2608407387" isn't numeric in numeric ge (>=) at input text line 328, <DATA> line 417.
Argument "42,3969767394" isn't numeric in numeric le (<=) at input text line 321, <DATA> line 417.
Argument "119,9999999983" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "-0,0006368616" isn't numeric in addition (+) at input text line 300, <DATA> line 417.
Argument "79,5049776395" isn't numeric in numeric ge (>=) at input text line 328, <DATA> line 417.
Argument "-89,8830269324" isn't numeric in numeric le (<=) at input text line 321, <DATA> line 417.

Running the same script with:

$ LANG=C ./foo.pl

Solves the issue.

The script used for tests is this one:

#!/usr/bin/perl
use strict;
use warnings;
use SVG::TT::Graph::Pie;

my $name = "foo.svg";

my @fields = ( "Jan",  "Feb", "Mar");
my @data_sales_02 = (12.1, 45.1, 21.1);

my $graph = SVG::TT::Graph::Pie->new({
  'height' => 500,
  'width'  => 300,
  'fields' => \@fields,
});

$graph->add_data({
  'data'  => \@data_sales_02,
  'title' => 'Sales 2002',
});

open(OUT, ">$name") or die "Cannot open $name for write: $!";
printf OUT "%s", $graph->burn();
close OUT;
@mchehab
Copy link
Author

mchehab commented Nov 4, 2020

One hack to fix it would be to add this to the script:

use POSIX qw(strtod setlocale LC_NUMERIC);
use locale;

setlocale LC_NUMERIC, "C";

Yet, it sounds that something like the above should be added somewhere inside SVG::TT::Graph.

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

1 participant