Skip to content

Commit 4dff747

Browse files
committed
Worked on Cubic-LineChart.
1 parent f2945ec commit 4dff747

4 files changed

Lines changed: 104 additions & 109 deletions

File tree

‎MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ protected void onCreate(Bundle savedInstanceState) {
7878

7979
XAxis x = mChart.getXAxis();
8080
x.setTypeface(tf);
81+
x.setEnabled(false);
8182

8283
YAxis y = mChart.getAxisLeft();
8384
y.setTypeface(tf);
8485
y.setLabelCount(5);
86+
y.setEnabled(false);
8587

8688
mChart.getAxisRight().setEnabled(false);
8789

‎MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,28 @@ protected void onDraw(Canvas canvas) {
157157

158158
long starttime = System.currentTimeMillis();
159159

160-
// if data filtering is enabled
161-
if (mFilterData) {
162-
mData = getFilteredData();
163-
164-
Log.i(LOG_TAG, "FilterTime: " + (System.currentTimeMillis() -
165-
starttime) + " ms");
166-
starttime = System.currentTimeMillis();
167-
} else {
168-
mData = getData();
169-
// Log.i(LOG_TAG, "Filtering disabled.");
170-
}
160+
// // if data filtering is enabled
161+
// if (mFilterData) {
162+
// mData = getFilteredData();
163+
//
164+
// Log.i(LOG_TAG, "FilterTime: " + (System.currentTimeMillis() -
165+
// starttime) + " ms");
166+
// starttime = System.currentTimeMillis();
167+
// } else {
168+
// mData = getData();
169+
// // Log.i(LOG_TAG, "Filtering disabled.");
170+
// }
171171

172172
if (mXAxis.isAdjustXLabelsEnabled())
173173
calcModulus();
174174

175175
// execute all drawing commands
176176
drawGridBackground(canvas);
177177

178-
mAxisRendererLeft.computeAxis(mAxisLeft.mAxisMinimum, mAxisLeft.mAxisMaximum);
179-
mAxisRendererRight.computeAxis(mAxisRight.mAxisMinimum, mAxisRight.mAxisMaximum);
178+
if (mAxisLeft.isEnabled())
179+
mAxisRendererLeft.computeAxis(mAxisLeft.mAxisMinimum, mAxisLeft.mAxisMaximum);
180+
if (mAxisRight.isEnabled())
181+
mAxisRendererRight.computeAxis(mAxisRight.mAxisMinimum, mAxisRight.mAxisMaximum);
180182

181183
// make sure the graph values and grid cannot be drawn outside the
182184
// content-rect

‎MPChartLib/src/com/github/mikephil/charting/charts/Chart.java‎

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public abstract class Chart<T extends ChartData<? extends DataSet<? extends Entr
7474
protected ValueFormatter mDefaultFormatter;
7575

7676
/** the canvas that is used for drawing on the bitmap */
77-
// protected Canvas mDrawCanvas;
77+
// protected Canvas mDrawCanvas;
7878

7979
/**
8080
* paint object used for drawing the description text in the bottom right
@@ -167,7 +167,7 @@ public Chart(Context context, AttributeSet attrs, int defStyle) {
167167
protected void init() {
168168

169169
setWillNotDraw(false);
170-
// setLayerType(View.LAYER_TYPE_HARDWARE, null);
170+
// setLayerType(View.LAYER_TYPE_HARDWARE, null);
171171

172172
if (android.os.Build.VERSION.SDK_INT < 11)
173173
mAnimator = new ChartAnimator();
@@ -251,22 +251,12 @@ public void onAnimationUpdate(ValueAnimator animation) {
251251
*/
252252
public void setData(T data) {
253253

254-
// if (data == null || !data.isValid()) {
255-
// Log.e(LOG_TAG,
256-
// "Cannot set data for chart. Provided chart values are null or contain less than 1 entry.");
257-
// mDataNotSet = true;
258-
// return;
259-
// }
260-
261254
if (data == null) {
262255
Log.e(LOG_TAG,
263256
"Cannot set data for chart. Provided data object is null.");
264257
return;
265258
}
266259

267-
// Log.i(LOG_TAG, "xvalcount: " + data.getXValCount());
268-
// Log.i(LOG_TAG, "entrycount: " + data.getYValCount());
269-
270260
// LET THE CHART KNOW THERE IS DATA
271261
mDataNotSet = false;
272262
mOffsetsCalculated = false;
@@ -389,12 +379,12 @@ protected void onDraw(Canvas canvas) {
389379
mOffsetsCalculated = true;
390380
}
391381

392-
// if (mDrawCanvas == null) {
393-
// mDrawCanvas = new Canvas(mDrawBitmap);
394-
// }
382+
// if (mDrawCanvas == null) {
383+
// mDrawCanvas = new Canvas(mDrawBitmap);
384+
// }
395385

396386
// clear everything
397-
// mDrawBitmap.eraseColor(Color.TRANSPARENT);
387+
// mDrawBitmap.eraseColor(Color.TRANSPARENT);
398388
}
399389

400390
/**
@@ -403,8 +393,8 @@ protected void onDraw(Canvas canvas) {
403393
protected void drawDescription(Canvas c) {
404394

405395
c.drawText(mDescription, getWidth() - mViewPortHandler.offsetRight() - 10,
406-
getHeight() - mViewPortHandler.offsetBottom()
407-
- 10, mDescPaint);
396+
getHeight() - mViewPortHandler.offsetBottom()
397+
- 10, mDescPaint);
408398
}
409399

410400
/**
@@ -418,6 +408,16 @@ protected void drawDescription(Canvas c) {
418408
*/
419409
protected Highlight[] mIndicesToHightlight = new Highlight[0];
420410

411+
/**
412+
* Returns the array of currently highlighted values. This might be null or
413+
* empty if nothing is highlighted.
414+
*
415+
* @return
416+
*/
417+
public Highlight[] getHighlighted() {
418+
return mIndicesToHightlight;
419+
}
420+
421421
/**
422422
* Returns true if there are values to highlight, false if there are no
423423
* values to highlight. Checks if the highlight array is null, has a length
@@ -670,14 +670,14 @@ public void animateY(int durationMillis) {
670670
*/
671671
/** BELOW THIS ONLY GETTERS AND SETTERS */
672672

673-
// /**
674-
// * Returns the canvas object the chart uses for drawing.
675-
// *
676-
// * @return
677-
// */
678-
// public Canvas getCanvas() {
679-
// return mDrawCanvas;
680-
// }
673+
// /**
674+
// * Returns the canvas object the chart uses for drawing.
675+
// *
676+
// * @return
677+
// */
678+
// public Canvas getCanvas() {
679+
// return mDrawCanvas;
680+
// }
681681

682682
/**
683683
* Returns the default ValueFormatter that has been determined by the chart
@@ -1344,7 +1344,7 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
13441344
if (w > 0 && h > 0 && w < 10000 && h < 10000) {
13451345
// create a new bitmap with the new dimensions
13461346
mDrawBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_4444);
1347-
// mDrawCanvas = new Canvas(mDrawBitmap);
1347+
// mDrawCanvas = new Canvas(mDrawBitmap);
13481348
mViewPortHandler.setChartDimens(w, h);
13491349

13501350
if (mLogEnabled)
@@ -1365,4 +1365,17 @@ public View getChartView() {
13651365
public PointF getCenterOfView() {
13661366
return getCenter();
13671367
}
1368+
1369+
/**
1370+
* Setting this to true will set the layer-type HARDWARE for the view, false
1371+
* will set layer-type SOFTWARE.
1372+
*
1373+
* @param enabled
1374+
*/
1375+
public void setHardwareAccelerationEnabled(boolean enabled) {
1376+
if (enabled)
1377+
setLayerType(View.LAYER_TYPE_HARDWARE, null);
1378+
else
1379+
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
1380+
}
13681381
}

0 commit comments

Comments
 (0)