Next: , Previous: , Up: Chart Object   [Contents][Index]


15.8.4 Other Chart Routines

There are a number of routines to change the values in the chart and to change its behavior. To clear a chart use the routine

void fl_clear_chart(FL_OBJECT *obj);

To add an item to a chart use

void fl_add_chart_value(FL_OBJECT *obj, double val,
                        const char *text, FL_COLOR col);

Here val is the value of the item, text is the label to be associated with the item (can be empty) and col is an index into the colormap (FL_RED etc.) that is the color of this item. The chart will be redrawn each time you add an item. This might not be appropriate if you are filling a chart with values. In this case put the calls between calls of fl_freeze_form() and fl_unfreeze_form().

By default, the label is drawn in a tiny font in black. You can change the font style, size or color using the following routine

void fl_set_chart_lstyle(FL_OBJECT *obj, int fontstyle);
void fl_set_chart_lsize(FL_OBJECT *obj, int fontsize);
void fl_set_chart_lcolor(FL_OBJECT *obj, FL_COLOR color);

Note that fl_set_chart_lcolor() only affects the label color of subsequent items, not the items already created.

You can also insert a new value at a particular place using

void fl_insert_chart_value(FL_OBJECT *obj, int index,
                           double val, const char *text,
                           FL_COLOR col);

index is the index before which the new item should be inserted. The first item is number 1. So, for example, to make a strip-chart where the new value appears at the left, each time insert the new value before index 1.

To replace the value of a particular item use the routine

void fl_replace_chart_value(FL_OBJECT *obj, int index,
                            double val, const char *text,
                            FL_COLOR col);

Here index is the index of the value to be replaced. The first value has an index of 1, etc.

Normally, bar-charts and line-charts are automatically scaled in the vertical direction such that all values can be displayed. This is often not wanted when new values are added from time to time. To set the minimal and maximal value displayed use the routine

void fl_set_chart_bounds(FL_OBJECT *obj, double min, double max)'

To return to automatic scaling call it with both min and max being set to 0.0. To obtain the current bounds, use the following routine

void fl_get_chart_bounds(FL_OBJECT *obj, double *min, double *max)'

Also the width of the bars and distance between the points in a line-chart are normally scaled. To change this use

void fl_set_chart_autosize(FL_OBJECT *obj, int autosize);

with autosize being set to false (0). In this case the width of the bars will be such that the maximum number of items fits in the box. This maximal number (defaults to FL_CHART_MAX) can be changed using

void fl_set_chart_maxnumb(FL_OBJECT *obj, int maxnumb);

where maxnumb is the maximal number of items to be displayed, which may not be larger than FL_CHART_MAX.


Next: , Previous: , Up: Chart Object   [Contents][Index]