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_defaultchart() initialize chart environment variable</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _pg_defaultchart()      Initialize chart environment variable

 #include   <pgchart.h>

 short _pg_defaultchart(env, charttype, chartstyle);
 chartenv _far *env;    Chart Environment Variable
 short charttype;       _PG_BARCHART     _PG_COLUMNCHART
                        _PG_LINECHART    _PG_PIECHART
                        _PG_SCATTERCHART
 short chartstyle;      Chart style; depends on chart type:
                        Bar        _PG_PLAINBARS    or  _PG_STACKEDBARS
                        Column     _PG_PLAINBARS    or  _PG_STACKEDBARS
                        Line       _PG_POINTANDLINE or  _PG_POINTONLY
                        Pie        _PG_NOPERCENT    or  _PG_PERCENT
                        Scatter    _PG_POINTANDLINE or  _PG_POINTONLY

    The _pg_defaultchart() function initializes the chart environment
    variable env; you use it to indicate what type of chart you want to
    display. The allowed types of charts, set in charttype, are:

             _PG_BARCHART  _PG_COLUMNCHART  _PG_LINECHART
                    _PG_PIECHART  _PG_SCATTERCHART

    Each type of chart also has two available styles, set in chartstyle:

    For bar charts:       _PG_PLAINBARS    or  _PG_STACKEDBARS
    For column charts:    _PG_PLAINBARS    or  _PG_STACKEDBARS
    For line charts:      _PG_POINTANDLINE or  _PG_POINTONLY
    For pie charts:       _PG_NOPERCENT    or  _PG_PERCENT
    For scatter charts:   _PG_POINTANDLINE or  _PG_POINTONLY

    After using _pg_defaultchart(), you call the corresponding presentation
    graphics function to display your chart (e.g. _pg_chartpie() or
    _pg_scatter()). In addition, note that the title fields in the
    environment variable are blanked by this call, so titles should be
    set after calling _pg_defaultchart().

    Returns:         0 for success; nonzero otherwise.

    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_getchardef() _pg_getstyleset() _pg_setchardef()

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