{
    "mode": "perldoc",
    "parameter": "Chart::Manual::Methods",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Chart%3A%3AManual%3A%3AMethods/json",
    "generated": "2026-10-08T03:21:49Z",
    "sections": {
        "NAME": {
            "content": "Chart::Manual::Methods - user API\n",
            "subsections": []
        },
        "OVERVIEW": {
            "content": "This are all methods for the chart user.\n",
            "subsections": []
        },
        "ALPHABETICALLY": {
            "content": "adddatafile\nLoads all data of a chart (one or more data sets) from a file. (Works only if no data yet\nadded.) You have to either provide a filename or filehandle (OLDSCHOOL or $scalar).\n\n$graph->adddataset( 'file.tsv' );\n$graph->adddataset( $filehandle );\n$graph->adddataset( FILEHANDLE );\n\nAn optional second argument, which defaults to 'set' can change the file format if set to 'pt'.\nIn 'set' mode every row of the file content is fed to \"adddataset\", in 'pt' every row get\nloaded like via \"addpt\". In other words: 'pt' transposes the data table.\n\n$graph->adddataset( 'file.tsv', 'pt'  );\n\nThe arbitrary named text files have to contain one or several rows of numbers. The numbers need\nto be separated by spaces or tabs (\\t) (mixing allowed). Perl style comments or empty lines will\nbe ignored, but rows containing different amount of numbers will cause problems.\n\nadddataset\nAdding a list of values as one data set. That is one row in the overall data table. The first\ndata set are usually x-axis labels (domain set). Make sure all sets have the same length.\n\n$graph->adddataset(  1, 2, 3, ...  );\n$graph->adddataset( [1, 2, 3, ...] );\n\nFor instances with Points, Lines or Bars one data set is represented by a set of graphic items\n(points, bars or line) of one color.\n\naddpt\nAdds (appends) to each already existing data set one value. That is a column in the overall data\ntable. In this example it adds to set 0 the value 3, to set 1 the 6 and so forth. Make sure that\nthe list lengths matches the number of already existing data sets.\n\n$graph->addpt(  3, 6, 9, ...  );\n$graph->addpt( [3, 6, 9, ...] );\n\ncgijpeg\nCreates same JPEG image as \"jpeg\", but outputs to STDOUT. Since no file name or handle needed,\nonly the optional data argument is acceptable.\n\n$graph->cgijpeg( );\n\nmy @data = ([1, 2, 3],   # data set 0\n[3, 4, 5]);  # data set 1\n$graph->cgijpeg( \\@data );\n\ncgipng\nCreates same PNG image as \"png\", but outputs to STDOUT. Since no file name or handle needed,\nonly the optional data argument is acceptable.\n\n$graph->cgipng( );\n\nmy $data = [[1, 2, 3],   # data set 0\n[3, 4, 5] ]; # data set 1\n$graph->cgipng( $data );\n\ncleardata\nNeeds no arguments and deletes all so far added data.\n\ngetdata\nReturn all data (array of arrays) given to a graph.\n\nimagemapdump\nWhen creating a chart for web purposes by \"cgijpeg\" or \"cgipng\", you maybe want the\ninformation, where the areas of interests in the image are located, that should react to a users\nclick. (HTML tag map). These areas are bounding boxes around the drawn bars or points. You will\nget per box the values: x1, y1, x2, y2 in one array. These arrays are again in an Array holding,\nall boxes from one data set. The highest level array again holds all arrays of all data sets,\nbeginning with index 1.\n\nThis method can only be called, if the functionality is activated by setting the property:\nimagemap to 'true'.\n\n$graph->set( imagemap => 'true');\nmy $imagemap = $graph->imagemapdump();\n\nsay \"coordinates of first bar, first data set:\";\nsay for @{$imagemap->[1][0]};\n\njpeg\nCreates an JPEG image from given data and properties. Accepts a file name or a file handle (raw\nor in a SCALAR). The method closes the file handle.\n\n$graph->jpeg( 'image.jpg' );\n$graph->jpeg( $filehandle );\n$graph->jpeg( FILEHANDLE );\n\n$graph->jpeg( 'image.jpg', $data );\n$graph->jpeg( 'image.jpg', 'datafile.tsv' );\n$graph->jpeg( 'image.jpg', $filehandle );\n$graph->jpeg( 'image.jpg', FILEHANDLE );\n\nThe second, optional argument is the data in form of an array of arrays reference. This only\nworks, if there is no data already given to the object. Alternatively the data can also be\nloaded from a file, just provide the filename or filehandle (modern in SCALAR or old school).\nRead more about the file format at \"adddatafile\" and note that this method has another option\nfor loading transposed data tables.\n\nnew\nCreates a new chart object. Takes two optional arguments, which are the width and height of the\nto be produced image in pixels. Defaults for that are 400 x 300.\n\nmy $graph = Chart::Bars->new ( );\nmy $graph = Chart::Bars->new (600, 700);\n\nInstead of Bars, you can also use: Composite, Direction, ErrorBars, HorizontalBars, Lines,\nLinesPoints, Mountain, Pareto, Pie, Points, Split and StackedBars. To know more about them read\nChart::Manual::Types.\n\npng\nCreates an PNG image from given data and properties. Accepts a file name or a file handle (raw\nor in a SCALAR). The method closes the file handle.\n\n$graph->png( 'image.png' );\n$graph->png( $filehandle );\n$graph->png( FILEHANDLE );\n\n$graph->png( 'image.png', $data );\n$graph->png( 'image.png', 'datafile.tsv' );\n$graph->png( 'image.png', $filehandle );\n$graph->png( 'image.png', FILEHANDLE );\n\nThe second, optional argument is the data in form of an array of arrays reference. This only\nworks, if there is no data already given to the object. Alternatively the data can also be\nloaded from a file, just provide the filename or filehandle (modern in SCALAR or old school).\nRead more about the file format at \"adddatafile\" and note that this method has another option\nfor loading transposed data tables.\n\nscalarjpeg\nCreates same JPEG image as \"jpeg\" but returns the image binary into a variable, not to STDOUT or\na file.\n\nmy $imagebinary = $graph->scalarjpeg();\nmy $imagebinary = $graph->scalarjpeg( $data );\n\nscalarpng\nCreates same PNG image as \"png\" but returns the image binary into a variable, not to STDOUT or a\nfile.\n\nmy $imagebinary = $graph->scalarpng();\nmy $imagebinary = $graph->scalarpng( $data );\n\nset\nMethod to change one or more chart properties in hash form.\n\n$chart->set ( propertyname => 'new value', ... );\n$chart->set ( %properties );\n\nDifferent chart types react to different properties, which are all listed and explained under\nChart::Manual::Properties.\n\nCOPYRIGHT & LICENSE\nCopyright 2022 Herbert Breunung.\n\nThis program is free software; you can redistribute it and/or modify it under same terms as Perl\nitself.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Herbert Breunung, <lichtkind@cpan.org>\n",
            "subsections": []
        }
    },
    "summary": "Chart::Manual::Methods - user API",
    "flags": [],
    "examples": [],
    "see_also": []
}