当前位置: 首页>>代码示例>>Java>>正文


Java Entry.getX方法代码示例

本文整理汇总了Java中com.github.mikephil.charting.data.Entry.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Entry.getX方法的具体用法?Java Entry.getX怎么用?Java Entry.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.mikephil.charting.data.Entry的用法示例。


在下文中一共展示了Entry.getX方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPosition

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
/**
 * Returns a recyclable MPPointF instance.
 *
 * @param e
 * @param axis
 * @return
 */
@Override
public MPPointF getPosition(Entry e, AxisDependency axis) {

    if (e == null)
        return null;

    float[] vals = mGetPositionBuffer;
    vals[0] = e.getY();
    vals[1] = e.getX();

    getTransformer(axis).pointValuesToPixel(vals);

    return MPPointF.getInstance(vals[0], vals[1]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:HorizontalBarChart.java

示例2: compare

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
@Override
public int compare(Entry entry1, Entry entry2) {
    float diff = entry1.getX() - entry2.getX();

    if (diff == 0f) return 0;
    else {
        if (diff > 0f) return 1;
        else return -1;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:EntryXComparator.java

示例3: generateTransformedValuesScatter

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the SCATTERCHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesScatter(IScatterDataSet data, float phaseX,
                                                float phaseY, int from, int to) {

    final int count = (int) ((to - from) * phaseX + 1) * 2;

    if (valuePointsForGenerateTransformedValuesScatter.length != count) {
        valuePointsForGenerateTransformedValuesScatter = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesScatter;

    for (int j = 0; j < count; j += 2) {

        Entry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getY() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:Transformer.java

示例4: generateTransformedValuesBubble

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the BUBBLECHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesBubble(IBubbleDataSet data, float phaseY, int from, int to) {

    final int count = (to - from + 1) * 2; // (int) Math.ceil((to - from) * phaseX) * 2;

    if (valuePointsForGenerateTransformedValuesBubble.length != count) {
        valuePointsForGenerateTransformedValuesBubble = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesBubble;

    for (int j = 0; j < count; j += 2) {

        Entry e = data.getEntryForIndex(j / 2 + from);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getY() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:Transformer.java

示例5: generateTransformedValuesLine

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
/**
 * Transforms an List of Entry into a float array containing the x and
 * y values transformed with all matrices for the LINECHART.
 *
 * @param data
 * @return
 */
public float[] generateTransformedValuesLine(ILineDataSet data,
                                             float phaseX, float phaseY,
                                             int min, int max) {

    final int count = ((int) ((max - min) * phaseX) + 1) * 2;

    if (valuePointsForGenerateTransformedValuesLine.length != count) {
        valuePointsForGenerateTransformedValuesLine = new float[count];
    }
    float[] valuePoints = valuePointsForGenerateTransformedValuesLine;

    for (int j = 0; j < count; j += 2) {

        Entry e = data.getEntryForIndex(j / 2 + min);

        if (e != null) {
            valuePoints[j] = e.getX();
            valuePoints[j + 1] = e.getY() * phaseY;
        } else {
            valuePoints[j] = 0;
            valuePoints[j + 1] = 0;
        }
    }

    getValueToPixelMatrix().mapPoints(valuePoints);

    return valuePoints;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:Transformer.java

示例6: setData

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
private void setData() {
    List<Entry> entries = data.getList();

    for(Entry e: entries){
        Date d= new Date((long) e.getX());
        Log.d(Const.TAG2, "Next Entry is "+d.toString()+" , "+e.getY());
    }

    LineDataSet dataSet = new LineDataSet(entries, "Hourly Weather report");
    dataSet.setColor(Color.rgb(184, 235, 161));
    dataSet.setDrawCircleHole(false);
    dataSet.setCircleColor(Color.CYAN);
    dataSet.setValueTextColor(Color.WHITE);
    dataSet.setValueTextSize(15);
    dataSet.setDrawFilled(true);
    dataSet.setFillColor(Color.LTGRAY);
    dataSet.setDrawValues(true);
    dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);
    dataSet.setValueFormatter(new IValueFormatter() {
        @Override
        public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
            int newValue = (int) value;
            return newValue + Const.DEGREE;
        }
    });

    LineData lineData = new LineData(dataSet);

    lineChart.setData(lineData);
    lineChart.invalidate();//refresh
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:32,代码来源:WeatherGraph.java

示例7: drawCubicBezier

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
protected void drawCubicBezier(ILineDataSet dataSet) {

        float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        float intensity = dataSet.getCubicIntensity();

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            float prevDx = 0f;
            float prevDy = 0f;
            float curDx = 0f;
            float curDy = 0f;

            // Take an extra point from the left, and an extra from the right.
            // That's because we need 4 points for a cubic bezier (cubic=4), otherwise we get lines moving and doing weird stuff on the edges of the chart.
            // So in the starting `prev` and `cur`, go -2, -1
            // And in the `lastIndex`, add +1

            final int firstIndex = mXBounds.min + 1;
            final int lastIndex = mXBounds.min + mXBounds.range;

            Entry prevPrev;
            Entry prev = dataSet.getEntryForIndex(Math.max(firstIndex - 2, 0));
            Entry cur = dataSet.getEntryForIndex(Math.max(firstIndex - 1, 0));
            Entry next = cur;
            int nextIndex = -1;

            if (cur == null) return;

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prevPrev = prev;
                prev = cur;
                cur = nextIndex == j ? next : dataSet.getEntryForIndex(j);

                nextIndex = j + 1 < dataSet.getEntryCount() ? j + 1 : j;
                next = dataSet.getEntryForIndex(nextIndex);

                prevDx = (cur.getX() - prevPrev.getX()) * intensity;
                prevDy = (cur.getY() - prevPrev.getY()) * intensity;
                curDx = (next.getX() - prev.getX()) * intensity;
                curDy = (next.getY() - prev.getY()) * intensity;

                cubicPath.cubicTo(prev.getX() + prevDx, (prev.getY() + prevDy) * phaseY,
                        cur.getX() - curDx,
                        (cur.getY() - curDy) * phaseY, cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);

            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:LineChartRenderer.java

示例8: drawCircles

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
protected void drawCircles(Canvas c) {

        mRenderPaint.setStyle(Paint.Style.FILL);

        float phaseY = mAnimator.getPhaseY();

        mCirclesBuffer[0] = 0;
        mCirclesBuffer[1] = 0;

        List<ILineDataSet> dataSets = mChart.getLineData().getDataSets();

        for (int i = 0; i < dataSets.size(); i++) {

            ILineDataSet dataSet = dataSets.get(i);

            if (!dataSet.isVisible() || !dataSet.isDrawCirclesEnabled() ||
                    dataSet.getEntryCount() == 0)
                continue;

            mCirclePaintInner.setColor(dataSet.getCircleHoleColor());

            Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

            mXBounds.set(mChart, dataSet);

            float circleRadius = dataSet.getCircleRadius();
            float circleHoleRadius = dataSet.getCircleHoleRadius();
            boolean drawCircleHole = dataSet.isDrawCircleHoleEnabled() &&
                    circleHoleRadius < circleRadius &&
                    circleHoleRadius > 0.f;
            boolean drawTransparentCircleHole = drawCircleHole &&
                    dataSet.getCircleHoleColor() == ColorTemplate.COLOR_NONE;

            DataSetImageCache imageCache;

            if (mImageCaches.containsKey(dataSet)) {
                imageCache = mImageCaches.get(dataSet);
            } else {
                imageCache = new DataSetImageCache();
                mImageCaches.put(dataSet, imageCache);
            }

            boolean changeRequired = imageCache.init(dataSet);

            // only fill the cache with new bitmaps if a change is required
            if (changeRequired) {
                imageCache.fill(dataSet, drawCircleHole, drawTransparentCircleHole);
            }

            int boundsRangeCount = mXBounds.range + mXBounds.min;

            for (int j = mXBounds.min; j <= boundsRangeCount; j++) {

                Entry e = dataSet.getEntryForIndex(j);

                if (e == null) break;

                mCirclesBuffer[0] = e.getX();
                mCirclesBuffer[1] = e.getY() * phaseY;

                trans.pointValuesToPixel(mCirclesBuffer);

                if (!mViewPortHandler.isInBoundsRight(mCirclesBuffer[0]))
                    break;

                if (!mViewPortHandler.isInBoundsLeft(mCirclesBuffer[0]) ||
                        !mViewPortHandler.isInBoundsY(mCirclesBuffer[1]))
                    continue;

                Bitmap circleBitmap = imageCache.getBitmap(j);

                if (circleBitmap != null) {
                    c.drawBitmap(circleBitmap, mCirclesBuffer[0] - circleRadius, mCirclesBuffer[1] - circleRadius, null);
                }
            }
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:78,代码来源:LineChartRenderer.java

示例9: drawDataSet

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) {

        ViewPortHandler viewPortHandler = mViewPortHandler;

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        float phaseY = mAnimator.getPhaseY();

        IShapeRenderer renderer = dataSet.getShapeRenderer();
        if (renderer == null) {
            Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet");
            return;
        }

        int max = (int)(Math.min(
                Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()),
                (float)dataSet.getEntryCount()));

        for (int i = 0; i < max; i++) {

            Entry e = dataSet.getEntryForIndex(i);

            mPixelBuffer[0] = e.getX();
            mPixelBuffer[1] = e.getY() * phaseY;

            trans.pointValuesToPixel(mPixelBuffer);

            if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0]))
                break;

            if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0])
                    || !viewPortHandler.isInBoundsY(mPixelBuffer[1]))
                continue;

            mRenderPaint.setColor(dataSet.getColor(i / 2));
            renderer.renderShape(
                    c, dataSet, mViewPortHandler,
                    mPixelBuffer[0], mPixelBuffer[1],
                    mRenderPaint);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:ScatterChartRenderer.java

示例10: getPosition

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
/**
 * Returns a recyclable MPPointF instance.
 * Returns the position (in pixels) the provided Entry has inside the chart
 * view or null, if the provided Entry is null.
 *
 * @param e
 * @return
 */
public MPPointF getPosition(Entry e, AxisDependency axis) {

    if (e == null)
        return null;

    mGetPositionBuffer[0] = e.getX();
    mGetPositionBuffer[1] = e.getY();

    getTransformer(axis).pointValuesToPixel(mGetPositionBuffer);

    return MPPointF.getInstance(mGetPositionBuffer[0], mGetPositionBuffer[1]);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BarLineChartBase.java

示例11: drawHorizontalBezier

import com.github.mikephil.charting.data.Entry; //导入方法依赖的package包/类
protected void drawHorizontalBezier(ILineDataSet dataSet) {

        float phaseY = mAnimator.getPhaseY();

        Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());

        mXBounds.set(mChart, dataSet);

        cubicPath.reset();

        if (mXBounds.range >= 1) {

            Entry prev = dataSet.getEntryForIndex(mXBounds.min);
            Entry cur = prev;

            // let the spline start
            cubicPath.moveTo(cur.getX(), cur.getY() * phaseY);

            for (int j = mXBounds.min + 1; j <= mXBounds.range + mXBounds.min; j++) {

                prev = cur;
                cur = dataSet.getEntryForIndex(j);

                final float cpx = (prev.getX())
                        + (cur.getX() - prev.getX()) / 2.0f;

                cubicPath.cubicTo(
                        cpx, prev.getY() * phaseY,
                        cpx, cur.getY() * phaseY,
                        cur.getX(), cur.getY() * phaseY);
            }
        }

        // if filled is enabled, close the path
        if (dataSet.isDrawFilledEnabled()) {

            cubicFillPath.reset();
            cubicFillPath.addPath(cubicPath);
            // create a new path, this is bad for performance
            drawCubicFill(mBitmapCanvas, dataSet, cubicFillPath, trans, mXBounds);
        }

        mRenderPaint.setColor(dataSet.getColor());

        mRenderPaint.setStyle(Paint.Style.STROKE);

        trans.pathValueToPixel(cubicPath);

        mBitmapCanvas.drawPath(cubicPath, mRenderPaint);

        mRenderPaint.setPathEffect(null);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:53,代码来源:LineChartRenderer.java


注:本文中的com.github.mikephil.charting.data.Entry.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。