BernieC has asked for the wisdom of the Perl Monks concerning the following question:

From what I can tell, svg::tt:graph::xy can only plot a single data set. Other than that it looks great :o). Is it possible to get it to do multiple datasets {each in a different color}?

I was thinking of writing my own program to do that. Doesn't seem too hard, but a bit complicated. I can see the parameters: x-range, y-range, y-title, x-title, y hash marks, x hash marks. And with that superstructure I think it'd be relatively easy to just do SVG lines from data-point to data-point but lots of messy stuff. I hit metacpan guessing that someone had done that and tt:graph:xy seems to only handle one set of data.

Am I crazy/reinventinganoldwheel to start doing something like this just using the SVG package? Is there an existing package that I missed that could handle that?

Replies are listed 'Best First'.
Re: svg line graphs
by kcott (Archbishop) on Jan 28, 2020 at 06:49 UTC

    G'day BernieC,

    "From what I can tell, svg::tt:graph::xy can only plot a single data set."

    Assuming you're actually referring to SVG::TT::Graph::XY, what are you reading that suggests it "can only plot a single data set"?

    I've never used this module; however, a very brief reading of its documentation showed:

    • SYNOPSIS — example code adding two data sets.
    • add_data() — description includes: "... It can be called several times to add more data sets in.".
    • config methods — amongst other things, the style_sheet() subsection indicates multiple data sets with "The default stylesheet handles up to 12 data sets." and has information on using colours.

    If my assumption about SVG::TT::Graph::XY was incorrect, please provide a link to svg::tt:graph::xy; otherwise, I suggest you read the documentation more closely, as this module already appears to provide all the things you've indicated you want.

    — Ken

      Mea Culpa. I see that now. I had skimmed through the docs on metacpan and didn't notice the subtleties -- except for the quiet mention, that you found {thanks for reading more carefully than I did} in add_data and config_methods, it kinda hid the fact of the multiple data sets. All my fault for missing it, and thanks - that looks like the perfect module for what I need.
        Another wrinkle:
        Files=5, Tests=178, 1 wallclock secs ( 0.05 usr + 0.03 sys = 0.08 C +PU) Result: FAIL Failed 1/5 test programs. 0/178 subtests failed. gmake: *** [Makefile:884: test_dynamic] Error 255 LLAP/SVG-TT-Graph-1.02.tar.gz C:\STRAWB~1\c\bin\gmake.exe test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports LLAP/SVG-TT-Graph-1.02.tar.gz Stopping: 'install' failed for 'SVG::TT::Graph::XY'.
        I checked on CPAN and, indeed, there were four testers who tried to get it to run on win32 and none managed it. I can't sort out the mess from cpan-install to figure out where the problem was {but I likely wouldn't be able to fix it anyway}. sigh

        So my quest continues, i guess. Is there another package that can do what SVG::TT::Graph::XY and works with win10/64?

Re: svg line graphs
by 1nickt (Canon) on Jan 27, 2020 at 22:34 UTC

    Hi,

    I'm not sure from your question whether you are asking for something related to Template Toolkit .... but I use Chart::Clicker all the time to do graphs with multiple data sets. (I use Cairo back end fwiw.)


    The way forward always starts with a minimal test.