#include <BarChart.hpp>
Public Member Functions | |
BarChart (const Vector &data) | |
constructor takes data as a Vector note: equivalent to 1xN Matrix More... | |
BarChart (const Matrix &data) | |
constructor takes data as a Matrix More... | |
BarChart (const BarChart &other) | |
copy constructor More... | |
const Matrix & | data () const |
get data as a Matrix More... | |
void | save (const openstudio::path &path) const |
display the chart in QT More... | |
void | setColors (const std::vector< Color > &colors) |
set the colors of the bar chart if rows = 1, then colors is size of number of columns if rows > 1, then colors is size of number of rows More... | |
void | setColors (unsigned columnIndex, const std::vector< Color > &colors) |
set the colors of a given column colors is size of number of rows More... | |
void | setLegendFont (unsigned fontSize, const Font &font) |
set the font and size of the legend, use font size = 0 to hide More... | |
void | setLegendLocation (LegendLocation loc) |
set the legend location More... | |
void | setTitle (const std::string &title) |
set the title More... | |
void | setTitleFont (unsigned fontSize, const Font &font) |
set the font and size of the title, use font size = 0 to hide More... | |
void | setXLabelFont (unsigned fontSize, const Font &font) |
set the font and size of the x labels, use font size = 0 to hide More... | |
void | setXLabels (const std::vector< std::string > &xLabels) |
set the x labels, does nothing if size of xLabels does not equal number of columns More... | |
void | setYLabelFont (unsigned fontSize, const Font &font) |
set the font and size of the y labels, use font size = 0 to hide More... | |
void | setYLabels (const std::vector< std::string > &yLabels) |
set the y labels, does nothing if size of yLabels does not equal number of rows More... | |
class BarChart
Data for the chart are stored in a Matrix, with each column representing a bar and each row representing the stacked components of that bar. xLabels correspond to labels for each bar and yLabels correspond to labels for each stacked component.
If number of rows = 1, then legend displays the xLabels, there are no x tick labels, and each column gets a unique color. This is a non-stacked bar chart.
If number of rows > 1, then legend displays the yLabels, xLabels are displayed next to tick mark for each bar, and each row gets a unique color. This is a stacked bar chart.
Example usage:
Matrix data(2,2); data(0,0) = 10; // baseline electricity data(0,1) = 15; // baseline gas data(1,0) = 8; // proposed electricity data(1,1) = 11; // proposed gas
vector<std::string> xLabels(2); // which building xLabels[0] = "Baseline"; // baseline building xLabels[1] = "Proposed"; // better building
vector<std::string> yLabels(2); // fuel type yLabels[0] = "Electricity"; // baseline building yLabels[1] = "Gas"; // better building
BarChart barChart(data); barChart.setTitle("Baseline vs. Proposed Building Energy Use (GJ)"); barChart.setXLabels(xLabels); barChart.setYLabels(yLabels);
openstudio::BarChart::BarChart | ( | const Vector & | data | ) |
constructor takes data as a Vector note: equivalent to 1xN Matrix
openstudio::BarChart::BarChart | ( | const Matrix & | data | ) |
constructor takes data as a Matrix
openstudio::BarChart::BarChart | ( | const BarChart & | other | ) |
copy constructor
const Matrix& openstudio::BarChart::data | ( | ) | const |
get data as a Matrix
void openstudio::BarChart::save | ( | const openstudio::path & | path | ) | const |
display the chart in QT
save the chart to file
void openstudio::BarChart::setColors | ( | const std::vector< Color > & | colors | ) |
set the colors of the bar chart if rows = 1, then colors is size of number of columns if rows > 1, then colors is size of number of rows
void openstudio::BarChart::setColors | ( | unsigned | columnIndex, |
const std::vector< Color > & | colors | ||
) |
set the colors of a given column colors is size of number of rows
void openstudio::BarChart::setLegendFont | ( | unsigned | fontSize, |
const Font & | font | ||
) |
set the font and size of the legend, use font size = 0 to hide
void openstudio::BarChart::setLegendLocation | ( | LegendLocation | loc | ) |
set the legend location
void openstudio::BarChart::setTitle | ( | const std::string & | title | ) |
set the title
void openstudio::BarChart::setTitleFont | ( | unsigned | fontSize, |
const Font & | font | ||
) |
set the font and size of the title, use font size = 0 to hide
void openstudio::BarChart::setXLabelFont | ( | unsigned | fontSize, |
const Font & | font | ||
) |
set the font and size of the x labels, use font size = 0 to hide
void openstudio::BarChart::setXLabels | ( | const std::vector< std::string > & | xLabels | ) |
set the x labels, does nothing if size of xLabels does not equal number of columns
void openstudio::BarChart::setYLabelFont | ( | unsigned | fontSize, |
const Font & | font | ||
) |
set the font and size of the y labels, use font size = 0 to hide
void openstudio::BarChart::setYLabels | ( | const std::vector< std::string > & | yLabels | ) |
set the y labels, does nothing if size of yLabels does not equal number of rows