use of com.github.mikephil.charting.data.Entry in project carat by amplab.
the class ColumnToBarTransformer method generateTransformedValuesBarChart.
/**
* Transforms an arraylist of Entry into a float array containing the x and
* y values transformed with all matrices for the BARCHART.
*
* @param entries
* @param dataSet the dataset index
* @return
*/
public float[] generateTransformedValuesBarChart(ArrayList<? extends Entry> entries, int dataSet, BarData bd, float phaseY) {
float[] valuePoints = new float[entries.size() * 2];
int setCount = bd.getDataSetCount();
float space = bd.getGroupSpace();
for (int j = 0; j < valuePoints.length; j += 2) {
int index = j / 2;
Entry e = entries.get(index);
//TODO: Need to find a better value than 1, should be dependant on yMax, I think
float x = e.getVal() + 1;
// calculate the y-position, depending on datasetcount
float y = e.getXIndex() + (index * (setCount - 1)) + dataSet + 0.5f + space * index + space / 2f;
valuePoints[j] = x;
valuePoints[j + 1] = y;
}
pointValuesToPixel(valuePoints);
return valuePoints;
}
use of com.github.mikephil.charting.data.Entry in project carat by amplab.
the class Transformer method generateTransformedValuesLineScatter.
/**
* Transforms an arraylist of Entry into a float array containing the x and
* y values transformed with all matrices for the LINECHART or SCATTERCHART.
*
* @param entries
* @return
*/
public float[] generateTransformedValuesLineScatter(ArrayList<? extends Entry> entries, float phaseY) {
float[] valuePoints = new float[entries.size() * 2];
for (int j = 0; j < valuePoints.length; j += 2) {
Entry e = entries.get(j / 2);
if (e != null) {
valuePoints[j] = e.getXIndex();
valuePoints[j + 1] = e.getVal() * phaseY;
}
}
pointValuesToPixel(valuePoints);
return valuePoints;
}
use of com.github.mikephil.charting.data.Entry in project carat by amplab.
the class Chart method drawMarkers.
/**
* draws all MarkerViews on the highlighted positions
*/
protected void drawMarkers() {
// if there is no marker view or drawing marker is disabled
if (mMarkerView == null || !mDrawMarkerViews || !valuesToHighlight())
return;
for (int i = 0; i < mIndicesToHightlight.length; i++) {
int xIndex = mIndicesToHightlight[i].getXIndex();
int dataSetIndex = mIndicesToHightlight[i].getDataSetIndex();
if (xIndex <= mDeltaX && xIndex <= mDeltaX * mPhaseX) {
Entry e = getEntryByDataSetIndex(xIndex, dataSetIndex);
// make sure entry not null
if (e == null)
continue;
float[] pos = getMarkerPosition(e, dataSetIndex);
// check bounds
if (pos[0] < mOffsetLeft || pos[0] > getWidth() - mOffsetRight || pos[1] < mOffsetTop || pos[1] > getHeight() - mOffsetBottom)
continue;
// callbacks to update the content
mMarkerView.refreshContent(e, dataSetIndex);
// mMarkerView.measure(MeasureSpec.makeMeasureSpec(0,
// MeasureSpec.UNSPECIFIED),
// MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
// mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(),
// mMarkerView.getMeasuredHeight());
// mMarkerView.draw(mDrawCanvas, pos[0], pos[1]);
mMarkerView.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
mMarkerView.layout(0, 0, mMarkerView.getMeasuredWidth(), mMarkerView.getMeasuredHeight());
if (pos[1] - mMarkerView.getHeight() <= 0) {
float y = mMarkerView.getHeight() - pos[1];
mMarkerView.draw(mDrawCanvas, pos[0], pos[1] + y);
} else {
mMarkerView.draw(mDrawCanvas, pos[0], pos[1]);
}
}
}
}
use of com.github.mikephil.charting.data.Entry in project carat by amplab.
the class Chart method getEntriesAtIndex.
/**
* 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 ArrayList<Entry> getEntriesAtIndex(int xIndex) {
ArrayList<Entry> vals = new ArrayList<Entry>();
for (int i = 0; i < mData.getDataSetCount(); i++) {
DataSet<? extends Entry> set = mData.getDataSetByIndex(i);
Entry e = set.getEntryForXIndex(xIndex);
if (e != null) {
vals.add(e);
}
}
return vals;
}
use of com.github.mikephil.charting.data.Entry in project carat by amplab.
the class LineChart method generateLinePath.
/**
* Generates the path that is used for drawing a single line.
*
* @param entries
* @return
*/
private Path generateLinePath(ArrayList<Entry> entries) {
Path line = new Path();
line.moveTo(entries.get(0).getXIndex(), entries.get(0).getVal() * mPhaseY);
// create a new path
for (int x = 1; x < entries.size() * mPhaseX; x++) {
Entry e = entries.get(x);
line.lineTo(e.getXIndex(), e.getVal() * mPhaseY);
}
return line;
}
Aggregations