Hi,

I'm using the Tk::Graph module to include a bar-chart in my application, with data that can be updated by the app. My problem is that I'm getting an error when the key for the data is 0. For example:

use Tk; use Tk::Graph; $mw = MainWindow->new; my $data = { 0 => 51, 2 => 135, -2 => 124, 4 => 5 }; my $graph = $mw->Graph(-type => 'BARS', -fill => 'both', -sortnames => 'num') ->pack(-expand => 1, -fill => 'both',); $graph->set($data); # set data MainLoop();

When I run this, I get the following error: ERROR in Tk::Graph:Tk::Graph::bar #666: No Name! at [...]/5.8.5/Tk/Graph.pm line 1802.

I tried to retrace the problem to the module's code, and found that it happens in the subroutine bar, that has the following line: my $name    = shift || return error('No Name!');

As far as I understand, when the name is 0, the code goes to the error, instead of displaying the bar. Is this an expected behaviour? Am I doing something wrong?

Incidentally, are there other modules that can be used in Tk to present charts?

Thanks a lot.


In reply to Tk::Graph problem by anna_black

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.