First _pg_chartscatter Call May Not Use Specified plotchar

Last reviewed: July 17, 1997
Article ID: Q68384
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50
MS-DOS                 | OS/2       | WINDOWS
kbprg

The information in this article applies to:

  • The C Run-time (CRT), included with:

        - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
        - Microsoft C for OS/2, versions 6.0, and 6.0a
        - Microsoft C/C++ for MS-DOS, versions 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SUMMARY

In Microsoft C versions 6.0, 6.0a, 6.0ax, C/C++ version 7.0, and Visual C/C++ version 1.0, when producing scatter charts with the Presentation Graphics function _pg_chartscatter(), the first scatter chart created in a program may be drawn with the default plotting character even if a different character was specified. This usually results from calling _pg_initchart() before setting the graphics video mode with _setvideomode().

MORE INFORMATION

The problem stems from an initialization sequence for the palette that is used whenever a new video mode is set. If the call to _pg_initchart is made AFTER a call to _setvideomode(), then the palette should not be affected.

The sample program below demonstrates this problem and the workaround. The program draws two scatter charts. For the first chart, the '$' character is specified for the plotting character. For the second chart, the '#' character is the plotting character. The second chart uses the '#' character as specified, but the first chart is drawn with the '*' character, which is the default plotting character.

If the program is altered, so that the call to _pg_initchart is moved down a few lines to after the call to _setvideomode(), then the problem goes away and the first chart is drawn correctly with the '$' character.

This is expected behavior. After entering a new video mode, a call to _pg_initchart() should be made, then the palette should be changed. The current plot character is considered to be part of the palette and requires a valid video mode to be set before the palette is set.

Sample Code

/* TEST.C
   Compile line: CL test.c graphics.lib pgchart.lib  */

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

float _far x[2][5] = { 23.0F, 42.0F, 59.0F, 72.0F, 96.0F }; float _far y[2][5] = { 0.9F, 2.3F, 5.4F, 8.0F, 9.3F };

void main(void)
{
    chartenv env;
    palettetype pal;
    int i;

    /* Move the following line to after the call to _setvideomode() */
    _pg_initchart();
    if( !_setvideomode( _MAXRESMODE ) )
        exit( 1 );

    _pg_defaultchart (&env, _PG_SCATTERCHART, _PG_POINTONLY );
    strcpy( env.maintitle.title, "Scatter Test" );
    strcpy( env.xaxis.axistitle.title, "X Amount" );
    strcpy( env.yaxis.axistitle.title, "Y Amount" );

    strcpy( env.subtitle.title, "\"plotchar\" should be '$'" );
    _pg_getpalette(pal);
    for(i=0; i < _PG_PALETTELEN; i++)
        pal[i].plotchar = '$';
    _pg_setpalette(pal);
    _pg_chartscatter( &env, x[0], y[0], 5 );
    getch();
    _clearscreen( _GCLEARSCREEN );

    strcpy( env.subtitle.title, "\"plotchar\" should be '#'" );
    _pg_getpalette(pal);
    for(i=0; i < _PG_PALETTELEN; i++)
        pal[i].plotchar = '#';
    _pg_setpalette(pal);
    _pg_chartscatter( &env, x[0], y[0], 5 );
    getch();
    _clearscreen( _GCLEARSCREEN );

    _setvideomode( _DEFAULTMODE );
}


Additional reference words: kbinf 1.00 1.50 6.00 6.00a 6.00ax 7.00 pgchart
KBCategory: kbprg
KBSubcategory: CRTIss GraphicsIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.