Beispiel #1
0
  /**
   * Get all Entry objects at the given index across all DataSets. INFORMATION: This method does
   * calculations at runtime. Do not over-use in performance critical situations.
   *
   * @param xIndex
   * @return
   */
  public List<Entry> getEntriesAtIndex(int xIndex) {

    List<Entry> vals = new ArrayList<Entry>();

    for (int i = 0; i < mData.getDataSetCount(); i++) {

      IDataSet set = mData.getDataSetByIndex(i);

      Entry e = set.getEntryForXIndex(xIndex);

      if (e != null) {
        vals.add(e);
      }
    }

    return vals;
  }
Beispiel #2
0
  /**
   * Sets a new data object for the chart. The data object contains all values and information
   * needed for displaying.
   *
   * @param data
   */
  public void setData(T data) {

    if (data == null) {
      Log.e(LOG_TAG, "Cannot set data for chart. Provided data object is null.");
      return;
    }

    // LET THE CHART KNOW THERE IS DATA
    mOffsetsCalculated = false;
    mData = data;

    // calculate how many digits are needed
    calculateFormatter(data.getYMin(), data.getYMax());

    for (IDataSet set : mData.getDataSets()) {
      if (Utils.needsDefaultFormatter(set.getValueFormatter()))
        set.setValueFormatter(mDefaultFormatter);
    }

    // let the chart know there is new data
    notifyDataSetChanged();

    if (mLogEnabled) Log.i(LOG_TAG, "Data is set.");
  }