use of com.github.mikephil.charting.data.LineDataSet in project carat by amplab.
the class LineChart method drawAdditional.
/**
* draws the circle value indicators
*/
@Override
protected void drawAdditional() {
mRenderPaint.setStyle(Paint.Style.FILL);
ArrayList<LineDataSet> dataSets = mData.getDataSets();
for (int i = 0; i < mData.getDataSetCount(); i++) {
LineDataSet dataSet = dataSets.get(i);
// if drawing circles is enabled for this dataset
if (dataSet.isDrawCirclesEnabled()) {
ArrayList<Entry> entries = dataSet.getYVals();
float[] positions = mTrans.generateTransformedValuesLineScatter(entries, mPhaseY);
for (int j = 0; j < positions.length * mPhaseX; j += 2) {
// Set the color for the currently drawn value. If the index
// is
// out of bounds, reuse colors.
mRenderPaint.setColor(dataSet.getCircleColor(j / 2));
if (isOffContentRight(positions[j]))
break;
// bounds
if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))
continue;
mDrawCanvas.drawCircle(positions[j], positions[j + 1], dataSet.getCircleSize(), mRenderPaint);
mDrawCanvas.drawCircle(positions[j], positions[j + 1], dataSet.getCircleSize() / 2f, mCirclePaintInner);
}
}
// else do nothing
}
}
use of com.github.mikephil.charting.data.LineDataSet in project carat by amplab.
the class LineChart method drawValues.
@Override
protected void drawValues() {
// if values are drawn
if (mDrawYValues && mData.getYValCount() < mMaxVisibleCount * mTrans.getScaleX()) {
ArrayList<LineDataSet> dataSets = mData.getDataSets();
for (int i = 0; i < mData.getDataSetCount(); i++) {
LineDataSet dataSet = dataSets.get(i);
// make sure the values do not interfear with the circles
int valOffset = (int) (dataSet.getCircleSize() * 1.75f);
if (!dataSet.isDrawCirclesEnabled())
valOffset = valOffset / 2;
ArrayList<Entry> entries = dataSet.getYVals();
float[] positions = mTrans.generateTransformedValuesLineScatter(entries, mPhaseY);
for (int j = 0; j < positions.length * mPhaseX; j += 2) {
if (isOffContentRight(positions[j]))
break;
if (isOffContentLeft(positions[j]) || isOffContentTop(positions[j + 1]) || isOffContentBottom(positions[j + 1]))
continue;
float val = entries.get(j / 2).getVal();
if (mDrawUnitInChart) {
mDrawCanvas.drawText(mValueFormatter.getFormattedValue(val) + mUnit, positions[j], positions[j + 1] - valOffset, mValuePaint);
} else {
mDrawCanvas.drawText(mValueFormatter.getFormattedValue(val), positions[j], positions[j + 1] - valOffset, mValuePaint);
}
}
}
}
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class CombinedChartActivity method generateLineData.
private LineData generateLineData() {
LineData d = new LineData();
ArrayList<Entry> entries = new ArrayList<Entry>();
for (int index = 0; index < itemcount; index++) entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
LineDataSet set = new LineDataSet(entries, "Line DataSet");
set.setColor(Color.rgb(240, 238, 70));
set.setLineWidth(2.5f);
set.setCircleColor(Color.rgb(240, 238, 70));
set.setCircleRadius(5f);
set.setFillColor(Color.rgb(240, 238, 70));
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set.setDrawValues(true);
set.setValueTextSize(10f);
set.setValueTextColor(Color.rgb(240, 238, 70));
set.setAxisDependency(YAxis.AxisDependency.LEFT);
d.addDataSet(set);
return d;
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class CubicLineChartActivity method setData.
private void setData(int count, float range) {
ArrayList<Entry> yVals = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
// + (float)
float val = (float) (Math.random() * mult) + 20;
// ((mult *
// 0.1) / 10);
yVals.add(new Entry(i, val));
}
LineDataSet set1;
if (mChart.getData() != null && mChart.getData().getDataSetCount() > 0) {
set1 = (LineDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
// create a dataset and give it a type
set1 = new LineDataSet(yVals, "DataSet 1");
set1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
set1.setCubicIntensity(0.2f);
//set1.setDrawFilled(true);
set1.setDrawCircles(false);
set1.setLineWidth(1.8f);
set1.setCircleRadius(4f);
set1.setCircleColor(Color.WHITE);
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setColor(Color.WHITE);
set1.setFillColor(Color.WHITE);
set1.setFillAlpha(100);
set1.setDrawHorizontalHighlightIndicator(false);
set1.setFillFormatter(new IFillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return -10;
}
});
// create a data object with the datasets
LineData data = new LineData(set1);
data.setValueTypeface(mTfLight);
data.setValueTextSize(9f);
data.setDrawValues(false);
// set data
mChart.setData(data);
}
}
use of com.github.mikephil.charting.data.LineDataSet in project MPAndroidChart by PhilJay.
the class DynamicalAddingActivity method createSet.
private LineDataSet createSet() {
LineDataSet set = new LineDataSet(null, "DataSet 1");
set.setLineWidth(2.5f);
set.setCircleRadius(4.5f);
set.setColor(Color.rgb(240, 99, 99));
set.setCircleColor(Color.rgb(240, 99, 99));
set.setHighLightColor(Color.rgb(190, 190, 190));
set.setAxisDependency(AxisDependency.LEFT);
set.setValueTextSize(10f);
return set;
}
Aggregations