Skip to content

Commit

Permalink
Merge & code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Jun 2, 2015
1 parent 73c60d5 commit a018e65
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ private void addEntry() {
// let the chart know it's data has changed
mChart.notifyDataSetChanged();

mChart.setVisibleXRange(6);
mChart.setVisibleYRange(10, AxisDependency.LEFT);
mChart.setVisibleXRangeMaximum(6);
mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
//
// // this automatically refreshes the chart (calls invalidate())
mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ private void setData(int count, float range) {
set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setDrawCircleHole(false);
// set1.setVisible(false);
// set1.setCircleHoleColor(Color.WHITE);

ArrayList<Entry> yVals2 = new ArrayList<Entry>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void addEntry() {
mChart.notifyDataSetChanged();

// limit the number of visible entries
mChart.setVisibleXRange(120);
mChart.setVisibleXRangeMaximum(120);
// mChart.setVisibleYRange(30, AxisDependency.LEFT);

// move to the latest entry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,15 +411,15 @@ protected void calculateOffsets() {
|| mLegend.getPosition() == LegendPosition.BELOW_CHART_CENTER) {

float yOffset = mLegend.mTextHeightMax; // It's
// possible
// that we do
// not need
// this offset
// anymore as
// it is
// available
// through the
// extraOffsets
// possible
// that we do
// not need
// this offset
// anymore as
// it is
// available
// through the
// extraOffsets
offsetBottom += Math.min(mLegend.mNeededHeight + yOffset,
mViewPortHandler.getChartHeight() * mLegend.getMaxSizePercent());

Expand Down Expand Up @@ -636,7 +636,8 @@ public void fitScreen() {
}

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

/**
* Sets the size of the area (range on the x-axis) that should be maximum
* visible at once. If this is e.g. set to 10, no more than 10 values on the
* x-axis can be viewed at once without scrolling.
* visible at once (no further zooming out allowed). If this is e.g. set to
* 10, no more than 10 values on the x-axis can be viewed at once without
* scrolling.
*
* @param minScaleX
* @param maxXRange The maximum visible range of x-values.
*/
public void setVisibleXRange(float minScaleX) {
float xScale = mDeltaX / (minScaleX);
mViewPortHandler.setMinimumScaleX(minScaleX);
public void setVisibleXRangeMaximum(float maxXRange) {
float xScale = mDeltaX / (maxXRange);
mViewPortHandler.setMinimumScaleX(xScale);
}

/**
* Limits the maximum and minimum value count that can be visible by pinching and zooming.
* e.g. minRange=10, maxRange=100 no less than 10 values and no more that 100 values can be viewed
* at once without scrolling
* Sets the size of the area (range on the x-axis) that should be minimum
* visible at once (no further zooming in allowed). If this is e.g. set to
* 10, no more than 10 values on the x-axis can be viewed at once without
* scrolling.
*
* @param minXRange The minimum visible range of x-values.
*/
public void setVisibleXRangeMinimum(float minXRange) {
float xScale = mDeltaX / (minXRange);
mViewPortHandler.setMaximumScaleX(xScale);
}

/**
* Limits the maximum and minimum value count that can be visible by
* pinching and zooming. e.g. minRange=10, maxRange=100 no less than 10
* values and no more that 100 values can be viewed at once without
* scrolling
*
* @param minXRange
* @param maxXRange
*/
public void setVisibleXRange(float minScaleX, float maxScaleX) {
float maxScale = mDeltaX / minScaleX;
float minScale = mDeltaX / maxScaleX;
mViewPortHandler.setScaleXRange(minScaleX, maxScaleX);
public void setVisibleXRange(float minXRange, float maxXRange) {
float maxScale = mDeltaX / minXRange;
float minScale = mDeltaX / maxXRange;
mViewPortHandler.setMinMaxScaleX(minScale, maxScale);
}

/**
* Sets the size of the area (range on the y-axis) that should be maximum
* visible at once.
*
* @param yRange
* @param maxYRange the maximum visible range on the y-axis
* @param axis - the axis for which this limit should apply
*/
public void setVisibleYRange(float yRange, AxisDependency axis) {
float yScale = getDeltaY(axis) / yRange;
public void setVisibleYRangeMaximum(float maxYRange, AxisDependency axis) {
float yScale = getDeltaY(axis) / maxYRange;
mViewPortHandler.setMinimumScaleY(yScale);
}

Expand Down
7 changes: 4 additions & 3 deletions MPChartLib/src/com/github/mikephil/charting/charts/Chart.java
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ public OnChartGestureListener getOnChartGestureListener() {
}

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

/**
* returns true if highlighting of values is enabled, false if not
* Returns true if highlighting of values is enabled, false if not
*
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ private void calcXValAverageLength() {
/**
* Checks if the combination of x-values array and DataSet array is legal or
* not.
*
*/
private void isLegal() {

Expand Down Expand Up @@ -901,7 +900,8 @@ public void setDrawValues(boolean enabled) {
}

/**
* Enables / disables highlighting values for all DataSets this data object contains.
* Enables / disables highlighting values for all DataSets this data object
* contains.
*/
public void setHighlightEnabled(boolean enabled) {
for (DataSet<?> set : mDataSets) {
Expand All @@ -910,7 +910,8 @@ public void setHighlightEnabled(boolean enabled) {
}

/**
* returns true if highlighting of values is enabled, false if not
* Returns true if highlighting of all underlying values is enabled, false
* if not.
*
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,17 @@ public void setMaximumScaleX(float xScale) {

limitTransAndScale(mMatrixTouch, mContentRect);
}

public void setMinMaxScaleX(float minScaleX, float maxScaleX) {

if (minScaleX < 1f)
minScaleX = 1f;

mMinScaleX = minScaleX;
mMaxScaleX = maxScaleX;

limitTransAndScale(mMatrixTouch, mContentRect);
}

public void setMinimumScaleY(float yScale) {

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

public void setScaleXRange(float minScaleX, float maxScaleX) {

if (minScaleX < 1f)
minScaleX = 1f;

mMinScaleX = minScaleX;
mMaxScaleX = maxScaleX;

limitTransAndScale(mMatrixTouch, mContentRect);
}

public boolean canZoomOutMoreX() {
return (mScaleX > mMinScaleX);
}
Expand Down

0 comments on commit a018e65

Please sign in to comment.