Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_pg_chartms() display multiple bar, column, or line chart</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _pg_chartms()           Display multiple bar, column, or line chart

 #include   <pgchart.h>

 short _pg_chartms(env, categs, vals, nseries, n, adim, slables);
 chartenv _far *env;            Environment variable
 char _far *_far *categs;       Category variables
 float _far *vals;              Data values
 short nseries;                 Number of series
 short n;                       Number of data values
 short adim;                    Row dimension of data array
 char _far *_far *slabels;      Series labels

    _pg_chartms() displays a multiple series bar, column, or line chart;
    the type of chart displayed is as set in the environment variable
    by _pg_defaultchart(); all series have to contain the same number
    of data points, n.

    The data is taken from the two dimensional array vals; each column in
    it makes up a single series, for a total of nseries displayed series.
    In other words, the first column of vals holds the data for the first
    data series, the second column the second series, and so on. The array
    slabels holds the labels to be used to mark each series.

    To use _pg_chartms(), you must set a graphics video mode with
    _setvideomode(), initialize the presentation graphics system with
    _pg_initchart(), and set the type of chart with _pg_defaultchart(),
    which fills the environment variable env. Then you use _pg_chartms()
    to display the chart.

   Returns:     0 for success; nonzero otherwise.

   Notes:       Note that adim must be greater than or equal to n
                and the column dimension in the array must be greater
                than or equal to nseries.

   Portability: MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                compatibles.

   -------------------------------- Example ---------------------------------

    This program puts a variety of Presentation Graphics charts on the
    screen.

    #include <conio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <graph.h>
    #include <pgchart.h>

    float _far my2data[2][4] = {{45.0,  52.0,  61.0,   35.0},
                                {53.0,  41.0,  41.0,   43.0}};
    char  _far *months[4] =  {"April",  "May", "June", "July"};
    char  _far *nations[2] = { "USA", "USSR" };
    float _far my1data[4] =    {45.0,  52.0,  61.0,   35.0};
    float _far Peanuts[4]  = {123.0, 134.0, 432.0, 345.0};
    float _far Soybeans[4] = {322.0, 321.0, 524.0, 331.0};
    char  _far *catgs[4] = { "USA", "UK", "USSR", "DDR" };
    short _far explode[5] = {0, 0, 1, 0, 0 };

    void main()
    {
        fillmap myfil = { 0x99, 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC };
            palettetype mypal;
        styleset mystyle;
        chartenv myenv;

        _setvideomode(_MAXRESMODE); /* Set style */
        _pg_initchart();
        _pg_getstyleset(mystyle);
        mystyle[1] = 0x5050;
        _pg_setstyleset(mystyle);
        _pg_defaultchart(&myenv, _PG_BARCHART, _PG_PLAINBARS);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartms(&myenv,months,(float _far *)my2data,2,4,4,nations);
        getch();

        _pg_getpalette(mypal);      /* Set palette */
        memcpy(mypal[1].fill, myfil, 8);
        mypal[1].plotchar = 16;
        mypal[1].color = 3;
        mypal[1].style = 0x5A5A;
        _pg_setpalette(mypal);

        _pg_defaultchart(&myenv, _PG_LINECHART, _PG_POINTANDLINE);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartms(&myenv,months,(float _far *)my2data,2,4,4,nations);
        _pg_hlabelchart(&myenv, (short)(myenv.chartwindow.x2 * .77F),
                        (short)(myenv.chartwindow.y2 * .30F), 13, "USSR");
        _pg_vlabelchart(&myenv, (short)(myenv.chartwindow.x2 * .77F),
                        (short)(myenv.chartwindow.y2 * .50F), 12, "USA");
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_resetpalette();           /* Default palette  */
        _pg_resetstyleset();          /* Default styleset */

        _pg_defaultchart(&myenv, _PG_PIECHART, _PG_PERCENT);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chartpie(&myenv, catgs, my1data, explode, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_defaultchart(&myenv, _PG_COLUMNCHART, _PG_PLAINBARS);
        strcpy(myenv.maintitle.title, "Soybean Consumption");
        _pg_chart(&myenv, catgs, my1data, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _pg_defaultchart (&myenv, _PG_SCATTERCHART, _PG_POINTONLY);
        strcpy(myenv.maintitle.title, "Soybeans vs. Peanuts");
        strcpy(myenv.xaxis.axistitle.title, "Peanuts");
        strcpy(myenv.yaxis.axistitle.title, "Soybeans");
        _pg_chartscatter(&myenv, Peanuts, Soybeans, 4);
        getch();
        _clearscreen(_GCLEARSCREEN);

        _setvideomode(_DEFAULTMODE);
    }


See Also: _pg_analyzechart() _pg_defaultchart() _pg_initchart()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson