public Number getEdgeYStart(int index) { return startSeries.getY(index); }
public Number getEdgeYStart(int index) { return startSeries.getY(index); }
public Number getEdgeYEnd(int index) { return endSeries.getY(index); }
public Number getEdgeYEnd(int index) { return endSeries.getY(index); }
/** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The value (possibly <code>null</code>). */ public Number getY(int series, int index) { XYSeries s = (XYSeries) this.data.get(series); return s.getY(index); }
/** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The value (possibly {@code null}). */ @Override public Number getY(int series, int index) { XYSeries s = (XYSeries) this.data.get(series); return s.getY(index); }
/** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The y-value for the specified series and item (possibly * <code>null</code>). */ public Number getY(int series, int index) { XYSeries s = (XYSeries) this.data.get(series); return s.getY(index); }
/** * Returns the y-value for the specified series and item. * * @param series the series (zero-based index). * @param index the index of the item of interest (zero-based). * * @return The y-value for the specified series and item (possibly * {@code null}). */ @Override public Number getY(int series, int index) { XYSeries s = (XYSeries) this.data.get(series); return s.getY(index); }
series1.setPointLabeler(new PointLabeler() { DecimalFormat df = new DecimalFormat("###.###"); @Override public String getLabel(XYSeries series, int index) { return df.format(series.getY(index)); } });
protected void drawChartValuesText(Canvas canvas, XYSeries series, SimpleSeriesRenderer renderer, Paint paint, List<Float> points, int seriesIndex, int startIndex) { int seriesNr = mDataset.getSeriesCount(); int length = points.size(); float halfDiffX = getHalfDiffX(points, length, seriesNr); for (int i = 0; i < length; i += 2) { int index = startIndex + i / 2; double value = series.getY(index); if (!isNullValue(value)) { float x = points.get(i); if (mType == Type.DEFAULT) { x += seriesIndex * 2 * halfDiffX - (seriesNr - 1.5f) * halfDiffX; } if (value >= 0) { drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1) - renderer.getChartValuesSpacing(), paint, 90); //Initially 90 was 0 you can change it according to your requirement } else { drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1) + renderer.getChartValuesTextSize() + renderer.getChartValuesSpacing() - 3, paint, 90); //Initially 90 was 0 you can change it according to your requirement } } } }
/** * Returns {@code true} if all the y-values for the specified x-value * are {@code null} and {@code false} otherwise. * * @param x the x-value. * * @return A boolean. */ protected boolean canPrune(Number x) { for (int s = 0; s < this.data.size(); s++) { XYSeries series = (XYSeries) this.data.get(s); if (series.getY(series.indexOf(x)) != null) { return false; } } return true; }
/** * Returns <code>true</code> if all the y-values for the specified x-value * are <code>null</code> and <code>false</code> otherwise. * * @param x the x-value. * * @return A boolean. */ protected boolean canPrune(Number x) { for (int s = 0; s < this.data.size(); s++) { XYSeries series = (XYSeries) this.data.get(s); if (series.getY(series.indexOf(x)) != null) { return false; } } return true; }
/** * Converts an XYSeries into CSV "x,y,x,y..." format. * @param series The series to be converted. * @return CSV formatted version of series. */ String toCsv(XYSeries series) { StringBuffer output = new StringBuffer(); for(int i = 0; i < series.size(); i++) { output.append(series.getX(i).toString()); output.append(','); output.append(series.getY(i)).toString(); } return output.toString(); }
if (Math.abs(points.get(2) - points.get(0)) > renderer.getDisplayChartValuesDistance() || Math.abs(points.get(3) - points.get(1)) > renderer.getDisplayChartValuesDistance()) { drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex)), points.get(0), points.get(1) - renderer.getChartValuesSpacing(), paint, 0); drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + 1)), points.get(2), points.get(3) - renderer.getChartValuesSpacing(), paint, 0); previousPointX = points.get(2); previousPointY = points.get(3); if (Math.abs(points.get(k) - previousPointX) > renderer.getDisplayChartValuesDistance() || Math.abs(points.get(k + 1) - previousPointY) > renderer.getDisplayChartValuesDistance()) { paint.setTextAlign((k >= points.size() - 2) ? Align.RIGHT : renderer.getChartValuesTextAlign()); // <<< drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)), points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0); previousPointX = points.get(k); previousPointY = points.get(k + 1); drawText(canvas, getLabel(renderer.getChartValuesFormat(), series.getY(startIndex + k / 2)), points.get(k), points.get(k + 1) - renderer.getChartValuesSpacing(), paint, 0);
final XYChart chart = new LineChart(mDataset, mRenderer); mChartView = new GraphicalView(this, chart); mChartView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { XYSeries series = mDataset.getSeriesAt(0); for(int i = 0; i < series.getItemCount(); i++) { double[] xy = chart.toScreenPoint(new double[] { series.getX(i), series.getY(i) }, 0); double dx = (xy[0] - event.getX()); double dy = (xy[1] - event.getY()); double distance = Math.sqrt(dx*dx + dy*dy); if (distance <= 2*pointSize) { //.pointSize that you've specified in your renderer SeriesSelection sel = chart.getSeriesAndPointForScreenCoordinate(new Point((float)xy[0], (float)xy[1])); if (sel != null) { Toast.makeText(XYChartBuilder.this, "Touched: " + sel.getValue(), Toast.LENGTH_SHORT).show(); } break; } Log.i("LuS", "dist: " + distance); } return true; } });
Number max = null; for(int i = 0; i < series.size(); i++) { Number thisNumber = series.getY(i); if(max == null || thisNumber != null && thisNumber.doubleValue() > max.doubleValue()) { max = thisNumber;
/** * Returns a new array containing the x and y values from this series. * * @return A new array containing the x and y values from this series. * * @since 1.0.4 */ public double[][] toArray() { int itemCount = getItemCount(); double[][] result = new double[2][itemCount]; for (int i = 0; i < itemCount; i++) { result[0][i] = this.getX(i).doubleValue(); Number y = getY(i); if (y != null) { result[1][i] = y.doubleValue(); } else { result[1][i] = Double.NaN; } } return result; }
/** * Returns a new array containing the x and y values from this series. * * @return A new array containing the x and y values from this series. * * @since 1.0.4 */ public double[][] toArray() { int itemCount = getItemCount(); double[][] result = new double[2][itemCount]; for (int i = 0; i < itemCount; i++) { result[0][i] = this.getX(i).doubleValue(); Number y = getY(i); if (y != null) { result[1][i] = y.doubleValue(); } else { result[1][i] = Double.NaN; } } return result; }