use of com.db.chart.model.Point in project WilliamChart by diogobernardino.
the class LineChartView method drawPoints.
/**
* Responsible for drawing points
*/
private void drawPoints(Canvas canvas, LineSet set) {
int begin = set.getBegin();
int end = set.getEnd();
Point dot;
for (int i = begin; i < end; i++) {
dot = (Point) set.getEntry(i);
if (dot.isVisible()) {
// Style dot
mStyle.mDotsPaint.setColor(dot.getColor());
mStyle.mDotsPaint.setAlpha((int) (set.getAlpha() * 255));
applyShadow(mStyle.mDotsPaint, set.getAlpha(), dot.getShadowDx(), dot.getShadowDy(), dot.getShadowRadius(), dot.getShadowColor());
// Draw dot
canvas.drawCircle(dot.getX(), dot.getY(), dot.getRadius(), mStyle.mDotsPaint);
//Draw dots stroke
if (dot.hasStroke()) {
// Style stroke
mStyle.mDotsStrokePaint.setStrokeWidth(dot.getStrokeThickness());
mStyle.mDotsStrokePaint.setColor(dot.getStrokeColor());
mStyle.mDotsStrokePaint.setAlpha((int) (set.getAlpha() * 255));
applyShadow(mStyle.mDotsStrokePaint, set.getAlpha(), dot.getShadowDx(), dot.getShadowDy(), dot.getShadowRadius(), dot.getShadowColor());
canvas.drawCircle(dot.getX(), dot.getY(), dot.getRadius(), mStyle.mDotsStrokePaint);
}
// Draw drawable
if (dot.getDrawable() != null) {
Bitmap dotsBitmap = Tools.drawableToBitmap(dot.getDrawable());
canvas.drawBitmap(dotsBitmap, dot.getX() - dotsBitmap.getWidth() / 2, dot.getY() - dotsBitmap.getHeight() / 2, mStyle.mDotsPaint);
}
}
}
}
use of com.db.chart.model.Point in project WilliamChart by diogobernardino.
the class LineCardTwo method show.
@Override
public void show(Runnable action) {
super.show(action);
LineSet dataset = new LineSet(mLabels, mValues[0]);
dataset.setColor(Color.parseColor("#004f7f")).setThickness(Tools.fromDpToPx(3)).setSmooth(true).beginAt(4).endAt(36);
for (int i = 0; i < mLabels.length; i += 5) {
Point point = (Point) dataset.getEntry(i);
point.setColor(Color.parseColor("#ffffff"));
point.setStrokeColor(Color.parseColor("#0290c3"));
if (i == 30 || i == 10)
point.setRadius(Tools.fromDpToPx(6));
}
mChart.addData(dataset);
Paint thresPaint = new Paint();
thresPaint.setColor(Color.parseColor("#0079ae"));
thresPaint.setStyle(Paint.Style.STROKE);
thresPaint.setAntiAlias(true);
thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
thresPaint.setPathEffect(new DashPathEffect(new float[] { 10, 10 }, 0));
Paint gridPaint = new Paint();
gridPaint.setColor(Color.parseColor("#ffffff"));
gridPaint.setStyle(Paint.Style.STROKE);
gridPaint.setAntiAlias(true);
gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
mChart.setBorderSpacing(Tools.fromDpToPx(0)).setXLabels(AxisRenderer.LabelPosition.OUTSIDE).setLabelsColor(Color.parseColor("#304a00")).setYLabels(AxisRenderer.LabelPosition.NONE).setXAxis(false).setYAxis(false).setGrid(0, 7, gridPaint).setValueThreshold(80f, 80f, thresPaint).setAxisBorderValues(0, 110);
Animation anim = new Animation().setStartPoint(0, .5f).setEndAction(action);
mChart.show(anim);
}
use of com.db.chart.model.Point in project WilliamChart by diogobernardino.
the class LineFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.fragment_line, container, false);
mChart = (LineChartView) layout.findViewById(R.id.chart);
mFirstStage = true;
layout.setOnClickListener(this);
mChart.setOnClickListener(this);
LineSet dataset = new LineSet(mLabels, mValues[0]);
dataset.setColor(Color.parseColor("#004f7f")).setThickness(Tools.fromDpToPx(3)).setSmooth(true).beginAt(4).endAt(36);
for (int i = 0; i < mLabels.length; i += 5) {
Point point = (Point) dataset.getEntry(i);
point.setColor(Color.parseColor("#ffffff"));
point.setStrokeColor(Color.parseColor("#0290c3"));
if (i == 30 || i == 10)
point.setRadius(Tools.fromDpToPx(6));
}
mChart.addData(dataset);
Paint thresPaint = new Paint();
thresPaint.setColor(Color.parseColor("#0079ae"));
thresPaint.setStyle(Paint.Style.STROKE);
thresPaint.setAntiAlias(true);
thresPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
thresPaint.setPathEffect(new DashPathEffect(new float[] { 10, 10 }, 0));
Paint gridPaint = new Paint();
gridPaint.setColor(Color.parseColor("#ffffff"));
gridPaint.setStyle(Paint.Style.STROKE);
gridPaint.setAntiAlias(true);
gridPaint.setStrokeWidth(Tools.fromDpToPx(.75f));
mChart.setBorderSpacing(Tools.fromDpToPx(0)).setXLabels(AxisRenderer.LabelPosition.OUTSIDE).setLabelsColor(Color.parseColor("#304a00")).setYLabels(AxisRenderer.LabelPosition.NONE).setXAxis(false).setYAxis(false).setGrid(ChartView.GridType.VERTICAL, 1, 7, gridPaint).setValueThreshold(80f, 80f, thresPaint).setAxisBorderValues(0, 110);
mChart.show(new Animation().setStartPoint(0, .5f));
return layout;
}
Aggregations