/** * Convert {@link ChartEntry} values into screen points. */ private void digestData() { int nEntries = data.get(0).size(); for(ChartSet set: data){ for(int i = 0; i < nEntries; i++){ set.getEntry(i) .setCoordinates(horController.parsePos(i, set.getValue(i)), verController.parsePos(i, set.getValue(i))); } } }
/** * Notify {@link ChartView} about updated values. {@link ChartView} will be validated. */ public void notifyDataUpdate(){ ArrayList<float[][]> oldCoords = new ArrayList<>(data.size()); ArrayList<float[][]> newCoords = new ArrayList<>(data.size()); for(ChartSet set : data) oldCoords.add(set.getScreenPoints()); digestData(); for(ChartSet set : data) newCoords.add(set.getScreenPoints()); mRegions = defineRegions(data); if(mAnim != null) data = mAnim.prepareUpdateAnimation(this, oldCoords, newCoords); invalidate(); }
/** * Set new data to the chart and invalidates the view to be then drawn. * * @param set {@link ChartSet} object. */ public void addData(ChartSet set){ if(!data.isEmpty() && set.size() != data.get(0).size()) Log.e(TAG, "The number of entries between sets doesn't match.", new IllegalArgumentException()); if(set == null) Log.e(TAG, "Chart data set can't be null", new IllegalArgumentException()); data.add(set); }
/** * Show chart data */ public void show(){ for(ChartSet set : data) set.setVisible(true); display(); }