Depict barchart widgets - 4

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 genbar2 module except in that those defined in this module doesn't display a legend. Thus, the user does not have to define legend element names.

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 contains 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
barchart4(Header,BarchartTitle,XTitle,XVector,YTitle,YVector,Footer)

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

Example:

barchart4('This is the header text',
  'Barchart without legend',
  'My xaxistitle',
  [[2],[5],[6]],
  'My yaxixtitle',
  [20,10,59],
  'Numeric values in the xaxis').

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 xbarelement4s.
    (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
barchart4(Hder,BT,XT,XVector,XMax,XMin,YT,YVector,YMax,YMin,Fter)

As we stated before, this predicate is quite similar to barchart2/10 except in the following aspects:

  • The XVector argument type, because the yielded bar chart lacks the legend.

  • The user can set limits for both x axis and y axis.

Example:

barchart4('This is the header text, you can write a graph description',
  'Barchart without legend',
  'My xaxistitle',
  [[2,'Blue','Yellow','pattern1'],
       [20,'MediumTurquoise','Plum','pattern5'],
       [30,'MediumTurquoise','Green','pattern5']],
  50,
  -10,
  'My yaxixtitle',
  [20,10,59],
  100,
  -10,
  'Numeric values in the xaxis').

Usage:

  • The following properties should hold at call time:
    (genbar1:header/1)Hder is a text (an atom) describing the header of the graph.
    (genbar1:title/1)BT is a text (an atom) to be used as label, usually not very long.
    (genbar1:title/1)XT is a text (an atom) to be used as label, usually not very long.
    (basic_props:list/2)XVector is a list of xbarelement4s.
    (genbar1:axis_limit/1)genbar1:axis_limit(XMax)
    (genbar1:axis_limit/1)genbar1:axis_limit(XMin)
    (genbar1:title/1)YT 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)Fter is a text (an atom) describing the footer of the graph.

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

The y axis maximum coordinate value is 100. The x axis limits are automatically worked out. This predicate is useful when the bar height represents percentages.

Example:

percentbarchart4('This is the header text',
  'Barchart without legend',
  'My xaxistitle',
  [[2,'Blue','Yellow','pattern1'],[5,'Yellow','Plum','pattern5'],
       [6,'MediumTurquoise','Green','pattern5']],
  'My yaxixtitle',
  [20,10,59],
  'Numeric values in the xaxis').

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 xbarelement4s.
    (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
Defines the attributes of the bar.

XValue
x-coordinate position of the bar. Different elements with the same abscissas will produce overlapped 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.