#include "Chart.hpp"

Chart::Chart() {
  //
}

Chart::~Chart() {
  //
}

void Chart::AddDataElement(DataElement* pDataElement) {
  vDataElements.push_back(pDataElement);
}

std::vector<DataElement*> Chart::GetDataElements() {
  return vDataElements;
}

void Chart::AddAxis(Axis* pAxis) {
  vAxes.push_back(pAxis);
}

std::vector<Axis*> Chart::GetAxes() {
  return vAxes;
}

void Chart::AddGridLine(GridLine* pGridLine) {
  vGridLines.push_back(pGridLine);
}

std::vector<GridLine*> Chart::GetGridLines() {
  return vGridLines;
}

void Chart::AddLabel(Label* pLabel) {
  vLabels.push_back(pLabel);
}

std::vector<Label*> Chart::GetLabels() {
  return vLabels;
}

DataSet* Chart::GetDataSet() {
  return pDataSet;
}

DataElement* Chart::GetConnectedDataElement(DataEntry* pDataEntry) {
  for (unsigned int i = 0; i < vDataElements.size(); i++) {
    DataElement* pCurrentDataElement = vDataElements.at(i);

    if (pCurrentDataElement->GetDataEntry() == pDataEntry) {
      return pCurrentDataElement;
    }
  }

  return NULL;
}

double Chart::GetHighestVisibleValue() {
  double dHighestValue = 0.0;

  for (unsigned int i = 0; i < vVisibleDataEntries.size(); i++) {
    double dValue = vVisibleDataEntries.at(i)->GetValue();

    if (dValue > dHighestValue) {
      dHighestValue = dValue;
    }
  }

  return dHighestValue;
}