Depict barchart widgets - 3

Author(s): Isabel Martín García.

This module defines predicates which depict barchart widgets. The three predicates exported by this module plot two-variable data as regular bars in a window and are similar to those exported in the genbar1 module except in that these defined in this module do not display a legend. Thus, not all the argument types are equal.

The predicates test whether the format of the arguments is correct. If one or both vectors are empty, the exception error2 will be thrown. If the vectors contain elements but are not correct, the exception error1 or error3 will be thrown, depending on the error type. error1 means that XVector and YVector do not contain the same number of elements and error3 indicates that not all the XVector elements contain a correct number of attributes .


Usage and interface

Documentation on exports

PREDICATE
barchart3(Header,BarchartTitle,XTitle,XVector,YTitle,YVector,Footer)

As we mentioned in the above paragraph, this predicate is comparable to barchart1/8 except in the XVector argument type.

Example:

barchart3('This is the header text',
  'Barchart without legend',
  'My xaxistitle',
  [['bar1'],['bar2']],
  'My yaxixtitle',
  [20,10],
  'This is the footer text').

Usage:

  • The following properties should hold at call time:
    (genbar1:header/1)Header is a text (an atom) describing the header of the graph.
    (genbar1:title/1)BarchartTitle is a text (an atom) to be used as label, usually not very long.
    (genbar1:title/1)XTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)XVector is a list of xbarelement3s.
    (genbar1:title/1)YTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)YVector is a list of yelements.
    (genbar1:footer/1)Footer is a text (an atom) describing the footer of the graph.

PREDICATE
barchart3(Header,BTitle,XTitle,XVector,YTitle,YVector,YMax,YMin,Footer)

As we mentioned, this predicate is quite similar to the barchart1/10 except in the XVector argument type, because the yielded bar chart lacks of legend.

Example:

barchart3('This is the header text',
  'Barchart without legend',
  'My xaxistitle',
  [['bar1'],['bar2']],
  'My yaxixtitle',
  30,
  5,
  [20,10],
  'This is the footer text').

Usage:

  • The following properties should hold at call time:
    (genbar1:header/1)Header is a text (an atom) describing the header of the graph.
    (genbar1:title/1)BTitle is a text (an atom) to be used as label, usually not very long.
    (genbar1:title/1)XTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)XVector is a list of xbarelement3s.
    (genbar1:title/1)YTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)YVector is a list of yelements.
    (genbar1:axis_limit/1)genbar1:axis_limit(YMax)
    (genbar1:axis_limit/1)genbar1:axis_limit(YMin)
    (genbar1:footer/1)Footer is a text (an atom) describing the footer of the graph.

PREDICATE
percentbarchart3(Header,BTitle,XTitle,XVector,YTitle,YVector,Footer)

The y axis maximum coordinate value is 100. The x axis limits are autoarrange.

Example:

percentbarchart3('This is a special barchart to represent percentages',
          'Barchart without legend',
          'My xaxistitle',
          [ ['pr1','Blue','Yellow','pattern1'],
            ['pr2','MediumTurquoise','Plum','pattern5'] ],
          'My yaxixtitle',
          [80,10],
          'This is the footer text').

Usage:

  • The following properties should hold at call time:
    (genbar1:header/1)Header is a text (an atom) describing the header of the graph.
    (genbar1:title/1)BTitle is a text (an atom) to be used as label, usually not very long.
    (genbar1:title/1)XTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)XVector is a list of xbarelement3s.
    (genbar1:title/1)YTitle is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)YVector is a list of yelements.
    (genbar1:footer/1)Footer is a text (an atom) describing the footer of the graph.

Documentation on internals

REGTYPE
xbarelement3([XValue]) :-
        atomic(XValue).
xbarelement3([XValue,ForegColor,BackgColor,StipplePattern]) :-
        atomic(XValue),
        color(ForegColor),
        color(BackgColor),
        pattern(StipplePattern).

Defines the attributes of the bar.

XValue
bar label. Although XValue values may be numbers, the will be treated as labels. Different elements with the same label will produce different bars.

ForegColor
It sets the Foreground color of the bar. Its value must be a valid color, otherwise the system will throw an exception. If the argument value is a variable, it gets instantiated to a color chosen by the library.

BackgColor
It sets the Background color of the bar. Its value must be a valid color, otherwise the system will throw an exception. If the argument value is a variable, it gets instantiated to a color chosen by the library.

SPattern
It sets the stipple of the bar. Its value must be a valid pattern, otherwise the system will throw an exception. If the argument value is a variable, it gets instantiated to a pattern chosen by the library.