Skip to content

Commit a018e65

Browse files
committed
Merge & code cleanup.
1 parent 73c60d5 commit a018e65

7 files changed

Lines changed: 68 additions & 46 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ private void addEntry() {
7171
// let the chart know it's data has changed
7272
mChart.notifyDataSetChanged();
7373

74-
mChart.setVisibleXRange(6);
75-
mChart.setVisibleYRange(10, AxisDependency.LEFT);
74+
mChart.setVisibleXRangeMaximum(6);
75+
mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
7676
//
7777
// // this automatically refreshes the chart (calls invalidate())
7878
mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ private void setData(int count, float range) {
292292
set1.setFillColor(ColorTemplate.getHoloBlue());
293293
set1.setHighLightColor(Color.rgb(244, 117, 117));
294294
set1.setDrawCircleHole(false);
295+
// set1.setVisible(false);
295296
// set1.setCircleHoleColor(Color.WHITE);
296297

297298
ArrayList<Entry> yVals2 = new ArrayList<Entry>();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private void addEntry() {
169169
mChart.notifyDataSetChanged();
170170

171171
// limit the number of visible entries
172-
mChart.setVisibleXRange(120);
172+
mChart.setVisibleXRangeMaximum(120);
173173
// mChart.setVisibleYRange(30, AxisDependency.LEFT);
174174

175175
// move to the latest entry

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

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -411,15 +411,15 @@ protected void calculateOffsets() {
411411
|| mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {
412412

413413
float yOffset = mLegend.mTextHeightMax; // It's
414-
// possible
415-
// that we do
416-
// not need
417-
// this offset
418-
// anymore as
419-
// it is
420-
// available
421-
// through the
422-
// extraOffsets
414+
// possible
415+
// that we do
416+
// not need
417+
// this offset
418+
// anymore as
419+
// it is
420+
// available
421+
// through the
422+
// extraOffsets
423423
offsetBottom += Math.min(mLegend.mNeededHeight + yOffset,
424424
mViewPortHandler.getChartHeight() * mLegend.getMaxSizePercent());
425425

@@ -636,7 +636,8 @@ public void fitScreen() {
636636
}
637637

638638
/**
639-
* Sets the minimum scale value to which can be zoomed out. 1f = fitScreen
639+
* Sets the minimum scale factor value to which can be zoomed out. 1f =
640+
* fitScreen
640641
*
641642
* @param scaleX
642643
* @param scaleY
@@ -648,36 +649,54 @@ public void setScaleMinima(float scaleX, float scaleY) {
648649

649650
/**
650651
* Sets the size of the area (range on the x-axis) that should be maximum
651-
* visible at once. If this is e.g. set to 10, no more than 10 values on the
652-
* x-axis can be viewed at once without scrolling.
652+
* visible at once (no further zooming out allowed). If this is e.g. set to
653+
* 10, no more than 10 values on the x-axis can be viewed at once without
654+
* scrolling.
653655
*
654-
* @param minScaleX
656+
* @param maxXRange The maximum visible range of x-values.
655657
*/
656-
public void setVisibleXRange(float minScaleX) {
657-
float xScale = mDeltaX / (minScaleX);
658-
mViewPortHandler.setMinimumScaleX(minScaleX);
658+
public void setVisibleXRangeMaximum(float maxXRange) {
659+
float xScale = mDeltaX / (maxXRange);
660+
mViewPortHandler.setMinimumScaleX(xScale);
659661
}
660662

661663
/**
662-
* Limits the maximum and minimum value count that can be visible by pinching and zooming.
663-
* e.g. minRange=10, maxRange=100 no less than 10 values and no more that 100 values can be viewed
664-
* at once without scrolling
664+
* Sets the size of the area (range on the x-axis) that should be minimum
665+
* visible at once (no further zooming in allowed). If this is e.g. set to
666+
* 10, no more than 10 values on the x-axis can be viewed at once without
667+
* scrolling.
668+
*
669+
* @param minXRange The minimum visible range of x-values.
670+
*/
671+
public void setVisibleXRangeMinimum(float minXRange) {
672+
float xScale = mDeltaX / (minXRange);
673+
mViewPortHandler.setMaximumScaleX(xScale);
674+
}
675+
676+
/**
677+
* Limits the maximum and minimum value count that can be visible by
678+
* pinching and zooming. e.g. minRange=10, maxRange=100 no less than 10
679+
* values and no more that 100 values can be viewed at once without
680+
* scrolling
681+
*
682+
* @param minXRange
683+
* @param maxXRange
665684
*/
666-
public void setVisibleXRange(float minScaleX, float maxScaleX) {
667-
float maxScale = mDeltaX / minScaleX;
668-
float minScale = mDeltaX / maxScaleX;
669-
mViewPortHandler.setScaleXRange(minScaleX, maxScaleX);
685+
public void setVisibleXRange(float minXRange, float maxXRange) {
686+
float maxScale = mDeltaX / minXRange;
687+
float minScale = mDeltaX / maxXRange;
688+
mViewPortHandler.setMinMaxScaleX(minScale, maxScale);
670689
}
671690

672691
/**
673692
* Sets the size of the area (range on the y-axis) that should be maximum
674693
* visible at once.
675694
*
676-
* @param yRange
695+
* @param maxYRange the maximum visible range on the y-axis
677696
* @param axis - the axis for which this limit should apply
678697
*/
679-
public void setVisibleYRange(float yRange, AxisDependency axis) {
680-
float yScale = getDeltaY(axis) / yRange;
698+
public void setVisibleYRangeMaximum(float maxYRange, AxisDependency axis) {
699+
float yScale = getDeltaY(axis) / maxYRange;
681700
mViewPortHandler.setMinimumScaleY(yScale);
682701
}
683702

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,9 @@ public OnChartGestureListener getOnChartGestureListener() {
856856
}
857857

858858
/**
859-
* If set to true, value highlighting is enabled which means that values can
860-
* be highlighted programmatically or by touch gesture.
859+
* If set to true, value highlighting is enabled for all underlying data of
860+
* the chart which means that all values can be highlighted programmatically
861+
* or by touch gesture.
861862
*
862863
* @param enabled
863864
*/
@@ -867,7 +868,7 @@ public void setHighlightEnabled(boolean enabled) {
867868
}
868869

869870
/**
870-
* returns true if highlighting of values is enabled, false if not
871+
* Returns true if highlighting of values is enabled, false if not
871872
*
872873
* @return
873874
*/

‎MPChartLib/src/com/github/mikephil/charting/data/ChartData.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ private void calcXValAverageLength() {
164164
/**
165165
* Checks if the combination of x-values array and DataSet array is legal or
166166
* not.
167-
*
168167
*/
169168
private void isLegal() {
170169

@@ -901,7 +900,8 @@ public void setDrawValues(boolean enabled) {
901900
}
902901

903902
/**
904-
* Enables / disables highlighting values for all DataSets this data object contains.
903+
* Enables / disables highlighting values for all DataSets this data object
904+
* contains.
905905
*/
906906
public void setHighlightEnabled(boolean enabled) {
907907
for (DataSet<?> set : mDataSets) {
@@ -910,7 +910,8 @@ public void setHighlightEnabled(boolean enabled) {
910910
}
911911

912912
/**
913-
* returns true if highlighting of values is enabled, false if not
913+
* Returns true if highlighting of all underlying values is enabled, false
914+
* if not.
914915
*
915916
* @return
916917
*/

‎MPChartLib/src/com/github/mikephil/charting/utils/ViewPortHandler.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,17 @@ public void setMaximumScaleX(float xScale) {
348348

349349
limitTransAndScale(mMatrixTouch, mContentRect);
350350
}
351+
352+
public void setMinMaxScaleX(float minScaleX, float maxScaleX) {
353+
354+
if (minScaleX < 1f)
355+
minScaleX = 1f;
356+
357+
mMinScaleX = minScaleX;
358+
mMaxScaleX = maxScaleX;
359+
360+
limitTransAndScale(mMatrixTouch, mContentRect);
361+
}
351362

352363
public void setMinimumScaleY(float yScale) {
353364

@@ -493,17 +504,6 @@ public boolean hasNoDragOffset() {
493504
return mTransOffsetX <= 0 && mTransOffsetY <= 0 ? true : false;
494505
}
495506

496-
public void setScaleXRange(float minScaleX, float maxScaleX) {
497-
498-
if (minScaleX < 1f)
499-
minScaleX = 1f;
500-
501-
mMinScaleX = minScaleX;
502-
mMaxScaleX = maxScaleX;
503-
504-
limitTransAndScale(mMatrixTouch, mContentRect);
505-
}
506-
507507
public boolean canZoomOutMoreX() {
508508
return (mScaleX > mMinScaleX);
509509
}

0 commit comments

Comments
 (0)