@SuppressLint("NewApi") @Override public boolean onPreDraw() { ChartView.this.getViewTreeObserver().removeOnPreDrawListener(this); style.init(); // Define chart frame mChartTop = getPaddingTop() + verController.getLabelHeight()/2; mChartBottom = getMeasuredHeight() - getPaddingBottom()-LABELTEXTMAXLINE*(int)(style.labelsPaint.descent()-style.labelsPaint.ascent()); mChartLeft = getPaddingLeft(); mChartRight = getMeasuredWidth() - getPaddingRight(); // Initialize controllers now that we have the measures verController.init(); if(mHasThresholdValue) { mThresholdStartValue = verController.parsePos(0, mThresholdStartValue); mThresholdEndValue = verController.parsePos(0, mThresholdEndValue); } // Mandatory: X axis after Y axis! horController.init(); // Process data to define screen positions digestData(); // Tells view to execute code before starting drawing onPreDrawChart(data); // Define regions mRegions = defineRegions(data); // Prepares the animation if needed and gets the first dump // of data to be drawn if(mAnim != null) data = mAnim.prepareEnterAnimation(ChartView.this); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) ChartView.this.setLayerType(LAYER_TYPE_SOFTWARE, null); return mReadyToDraw = true; }