File: gdc_samp1.c

package info (click to toggle)
libgdchart-gd1 0.10.1dev-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 328 kB
  • ctags: 430
  • sloc: ansic: 3,885; sh: 123; makefile: 111
file content (47 lines) | stat: -rw-r--r-- 1,797 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* GDCHART 0.10.0dev  1st CHART SAMPLE  2 Nov 2000 */
/* Copyright Bruce Verderaime 1998, 1999, 2000 */

/* writes gif file to stdout */

/* sample gdchart usage */
/* this will produce a 3D BAR chart */
/* this is suitable for use as a CGI */

/* for CGI use un-comment the "Content-Type" line */

#include <stdio.h>
 
#include "gdc.h"
#include "gdchart.h"
 
main()
{
    /* ----- set some data ----- */
//    float   a[6]  = { 0.5, 0.09, 0.6, 0.85, 0.0, 0.90 },
//            b[6]  = { 1.9, 1.3,  0.6, 0.75, 0.1, 2.0 };
    float   a[2][6]  = { { 0.5, 0.09, 0.6, 0.85, 0.0, 0.90 },
                         { 1.9, 1.3,  0.6, 0.75, 0.1, 2.0 } };

    /* ----- X labels ----- */
    char    *t[6] = { "Chicago", "New York", "L.A.", "Atlanta", "Paris, MD\n(USA) ", "London" };
    /* ----- data set colors (RGB) ----- */
    unsigned long   sc[2]    = { 0xFF8080, 0x8080FF };
 
    GDC_BGColor   = 0xFFFFFFL;                  /* backgound color (white) */
    GDC_LineColor = 0x000000L;                  /* line color      (black) */
    GDC_SetColor  = &(sc[0]);                   /* assign set colors */

//    printf( "Content-Type: image/gif\n\n" );    /* tell browser type */

                              /* ----- call the lib ----- */
    GDC_out_graph( 250, 200,      /* short       width, height */
               stdout,        /* FILE*       open FILE pointer */
               GDC_3DBAR,     /* GDC_CHART_T chart type */
               6,             /* int         number of points per data set */
               t,             /* char*[]     array of X labels */
               2,             /* int         number of data sets */
               (float*)a, NULL );             /* float[]     data set 1 */
//               b );           /*  ...        data set n */

    exit(0);
}