Java Code Examples for com.github.mikephil.charting.components.XAxis.XAxisPosition#BOTH_SIDED

The following examples show how to use com.github.mikephil.charting.components.XAxis.XAxisPosition#BOTH_SIDED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XAxisRendererHorizontalBarChart.java    From android-kline with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 2
Source File: XAxisRenderer.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 3
Source File: XAxisRendererHorizontalBarChart.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 4
Source File: XAxisRenderer.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 5
Source File: XAxisRendererHorizontalBarChart.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 6
Source File: XAxisRenderer.java    From iMoney with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 7
Source File: XAxisRendererHorizontalBarChart.java    From iMoney with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 8
Source File: XAxisRenderer.java    From android-kline with Apache License 2.0 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());
    mAxisLinePaint.setPathEffect(mXAxis.getAxisLineDashPathEffect());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 9
Source File: XAxisRenderer.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());
    mAxisLinePaint.setPathEffect(mXAxis.getAxisLineDashPathEffect());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 10
Source File: XAxisRendererHorizontalBarChart.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 11
Source File: XAxisRenderer.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled())
        return;

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());
    mAxisLinePaint.setPathEffect(mXAxis.getAxisLineDashPathEffect());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 12
Source File: XAxisRendererHorizontalBarChart.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
@Override
public void renderAxisLine(Canvas c) {

    if (!mXAxis.isDrawAxisLineEnabled() || !mXAxis.isEnabled()) {
        return;
    }

    mAxisLinePaint.setColor(mXAxis.getAxisLineColor());
    mAxisLinePaint.setStrokeWidth(mXAxis.getAxisLineWidth());

    if (mXAxis.getPosition() == XAxisPosition.TOP
            || mXAxis.getPosition() == XAxisPosition.TOP_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentRight(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentRight(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }

    if (mXAxis.getPosition() == XAxisPosition.BOTTOM
            || mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE
            || mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
        c.drawLine(mViewPortHandler.contentLeft(),
                mViewPortHandler.contentTop(), mViewPortHandler.contentLeft(),
                mViewPortHandler.contentBottom(), mAxisLinePaint);
    }
}
 
Example 13
Source File: BarLineChartBase.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@Override
public void calculateOffsets() {

    if (!mCustomViewPortEnabled) {

        float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

        calculateLegendOffsets(mOffsetsBuffer);

        offsetLeft += mOffsetsBuffer.left;
        offsetTop += mOffsetsBuffer.top;
        offsetRight += mOffsetsBuffer.right;
        offsetBottom += mOffsetsBuffer.bottom;

        // offsets for y-labels
        if (mAxisLeft.needsOffset()) {
            offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft
                    .getPaintAxisLabels());
        }

        if (mAxisRight.needsOffset()) {
            offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight
                    .getPaintAxisLabels());
        }

        if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {

            float xlabelheight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();

            // offsets for x-labels
            if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

                offsetBottom += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

                offsetTop += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

                offsetBottom += xlabelheight;
                offsetTop += xlabelheight;
            }
        }

        offsetTop += getExtraTopOffset();
        offsetRight += getExtraRightOffset();
        offsetBottom += getExtraBottomOffset();
        offsetLeft += getExtraLeftOffset();

        float minOffset = Utils.convertDpToPixel(mMinOffset);

        mViewPortHandler.restrainViewPort(
                Math.max(minOffset, offsetLeft),
                Math.max(minOffset, offsetTop),
                Math.max(minOffset, offsetRight),
                Math.max(minOffset, offsetBottom));

        if (mLogEnabled) {
            Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop
                    + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
            Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
        }
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 14
Source File: HorizontalBarChart.java    From android-kline with Apache License 2.0 4 votes vote down vote up
@Override
public void calculateOffsets() {

    float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

    calculateLegendOffsets(mOffsetsBuffer);

    offsetLeft += mOffsetsBuffer.left;
    offsetTop += mOffsetsBuffer.top;
    offsetRight += mOffsetsBuffer.right;
    offsetBottom += mOffsetsBuffer.bottom;

    // offsets for y-labels
    if (mAxisLeft.needsOffset()) {
        offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.getPaintAxisLabels());
    }

    if (mAxisRight.needsOffset()) {
        offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.getPaintAxisLabels());
    }

    float xlabelwidth = mXAxis.mLabelRotatedWidth;

    if (mXAxis.isEnabled()) {

        // offsets for x-labels
        if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

            offsetLeft += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

            offsetRight += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

            offsetLeft += xlabelwidth;
            offsetRight += xlabelwidth;
        }
    }

    offsetTop += getExtraTopOffset();
    offsetRight += getExtraRightOffset();
    offsetBottom += getExtraBottomOffset();
    offsetLeft += getExtraLeftOffset();

    float minOffset = Utils.convertDpToPixel(mMinOffset);

    mViewPortHandler.restrainViewPort(
            Math.max(minOffset, offsetLeft),
            Math.max(minOffset, offsetTop),
            Math.max(minOffset, offsetRight),
            Math.max(minOffset, offsetBottom));

    if (mLogEnabled) {
        Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " +
                offsetRight + ", offsetBottom: "
                + offsetBottom);
        Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 15
Source File: BarLineChartBase.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void calculateOffsets() {

    if (!mCustomViewPortEnabled) {

        float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

        calculateLegendOffsets(mOffsetsBuffer);

        offsetLeft += mOffsetsBuffer.left;
        offsetTop += mOffsetsBuffer.top;
        offsetRight += mOffsetsBuffer.right;
        offsetBottom += mOffsetsBuffer.bottom;

        // offsets for y-labels
        if (mAxisLeft.needsOffset()) {
            offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft
                    .getPaintAxisLabels());
        }

        if (mAxisRight.needsOffset()) {
            offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight
                    .getPaintAxisLabels());
        }

        if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {

            float xLabelHeight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();

            // offsets for x-labels
            if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

                offsetBottom += xLabelHeight;

            } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

                offsetTop += xLabelHeight;

            } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

                offsetBottom += xLabelHeight;
                offsetTop += xLabelHeight;
            }
        }

        offsetTop += getExtraTopOffset();
        offsetRight += getExtraRightOffset();
        offsetBottom += getExtraBottomOffset();
        offsetLeft += getExtraLeftOffset();

        float minOffset = Utils.convertDpToPixel(mMinOffset);

        mViewPortHandler.restrainViewPort(
                Math.max(minOffset, offsetLeft),
                Math.max(minOffset, offsetTop),
                Math.max(minOffset, offsetRight),
                Math.max(minOffset, offsetBottom));

        if (mLogEnabled) {
            Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop
                    + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
            Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
        }
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 16
Source File: HorizontalBarChart.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public void calculateOffsets() {

    float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

    calculateLegendOffsets(mOffsetsBuffer);

    offsetLeft += mOffsetsBuffer.left;
    offsetTop += mOffsetsBuffer.top;
    offsetRight += mOffsetsBuffer.right;
    offsetBottom += mOffsetsBuffer.bottom;

    // offsets for y-labels
    if (mAxisLeft.needsOffset()) {
        offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.getPaintAxisLabels());
    }

    if (mAxisRight.needsOffset()) {
        offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.getPaintAxisLabels());
    }

    float xlabelwidth = mXAxis.mLabelRotatedWidth;

    if (mXAxis.isEnabled()) {

        // offsets for x-labels
        if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

            offsetLeft += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

            offsetRight += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

            offsetLeft += xlabelwidth;
            offsetRight += xlabelwidth;
        }
    }

    offsetTop += getExtraTopOffset();
    offsetRight += getExtraRightOffset();
    offsetBottom += getExtraBottomOffset();
    offsetLeft += getExtraLeftOffset();

    float minOffset = Utils.convertDpToPixel(mMinOffset);

    mViewPortHandler.restrainViewPort(
            Math.max(minOffset, offsetLeft),
            Math.max(minOffset, offsetTop),
            Math.max(minOffset, offsetRight),
            Math.max(minOffset, offsetBottom));

    if (mLogEnabled) {
        Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " +
                offsetRight + ", offsetBottom: "
                + offsetBottom);
        Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 17
Source File: BarLineChartBase.java    From Ticket-Analysis with MIT License 4 votes vote down vote up
@Override
public void calculateOffsets() {

    if (!mCustomViewPortEnabled) {

        float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

        calculateLegendOffsets(mOffsetsBuffer);

        offsetLeft += mOffsetsBuffer.left;
        offsetTop += mOffsetsBuffer.top;
        offsetRight += mOffsetsBuffer.right;
        offsetBottom += mOffsetsBuffer.bottom;

        // offsets for y-labels
        if (mAxisLeft.needsOffset()) {
            offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft
                    .getPaintAxisLabels());
        }

        if (mAxisRight.needsOffset()) {
            offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight
                    .getPaintAxisLabels());
        }

        if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {

            float xlabelheight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();

            // offsets for x-labels
            if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

                offsetBottom += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

                offsetTop += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

                offsetBottom += xlabelheight;
                offsetTop += xlabelheight;
            }
        }

        offsetTop += getExtraTopOffset();
        offsetRight += getExtraRightOffset();
        offsetBottom += getExtraBottomOffset();
        offsetLeft += getExtraLeftOffset();

        float minOffset = Utils.convertDpToPixel(mMinOffset);

        mViewPortHandler.restrainViewPort(
                Math.max(minOffset, offsetLeft),
                Math.max(minOffset, offsetTop),
                Math.max(minOffset, offsetRight),
                Math.max(minOffset, offsetBottom));

        if (mLogEnabled) {
            Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop
                    + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
            Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
        }
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 18
Source File: BarLineChartBase.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public void calculateOffsets() {

    if (!mCustomViewPortEnabled) {

        float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

        calculateLegendOffsets(mOffsetsBuffer);

        offsetLeft += mOffsetsBuffer.left;
        offsetTop += mOffsetsBuffer.top;
        offsetRight += mOffsetsBuffer.right;
        offsetBottom += mOffsetsBuffer.bottom;

        // offsets for y-labels
        if (mAxisLeft.needsOffset()) {
            offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft
                    .getPaintAxisLabels());
        }

        if (mAxisRight.needsOffset()) {
            offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight
                    .getPaintAxisLabels());
        }

        if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {

            float xlabelheight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();

            // offsets for x-labels
            if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

                offsetBottom += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

                offsetTop += xlabelheight;

            } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

                offsetBottom += xlabelheight;
                offsetTop += xlabelheight;
            }
        }

        offsetTop += getExtraTopOffset();
        offsetRight += getExtraRightOffset();
        offsetBottom += getExtraBottomOffset();
        offsetLeft += getExtraLeftOffset();

        float minOffset = Utils.convertDpToPixel(mMinOffset);

        mViewPortHandler.restrainViewPort(
                Math.max(minOffset, offsetLeft),
                Math.max(minOffset, offsetTop),
                Math.max(minOffset, offsetRight),
                Math.max(minOffset, offsetBottom));

        if (mLogEnabled) {
            Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop
                    + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
            Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
        }
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}
 
Example 19
Source File: HorizontalBarChart.java    From NetKnight with Apache License 2.0 4 votes vote down vote up
@Override
public void calculateOffsets() {

	float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

	calculateLegendOffsets(mOffsetsBuffer);

	offsetLeft += mOffsetsBuffer.left;
	offsetTop += mOffsetsBuffer.top;
	offsetRight += mOffsetsBuffer.right;
	offsetBottom += mOffsetsBuffer.bottom;

	// offsets for y-labels
	if (mAxisLeft.needsOffset()) {
		offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.getPaintAxisLabels());
	}

	if (mAxisRight.needsOffset()) {
		offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.getPaintAxisLabels());
	}

	float xlabelwidth = mXAxis.mLabelRotatedWidth;

	if (mXAxis.isEnabled()) {

		// offsets for x-labels
		if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

			offsetLeft += xlabelwidth;

		} else if (mXAxis.getPosition() == XAxisPosition.TOP) {

			offsetRight += xlabelwidth;

		} else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

			offsetLeft += xlabelwidth;
			offsetRight += xlabelwidth;
		}
	}

	offsetTop += getExtraTopOffset();
	offsetRight += getExtraRightOffset();
	offsetBottom += getExtraBottomOffset();
	offsetLeft += getExtraLeftOffset();

	float minOffset = Utils.convertDpToPixel(mMinOffset);

	mViewPortHandler.restrainViewPort(
			Math.max(minOffset, offsetLeft),
			Math.max(minOffset, offsetTop),
			Math.max(minOffset, offsetRight),
			Math.max(minOffset, offsetBottom));

	if (mLogEnabled) {
		Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: "
				+ offsetBottom);
		Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
	}

	prepareOffsetMatrix();
	prepareValuePxMatrix();
}
 
Example 20
Source File: HorizontalBarChart.java    From StockChart-MPAndroidChart with MIT License 4 votes vote down vote up
@Override
public void calculateOffsets() {

    float offsetLeft = 0f, offsetRight = 0f, offsetTop = 0f, offsetBottom = 0f;

    calculateLegendOffsets(mOffsetsBuffer);

    offsetLeft += mOffsetsBuffer.left;
    offsetTop += mOffsetsBuffer.top;
    offsetRight += mOffsetsBuffer.right;
    offsetBottom += mOffsetsBuffer.bottom;

    // offsets for y-labels
    if (mAxisLeft.needsOffset()) {
        offsetTop += mAxisLeft.getRequiredHeightSpace(mAxisRendererLeft.getPaintAxisLabels());
    }

    if (mAxisRight.needsOffset()) {
        offsetBottom += mAxisRight.getRequiredHeightSpace(mAxisRendererRight.getPaintAxisLabels());
    }

    float xlabelwidth = mXAxis.mLabelRotatedWidth;

    if (mXAxis.isEnabled()) {

        // offsets for x-labels
        if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {

            offsetLeft += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.TOP) {

            offsetRight += xlabelwidth;

        } else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {

            offsetLeft += xlabelwidth;
            offsetRight += xlabelwidth;
        }
    }

    offsetTop += getExtraTopOffset();
    offsetRight += getExtraRightOffset();
    offsetBottom += getExtraBottomOffset();
    offsetLeft += getExtraLeftOffset();

    float minOffset = Utils.convertDpToPixel(mMinOffset);

    mViewPortHandler.restrainViewPort(
            Math.max(minOffset, offsetLeft),
            Math.max(minOffset, offsetTop),
            Math.max(minOffset, offsetRight),
            Math.max(minOffset, offsetBottom));

    if (mLogEnabled) {
        Log.i(LOG_TAG, "offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " +
                offsetRight + ", offsetBottom: "
                + offsetBottom);
        Log.i(LOG_TAG, "Content: " + mViewPortHandler.getContentRect().toString());
    }

    prepareOffsetMatrix();
    prepareValuePxMatrix();
}