protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
filled.reset(); final Entry entry = dataSet.getEntryForIndex(startIndex); for (int x = startIndex + 1; x <= endIndex; x++) { currentEntry = dataSet.getEntryForIndex(x);
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Entry prev = dataSet.getEntryForIndex(mXBounds.min); Entry cur = prev; cur = dataSet.getEntryForIndex(j);
Entry prev = dataSet.getEntryForIndex(Math.max(firstIndex - 2, 0)); Entry cur = dataSet.getEntryForIndex(Math.max(firstIndex - 1, 0)); Entry next = cur; int nextIndex = -1; cur = nextIndex == j ? next : dataSet.getEntryForIndex(j); next = dataSet.getEntryForIndex(nextIndex);
Entry e = dataSet.getEntryForIndex(j); if (e == null) continue; e = dataSet.getEntryForIndex(j + 1); e1 = dataSet.getEntryForIndex(mXBounds.min); for (int x = mXBounds.min; x <= mXBounds.range + mXBounds.min; x++) { e1 = dataSet.getEntryForIndex(x == 0 ? 0 : (x - 1)); e2 = dataSet.getEntryForIndex(x);
Entry e = dataSet.getEntryForIndex(j);
continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min);
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX()+ offSet, fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX()+ offSet, fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
/** * Transforms an List of Entry into a float array containing the x and * y values transformed with all matrices for the LINECHART. * * @param data * @return */ public float[] generateTransformedValuesLine(ILineDataSet data, float phaseX, float phaseY, int min, int max) { final int count = ((int) ((max - min) * phaseX) + 1) * 2; if (valuePointsForGenerateTransformedValuesLine.length != count) { valuePointsForGenerateTransformedValuesLine = new float[count]; } float[] valuePoints = valuePointsForGenerateTransformedValuesLine; for (int j = 0; j < count; j += 2) { Entry e = data.getEntryForIndex(j / 2 + min); if (e != null) { valuePoints[j] = e.getX(); valuePoints[j + 1] = e.getY() * phaseY; } else { valuePoints[j] = 0; valuePoints[j + 1] = 0; } } getValueToPixelMatrix().mapPoints(valuePoints); return valuePoints; }
Entry prev = dataSet.getEntryForIndex(mXBounds.min); Entry cur = prev; cur = dataSet.getEntryForIndex(j);
public void addEntry(float value) { LineData data = mChart.getData(); if (data != null){ ILineDataSet set = data.getDataSetByIndex(0); // set.addEntry(...); // can be called as well if (set == null) { set = createSet(); data.addDataSet(set); } data.addEntry(new Entry(set.getEntryCount(),value),0); Log.w("anjing", set.getEntryForIndex(set.getEntryCount()-1).toString()); data.notifyDataChanged(); // let the chart know it's data has changed mChart.notifyDataSetChanged(); // limit the number of visible entries mChart.setVisibleXRangeMaximum(10); // mChart.setVisibleYRange(30, AxisDependency.LEFT); // move to the latest entry mChart.moveViewTo(set.getEntryCount()-1, data.getYMax(), YAxis.AxisDependency.LEFT); // this automatically refreshes the chart (calls invalidate()) // mChart.moveViewTo(data.getXValCount()-7, 55f, // AxisDependency.LEFT); } }
public void dynamicsUpdateOne(TimeDataModel timeDatamodel, int length) { int index = length - 1; LineData lineData = lineChart.getData(); ILineDataSet d1 = lineData.getDataSetByIndex(0); Entry e = d1.getEntryForIndex(index); d1.removeEntry(e); d1.addEntry(new Entry(index, index, (float) timeDatamodel.getNowPrice())); ILineDataSet d2 = lineData.getDataSetByIndex(1); Entry e2 = d2.getEntryForIndex(index); d2.removeEntry(e2); d2.addEntry(new Entry(index, index, (float) timeDatamodel.getAveragePrice())); BarData barData = barChart.getData(); IBarDataSet barDataSet = barData.getDataSetByIndex(0); barDataSet.removeEntry(index); barDataSet.addEntry(new BarEntry(index, index, timeDatamodel.getVolume())); lineData.notifyDataChanged(); lineChart.notifyDataSetChanged(); lineChart.moveViewToX(index); barData.notifyDataChanged(); barChart.notifyDataSetChanged(); barChart.moveViewToX(index); }
public void dynamicsUpdateOne(TimeDataModel timeDatamodel, int length) { int index = length - 1; LineData lineData = lineChart.getData(); ILineDataSet d1 = lineData.getDataSetByIndex(0); Entry e = d1.getEntryForIndex(index); d1.removeEntry(e); d1.addEntry(new Entry(index, index, (float) timeDatamodel.getNowPrice())); ILineDataSet d2 = lineData.getDataSetByIndex(1); Entry e2 = d2.getEntryForIndex(index); d2.removeEntry(e2); d2.addEntry(new Entry(index, index, (float) timeDatamodel.getAveragePrice())); BarData barData = barChart.getData(); IBarDataSet barDataSet = barData.getDataSetByIndex(0); barDataSet.removeEntry(index); barDataSet.addEntry(new BarEntry(index, index, timeDatamodel.getVolume())); lineData.notifyDataChanged(); lineChart.notifyDataSetChanged(); lineChart.moveViewToX(index); barData.notifyDataChanged(); barChart.notifyDataSetChanged(); barChart.moveViewToX(index); }