PtBarGraph

Gamma/Photon: Using Gamma™ with the Photon microGUIŽ, Version 4.0
Prev |  | Next

# `PtBarGraph`

`PtBarGraph` -- A bar graph.

## Synopsis

    class PtBarGraph PtBasic
    {
        bargraph_base;          // short
        bargraph_color;         // color array
        bargraph_data;          // bar data array
        bargraph_depth;         // short
        bargraph_flags;         // flag
        bargraph_grid_color;    // color
        bargraph_grid_horiz;    // short
        bargraph_grid_vert;     // short
        bargraph_max;           // short
        bargraph_min;           // short
    }

## Base Classes

`PtWidget` <-- `PtBasic` <-- `PtBarGraph`

## Description

This widget creates a bar graph from a data array. It features an adjustable baseline, user-assigned bar colors, and an optional grid. The bars automatically adjust their width to fill the width of the widget.

| This widget does not appear in the Photon documentation.

## Instance Variables

bargraph_base

  A number specifying a baseline for the graph display. Any `bargraph_data` value lower than the baseline value will display a bar going down from the baseline, while any `bargraph_data` value greater than the baseline will display a bar going up from the baseline. The default baseline is 0.

bargraph_color

  An array of numbers specifying colors for each value in `bargraph_data`. The default color is red, but if at least one color is assigned, Gamma chooses among several shades of blue, grey and black for the remaining colors.

bargraph_data

  An array of numbers corresponding to the data to be graphed.

bargraph_depth

  An integer specifying the depth of the highlighted border to give to each bar. Default is `0`.

bargraph_flags

  Flags that allow you to specify various options, of which only one is currently available.

  This instance variable may be a combination of zero or more of the following flags:

  Constant | Description
  --- | ---
  `Pt_BARGRAPH_GRID` | Puts a grid on the bargraph. Default is ON.

bargraph_grid_color

  An integer specifying the color of the grid lines, displayed if the `Pt_BARGRAPH_GRID` flag is set on the `bargraph_flags` variable. Default is `0x606060` (dark grey).

bargraph_grid_horiz

  An integer specifying the number of horizontal grid lines if a grid is to be displayed. Default is `6`.

bargraph_grid_vert

  An integer specifying the number of vertical grid lines if a grid is to be displayed. Default is `6`.

bargraph_max

  An integer specifying the maximum value for the graph. Bars for numbers above this value will be truncated at the top of the graph. The highest allowable value is 32,767, which is also the default.

bargraph_min

  An integer specifying the minimum value for the graph. Bars for numbers below this range will be truncated at the bottom of the graph. The lowest allowable value is -32,768, which is also the default.

## Example

This example, `ex_PtBarGraph.g`, is included in the `gamma_ph_`#`_examples_1_QNX4.tgz` file available on the Cogent Web Site.

    #!/usr/cogent/bin/phgamma

    /*
     * This example demonstrates a PtBarGraph, using data with steadily
     * decreasing values. The baseline is set to -50, and green_tinted colors
     * have been specified for all the positive numbers.  The 39 horizontal
     * grid lines divide the graph into 40 equal horizontal sections, while
     * the 8 vertical gridlines make 9 equal vertical sections.
     */
    require_lisp("PhotonWidgets.lsp");
    PtInit(nil);

    win = new(PtWindow);
    win.SetDim (325,325);

    bgf = new(PtBarGraph);
    bgf.SetArea (10,10,300,300);
    bgf.fill_color = 0xaabfaa;
    bgf.bargraph_base = -50;
    bgf.bargraph_color = array(0xcceecc, 0xaaeeaa, 0x77ee77, 0x55ee55);
    bgf.bargraph_data = array(150,100,50,25,0,-25,-50,-100,-150);
    bgf.bargraph_depth = 3;
    bgf.bargraph_flags = Pt_BARGRAPH_GRID;
    bgf.bargraph_grid_color = 0x00aaff;
    bgf.bargraph_grid_horiz = 8;
    bgf.bargraph_grid_vert = 39;
    bgf.bargraph_max = 200;
    bgf.bargraph_min = -200;

    princ(hex(bgf.bargraph_max),"\n");
    princ(bgf.bargraph_min,"\n");

    PtRealizeWidget(win);
    PtMainLoop();

Prev | Home | Next
`PtArc` | Up | `PtBasic`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.