本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.AxisDependency类的典型用法代码示例。如果您正苦于以下问题:Java AxisDependency类的具体用法?Java AxisDependency怎么用?Java AxisDependency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AxisDependency类属于com.github.mikephil.charting.components.YAxis包,在下文中一共展示了AxisDependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: zoomAndCenterAnimated
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* Zooms by the specified scale factor to the specified values on the specified axis.
*
* @param scaleX
* @param scaleY
* @param xValue
* @param yValue
* @param axis
* @param duration
*/
@TargetApi(11)
public void zoomAndCenterAnimated(float scaleX, float scaleY, float xValue, float yValue, AxisDependency axis,
long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
MPPointD origin = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
Runnable job = AnimatedZoomJob.getInstance(mViewPortHandler, this, getTransformer(axis), getAxis(axis), mXAxis
.mAxisRange, scaleX, scaleY, mViewPortHandler.getScaleX(), mViewPortHandler.getScaleY(),
xValue, yValue, (float) origin.x, (float) origin.y, duration);
addViewportJob(job);
MPPointD.recycleInstance(origin);
} else {
Log.e(LOG_TAG, "Unable to execute zoomAndCenterAnimated(...) on API level < 11");
}
}
示例2: moveViewToAnimated
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* This will move the left side of the current viewport to the specified x-value
* and center the viewport to the y value animated.
* This also refreshes the chart by calling invalidate().
*
* @param xValue
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void moveViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY();
Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler, xValue, yValue + yInView / 2f,
getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration);
addViewportJob(job);
MPPointD.recycleInstance(bounds);
} else {
Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11");
}
}
示例3: centerViewToAnimated
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* This will move the center of the current viewport to the specified
* x and y value animated.
*
* @param xValue
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void centerViewToAnimated(float xValue, float yValue, AxisDependency axis, long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
MPPointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
float yInView = getAxisRange(axis) / mViewPortHandler.getScaleY();
float xInView = getXAxis().mAxisRange / mViewPortHandler.getScaleX();
Runnable job = AnimatedMoveViewJob.getInstance(mViewPortHandler,
xValue - xInView / 2f, yValue + yInView / 2f,
getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration);
addViewportJob(job);
MPPointD.recycleInstance(bounds);
} else {
Log.e(LOG_TAG, "Unable to execute centerViewToAnimated(...) on API level < 11");
}
}
示例4: onSizeChanged
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// Saving current position of chart.
mOnSizeChangedBuffer[0] = mOnSizeChangedBuffer[1] = 0;
if (mKeepPositionOnRotation) {
mOnSizeChangedBuffer[0] = mViewPortHandler.contentLeft();
mOnSizeChangedBuffer[1] = mViewPortHandler.contentTop();
getTransformer(AxisDependency.LEFT).pixelsToValue(mOnSizeChangedBuffer);
}
//Superclass transforms chart.
super.onSizeChanged(w, h, oldw, oldh);
if (mKeepPositionOnRotation) {
//Restoring old position of chart.
getTransformer(AxisDependency.LEFT).pointValuesToPixel(mOnSizeChangedBuffer);
mViewPortHandler.centerViewPort(mOnSizeChangedBuffer, this);
} else {
mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(), this, true);
}
}
示例5: calcMinMax
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* Adjusts the current minimum and maximum values based on the provided Entry object.
*
* @param e
* @param axis
*/
protected void calcMinMax(Entry e, AxisDependency axis) {
if (mYMax < e.getY())
mYMax = e.getY();
if (mYMin > e.getY())
mYMin = e.getY();
if (mXMax < e.getX())
mXMax = e.getX();
if (mXMin > e.getX())
mXMin = e.getX();
if (axis == AxisDependency.LEFT) {
if (mLeftAxisMax < e.getY())
mLeftAxisMax = e.getY();
if (mLeftAxisMin > e.getY())
mLeftAxisMin = e.getY();
} else {
if (mRightAxisMax < e.getY())
mRightAxisMax = e.getY();
if (mRightAxisMin > e.getY())
mRightAxisMin = e.getY();
}
}
示例6: renderAxisLine
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
@Override
public void renderAxisLine(Canvas c) {
if (!mYAxis.isEnabled() || !mYAxis.isDrawAxisLineEnabled())
return;
mAxisLinePaint.setColor(mYAxis.getAxisLineColor());
mAxisLinePaint.setStrokeWidth(mYAxis.getAxisLineWidth());
if (mYAxis.getAxisDependency() == AxisDependency.LEFT) {
c.drawLine(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
mViewPortHandler.contentBottom(), mAxisLinePaint);
} else {
c.drawLine(mViewPortHandler.contentRight(), mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
mViewPortHandler.contentBottom(), mAxisLinePaint);
}
}
示例7: renderAxisLine
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
@Override
public void renderAxisLine(Canvas c) {
if (!mYAxis.isEnabled() || !mYAxis.isDrawAxisLineEnabled())
return;
mAxisLinePaint.setColor(mYAxis.getAxisLineColor());
mAxisLinePaint.setStrokeWidth(mYAxis.getAxisLineWidth());
if (mYAxis.getAxisDependency() == AxisDependency.LEFT) {
c.drawLine(mViewPortHandler.contentLeft(),
mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
mViewPortHandler.contentTop(), mAxisLinePaint);
} else {
c.drawLine(mViewPortHandler.contentLeft(),
mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
mViewPortHandler.contentBottom(), mAxisLinePaint);
}
}
示例8: onValueSelected
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mOnValueSelectedRectF;
mChart.getBarBounds((BarEntry) e, bounds);
MPPointF position = mChart.getPosition(e, AxisDependency.LEFT);
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
Log.i("x-index",
"low: " + mChart.getLowestVisibleX() + ", high: "
+ mChart.getHighestVisibleX());
MPPointF.recycleInstance(position);
}
示例9: createSet
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
private LineDataSet createSet() {
LineDataSet set = new LineDataSet(null, "Dynamic Data");
set.setAxisDependency(AxisDependency.LEFT);
set.setColor(ColorTemplate.getHoloBlue());
set.setCircleColor(Color.WHITE);
set.setLineWidth(2f);
set.setCircleRadius(4f);
set.setFillAlpha(65);
set.setFillColor(ColorTemplate.getHoloBlue());
set.setHighLightColor(Color.rgb(244, 117, 117));
set.setValueTextColor(Color.WHITE);
set.setValueTextSize(9f);
set.setDrawValues(false);
return set;
}
示例10: calcMinMax
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
protected void calcMinMax(Entry e, AxisDependency axis) {
if (mYMax < e.getY())
mYMax = e.getY();
if (mYMin > e.getY())
mYMin = e.getY();
if (mXMax < e.getX())
mXMax = e.getX();
if (mXMin > e.getX())
mXMin = e.getX();
if (axis == AxisDependency.LEFT) {
if (mLeftAxisMax < e.getY())
mLeftAxisMax = e.getY();
if (mLeftAxisMin > e.getY())
mLeftAxisMin = e.getY();
} else {
if (mRightAxisMax < e.getY())
mRightAxisMax = e.getY();
if (mRightAxisMin > e.getY())
mRightAxisMin = e.getY();
}
}
示例11: getClosestDataSetIndex
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* Returns the index of the DataSet that contains the closest value on the
* y-axis. This is needed for highlighting. This will return -Integer.MAX_VALUE if failure.
*
* @param valsAtIndex all the values at a specific index
* @return
*/
public static int getClosestDataSetIndex(List<SelectionDetail> valsAtIndex, float val,
AxisDependency axis) {
int index = -Integer.MAX_VALUE;
float distance = Float.MAX_VALUE;
for (int i = 0; i < valsAtIndex.size(); i++) {
SelectionDetail sel = valsAtIndex.get(i);
if (axis == null || sel.dataSet.getAxisDependency() == axis) {
float cdistance = Math.abs((float) sel.val - val);
if (cdistance < distance) {
index = valsAtIndex.get(i).dataSetIndex;
distance = cdistance;
}
}
}
return index;
}
示例12: autoScale
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* Performs auto scaling of the axis by recalculating the minimum and maximum y-values based on the entries currently in view.
*/
protected void autoScale() {
final float fromX = getLowestVisibleX();
final float toX = getHighestVisibleX();
mData.calcMinMaxY(fromX, toX);
mXAxis.calculate(mData.getXMin(), mData.getXMax());
// calculate axis range (min / max) according to provided data
mAxisLeft.calculate(mData.getYMin(AxisDependency.LEFT), mData.getYMax(AxisDependency.LEFT));
mAxisRight.calculate(mData.getYMin(AxisDependency.RIGHT), mData.getYMax(AxisDependency
.RIGHT));
calculateOffsets();
}
示例13: getClosestDataSetIndex
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* Returns the index of the DataSet that contains the closest value on the
* y-axis. This is needed for highlighting. This will return -Integer.MAX_VALUE if failure.
*
* @param valsAtIndex all the values at a specific index
* @return
*/
public static int getClosestDataSetIndex(List<SelectionDetail> valsAtIndex, float val,
AxisDependency axis) {
int index = -Integer.MAX_VALUE;
float distance = Float.MAX_VALUE;
for (int i = 0; i < valsAtIndex.size(); i++) {
SelectionDetail sel = valsAtIndex.get(i);
if (axis == null || sel.dataSet.getAxisDependency() == axis) {
float cdistance = Math.abs((float) sel.val - val);
if (cdistance < distance) {
index = valsAtIndex.get(i).dataSetIndex;
distance = cdistance;
}
}
}
return index;
}
示例14: moveViewToAnimated
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
/**
* This will move the left side of the current viewport to the specified x-position
* and center the viewport to the specified y-position animated.
* This also refreshes the chart by calling invalidate().
*
* @param xIndex
* @param yValue
* @param axis
* @param duration the duration of the animation in milliseconds
*/
@TargetApi(11)
public void moveViewToAnimated(float xIndex, float yValue, AxisDependency axis, long duration) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
PointD bounds = getValuesByTouchPoint(mViewPortHandler.contentLeft(), mViewPortHandler.contentTop(), axis);
float valsInView = getDeltaY(axis) / mViewPortHandler.getScaleY();
Runnable job = new AnimatedMoveViewJob(mViewPortHandler, xIndex, yValue + valsInView / 2f,
getTransformer(axis), this, (float) bounds.x, (float) bounds.y, duration);
addViewportJob(job);
} else {
Log.e(LOG_TAG, "Unable to execute moveViewToAnimated(...) on API level < 11");
}
}
示例15: onSizeChanged
import com.github.mikephil.charting.components.YAxis.AxisDependency; //导入依赖的package包/类
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
// Saving current position of chart.
float[] pts = new float[2];
if (mKeepPositionOnRotation) {
pts[0] = mViewPortHandler.contentLeft();
pts[1] = mViewPortHandler.contentTop();
getTransformer(AxisDependency.LEFT).pixelsToValue(pts);
}
//Superclass transforms chart.
super.onSizeChanged(w, h, oldw, oldh);
if (mKeepPositionOnRotation) {
//Restoring old position of chart.
getTransformer(AxisDependency.LEFT).pointValuesToPixel(pts);
mViewPortHandler.centerViewPort(pts, this);
} else {
mViewPortHandler.refresh(mViewPortHandler.getMatrixTouch(), this, true);
}
}