Bridges-C++ 3.5.0
Bridges(C++ API)
Public Member Functions | List of all members
bridges::datastructure::BarChart Class Reference

Support for drawing Bar charts. More...

#include <BarChart.h>

Inheritance diagram for bridges::datastructure::BarChart:
bridges::datastructure::DataStructure

Public Member Functions

 BarChart ()
 makes an empty BarChart More...
 
virtual const string getDStype () const override
 Get the data type. More...
 
void setTitle (std::string t)
 Set title of the plot. More...
 
std::string getTitle () const
 Get title of the plot. More...
 
void setSubTitle (const std::string &s)
 set subtitle of the plot More...
 
std::string getSubTitle () const
 get the subtitle of the plot More...
 
void setValueLabel (const std::string &vAxisName)
 Set the label for the value axis. More...
 
std::string getValueLabel () const
 Returns the label for the value axis. More...
 
void setCategoriesLabel (const std::string &cAxisName)
 Change the label for category axis. More...
 
std::string getCategoriesLabel () const
 Returns the axis label for the categories. More...
 
void setBarOrientation (const std::string &orient)
 sets the bar chart orientation More...
 
std::string getBarOrientation () const
 gets the bar chart orientation More...
 
void setTooltipSuffix (const std::string &suffix)
 sets the tooltip suffix More...
 
std::string getTooltipSuffix () const
 gets the tooltip suffix More...
 
void setCategories (const std::vector< std::string > &categories)
 set the categories for this bar chart More...
 
void addDataSeries (std::string seriesName, std::vector< double > data)
 Add a series of data. More...
 
virtual const std::string getDataStructureRepresentation () const override
 get the data structure representation as a JSON More...
 
- Public Member Functions inherited from bridges::datastructure::DataStructure
virtual ~DataStructure ()=default
 
virtual const string getDStype () const =0
 

Detailed Description

Support for drawing Bar charts.

Bar charts (https://en.wikipedia.org/wiki/Bar_chart) are used to represent categorical data as a series of rectangular bars with length proportional to the values they represent.

Series in a bar chart provides data for a number of categories (sometimes called bins). Categories are defined using setCategories() and the series are added using addDataSeries(). The series are rendered in the order in which they were added. Once a series has been added, it can not be modified.

One should always define the categories before adding data. Changing the categories after series have been added will throw exceptions; adding series with different number of values than the number of categories will throw an exception.

The Bar charts can have a title, subtitle. The charts can be horizontal or vertically oriented, using setBarOrientation().

A tooltip indicating the value of a series in a particular bin is displayed by hovering on a bar. One can append a string to the value using setTooltipSuffix() to specify units in the tooltip if desired.

See also
See tutorial on using BarChart at: https://bridgesuncc.github.io/tutorials/BarChart.html
Author
Matthew Mcquaigue, Kalpathi Subramanian, Erik Saule
Date
09/15/24 (updated)

Constructor & Destructor Documentation

◆ BarChart()

bridges::datastructure::BarChart::BarChart ( )
inline

makes an empty BarChart

Member Function Documentation

◆ addDataSeries()

void bridges::datastructure::BarChart::addDataSeries ( std::string  seriesName,
std::vector< double >  data 
)
inline

Add a series of data.

This will throw an exception if the data vector does not have the same size as the number of categories.

This will throw exceptions if two series have the same name.

Parameters
seriesNameindicates the name of the data to add
datavalues of that serie for each category

◆ getBarOrientation()

std::string bridges::datastructure::BarChart::getBarOrientation ( ) const
inline

gets the bar chart orientation

Returns
orientation (either "horizontal" or "vertical")

◆ getCategoriesLabel()

std::string bridges::datastructure::BarChart::getCategoriesLabel ( ) const
inline

Returns the axis label for the categories.

Returns
label for the categories

◆ getDataStructureRepresentation()

virtual const std::string bridges::datastructure::BarChart::getDataStructureRepresentation ( ) const
inlineoverridevirtual

get the data structure representation as a JSON

This is an internal function to BRIDGES. There are little reasons to call this function directly.

Implements bridges::datastructure::DataStructure.

◆ getDStype()

virtual const string bridges::datastructure::BarChart::getDStype ( ) const
inlineoverridevirtual

Get the data type.

This is an internal function to BRIDGES. There are little reasons to call this function directly.

Returns
name of the data type (used internally)

Implements bridges::datastructure::DataStructure.

◆ getSubTitle()

std::string bridges::datastructure::BarChart::getSubTitle ( ) const
inline

get the subtitle of the plot

Returns
the subtitle of the BarChart

◆ getTitle()

std::string bridges::datastructure::BarChart::getTitle ( ) const
inline

Get title of the plot.

Returns
the title of the BarChart

◆ getTooltipSuffix()

std::string bridges::datastructure::BarChart::getTooltipSuffix ( ) const
inline

gets the tooltip suffix

Returns
suffix

◆ getValueLabel()

std::string bridges::datastructure::BarChart::getValueLabel ( ) const
inline

Returns the label for the value axis.

Returns
label for the value axis

◆ setBarOrientation()

void bridges::datastructure::BarChart::setBarOrientation ( const std::string &  orient)
inline

sets the bar chart orientation

Parameters
orientcan be 'horizontal' or 'vertical'. (Throws exception on other values)

◆ setCategories()

void bridges::datastructure::BarChart::setCategories ( const std::vector< std::string > &  categories)
inline

set the categories for this bar chart

Will throw an exception if there are already data series defined.

Parameters
categoriesNames of different categories

◆ setCategoriesLabel()

void bridges::datastructure::BarChart::setCategoriesLabel ( const std::string &  cAxisName)
inline

Change the label for category axis.

Parameters
cAxisNamelabel for the category axis

◆ setSubTitle()

void bridges::datastructure::BarChart::setSubTitle ( const std::string &  s)
inline

set subtitle of the plot

Parameters
sthe subtitle of the BarChart

◆ setTitle()

void bridges::datastructure::BarChart::setTitle ( std::string  t)
inline

Set title of the plot.

Parameters
tthe title of the BarChart

◆ setTooltipSuffix()

void bridges::datastructure::BarChart::setTooltipSuffix ( const std::string &  suffix)
inline

sets the tooltip suffix

This appends a string to the values in the hover tooltip.

Parameters
suffix

◆ setValueLabel()

void bridges::datastructure::BarChart::setValueLabel ( const std::string &  vAxisName)
inline

Set the label for the value axis.

Parameters
vAxisNamelabel for the value axis

The documentation for this class was generated from the following file: