Exemple #1
0
 /**
  * Sets a custom ValueFormatter for all DataSets this data object contains.
  *
  * @param f
  */
 public void setValueFormatter(ValueFormatter f) {
   if (f == null) return;
   else {
     for (IDataSet set : mDataSets) {
       set.setValueFormatter(f);
     }
   }
 }
Exemple #2
0
  /**
   * Removes the Entry object at the given xIndex from the DataSet at the specified index. Returns
   * true if an Entry was removed, false if no Entry was found that meets the specified
   * requirements.
   *
   * @param xIndex
   * @param dataSetIndex
   * @return
   */
  public boolean removeEntry(int xIndex, int dataSetIndex) {

    if (dataSetIndex >= mDataSets.size()) return false;

    IDataSet dataSet = mDataSets.get(dataSetIndex);
    Entry e = dataSet.getEntryForXIndex(xIndex);

    if (e == null || e.getXIndex() != xIndex) return false;

    return removeEntry(e, dataSetIndex);
  }
Exemple #3
0
  /**
   * Adds an Entry to the DataSet at the specified index. Entries are added to the end of the list.
   *
   * @param e
   * @param dataSetIndex
   */
  public void addEntry(Entry e, int dataSetIndex) {

    if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) {

      IDataSet set = mDataSets.get(dataSetIndex);
      // add the entry to the dataset
      if (!set.addEntry(e)) return;

      float val = e.getVal();

      if (mYValCount == 0) {
        mYMin = val;
        mYMax = val;

        if (set.getAxisDependency() == AxisDependency.LEFT) {

          mLeftAxisMax = e.getVal();
          mLeftAxisMin = e.getVal();
        } else {
          mRightAxisMax = e.getVal();
          mRightAxisMin = e.getVal();
        }
      } else {

        if (mYMax < val) mYMax = val;
        if (mYMin > val) mYMin = val;

        if (set.getAxisDependency() == AxisDependency.LEFT) {

          if (mLeftAxisMax < e.getVal()) mLeftAxisMax = e.getVal();
          if (mLeftAxisMin > e.getVal()) mLeftAxisMin = e.getVal();
        } else {
          if (mRightAxisMax < e.getVal()) mRightAxisMax = e.getVal();
          if (mRightAxisMin > e.getVal()) mRightAxisMin = e.getVal();
        }
      }

      mYValCount += 1;

      handleEmptyAxis(getFirstLeft(), getFirstRight());

    } else {
      Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low.");
    }
  }
Exemple #4
0
  /**
   * Removes the given Entry object from the DataSet at the specified index.
   *
   * @param e
   * @param dataSetIndex
   */
  public boolean removeEntry(Entry e, int dataSetIndex) {

    // entry null, outofbounds
    if (e == null || dataSetIndex >= mDataSets.size()) return false;

    IDataSet set = mDataSets.get(dataSetIndex);

    if (set != null) {
      // remove the entry from the dataset
      boolean removed = set.removeEntry(e);

      if (removed) {
        mYValCount -= 1;

        calcMinMax(0, mYValCount);
      }

      return removed;
    } else return false;
  }
Exemple #5
0
 /**
  * Returns true if highlighting of all underlying values is enabled, false if not.
  *
  * @return
  */
 public boolean isHighlightEnabled() {
   for (IDataSet set : mDataSets) {
     if (!set.isHighlightEnabled()) return false;
   }
   return true;
 }
Exemple #6
0
 /**
  * Enables / disables highlighting values for all DataSets this data object contains. If set to
  * true, this means that values can be highlighted programmatically or by touch gesture.
  */
 public void setHighlightEnabled(boolean enabled) {
   for (IDataSet set : mDataSets) {
     set.setHighlightEnabled(enabled);
   }
 }
Exemple #7
0
 /**
  * Enables / disables drawing values (value-text) for all DataSets this data object contains.
  *
  * @param enabled
  */
 public void setDrawValues(boolean enabled) {
   for (IDataSet set : mDataSets) {
     set.setDrawValues(enabled);
   }
 }
Exemple #8
0
 /**
  * Sets the size (in dp) of the value-text for all DataSets this data object contains.
  *
  * @param size
  */
 public void setValueTextSize(float size) {
   for (IDataSet set : mDataSets) {
     set.setValueTextSize(size);
   }
 }
Exemple #9
0
 /**
  * Sets the Typeface for all value-labels for all DataSets this data object contains.
  *
  * @param tf
  */
 public void setValueTypeface(Typeface tf) {
   for (IDataSet set : mDataSets) {
     set.setValueTypeface(tf);
   }
 }
Exemple #10
0
 /**
  * Sets the color of the value-text (color in which the value-labels are drawn) for all DataSets
  * this data object contains.
  *
  * @param color
  */
 public void setValueTextColor(int color) {
   for (IDataSet set : mDataSets) {
     set.setValueTextColor(color);
   }
 }
Exemple #11
0
  /** calc minimum and maximum y value over all datasets */
  public void calcMinMax(int start, int end) {

    if (mDataSets == null || mDataSets.size() < 1) {

      mYMax = 0f;
      mYMin = 0f;
    } else {

      mYMin = Float.MAX_VALUE;
      mYMax = -Float.MAX_VALUE;

      for (int i = 0; i < mDataSets.size(); i++) {

        IDataSet set = mDataSets.get(i);
        set.calcMinMax(start, end);

        if (set.getYMin() < mYMin) mYMin = set.getYMin();

        if (set.getYMax() > mYMax) mYMax = set.getYMax();
      }

      if (mYMin == Float.MAX_VALUE) {
        mYMin = 0.f;
        mYMax = 0.f;
      }

      // left axis
      T firstLeft = getFirstLeft();

      if (firstLeft != null) {

        mLeftAxisMax = firstLeft.getYMax();
        mLeftAxisMin = firstLeft.getYMin();

        for (IDataSet dataSet : mDataSets) {
          if (dataSet.getAxisDependency() == AxisDependency.LEFT) {
            if (dataSet.getYMin() < mLeftAxisMin) mLeftAxisMin = dataSet.getYMin();

            if (dataSet.getYMax() > mLeftAxisMax) mLeftAxisMax = dataSet.getYMax();
          }
        }
      }

      // right axis
      T firstRight = getFirstRight();

      if (firstRight != null) {

        mRightAxisMax = firstRight.getYMax();
        mRightAxisMin = firstRight.getYMin();

        for (IDataSet dataSet : mDataSets) {
          if (dataSet.getAxisDependency() == AxisDependency.RIGHT) {
            if (dataSet.getYMin() < mRightAxisMin) mRightAxisMin = dataSet.getYMin();

            if (dataSet.getYMax() > mRightAxisMax) mRightAxisMax = dataSet.getYMax();
          }
        }
      }

      // in case there is only one axis, adjust the second axis
      handleEmptyAxis(firstLeft, firstRight);
    }
  }