Microsoft KB Archive/68745

{|
 * width="100%"|

PGCHART: How to Draw a Line Chart with Lines Only

 * }

Q68745

-

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/C++ for MS-DOS, version 7.0
 * Microsoft Visual C++, version 1.0

-

SUMMARY
In Microsoft C versions 6.0, 6.0a, 6.0ax, C/C++ 7.0 and Visual C/C++ 1.0 using _pg_defaultchart, you can specify a line-chart type with _PG_LINECHART. The choices for the chart style are _PG_POINTANDLINE and _PG_POINTONLY. There is no manifest constant for &quot;lines only,&quot; but a line chart with lines only can be made with a few modifications to the existing code, which produces a chart with points and lines.

MORE INFORMATION
The following code, which defines the field in the palette to be modified, is taken from page 259 of the &quot;Microsoft C Advanced Programming Techniques&quot; manual that shipped with C version 6.0.

/* Typedef for pattern bitmap */ typedef unsigned char fillmap[8]; /* Typedef for palette entry definition */ typedef struct {    unsigned short color; unsigned short style; fillmap fill; char plotchar;    /* by default, the plotted character is '*' */ } paletteentry; /* Typedef for palette definition */ typedef paletteentry palettetype[ _PG_PALETTELEN ]; The following are the modifications to be made to the sample program SCATTER.C on pages 256-258 of &quot;Microsoft C Advanced Programming Techniques&quot; (also on pages 280-281 of &quot;C For Yourself,&quot; which was shipped with QuickC version 2.5). Note that the original program produces a scatter chart; a line chart requires different arguments in the call to _pg_defaultchart, as shown below.

Declare the following variable 

  palettetype palette_struct; after the line

  _pg_initchart; but before the line:

  _pg_defaultchart( &amp;env, _PG_LINECHART, _PG_POINTANDLINE);   Get the array of current palette structures with the line:       _pg_getpalette( palette_struct );   Change the plotted character in the first palette to a blank, so that no points will appear on the graph (the line will be unbroken). For example:      palette_struct[1].plotchar = ' ';   Reset the palette with the line:       _pg_setpalette( palette_struct ); 

The following is the modified SCATTER.C program:

Sample Code
#include <conio.h>
 * 1) include <string.h>
 * 2) include <graph.h>
 * 3) include <pgchart.h>

typedef enum {FALSE, TRUE} boolean; float far value[MONTHS] = {       33.0,27.0,42.0,64.0,106.0,157.0,       182.0,217.0,128.0,62.0,43.0,36.0 }; char far *category[MONTHS] = {       &quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;Jun&quot;, &quot;Jly&quot;, &quot;Aug&quot;, &quot;Sep&quot;, &quot;Oct&quot;, &quot;Nov&quot;, &quot;Dec&quot; }; palettetype palette_struct; main {       chartenv env; int mode = _VRES16COLOR;
 * 1) define MONTHS 12

if( _setvideomode( _MAXRESMODE ) == 0 ) exit( 0 ); _pg_initchart;

_pg_getpalette( palette_struct ); palette_struct[1].plotchar = ' '; _pg_setpalette( palette_struct );

_pg_defaultchart( &env, _PG_LINECHART, _PG_POINTANDLINE ); strcpy( env.maintitle.title, &quot;Good Neighbor Grocery&quot; ); env.maintitle.titlecolor = 6; env.maintitle.justify = _PG_RIGHT; strcpy( env.subtitle.title, &quot;Orange Juice vs Hot Chocolate&quot; ); env.subtitle.titlecolor = 6; env.subtitle.justify = _PG_RIGHT; strcpy( env.xaxis.axistitle.title, &quot;Months&quot; ); strcpy( env.yaxis.axistitle.title, &quot;Quantity&quot; ); env.chartwindow.border = FALSE; env.xaxis.ticinterval = 4.0;

if( _pg_chart( &env, category, value, MONTHS ) ) {               _setvideomode( _DEFAULTMODE ); _outtext( &quot;Error: can't draw chart&quot; ); }       else {               getch; _setvideomode( _DEFAULTMODE ); }       return( 0 ); } For more information about line charts, see pages 252-273 of &quot;Microsoft C Advanced Programming Techniques,&quot; and pages 267-296 of &quot;C for Yourself.&quot;

Additional query words: kbinf 6.00 6.00a 6.00ax 7.00 1.00

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT