Search in sources :

Example 1 with Chart

use of com.github.mikephil.charting.charts.Chart in project MPAndroidChart by PhilJay.

the class MarkerImage method getOffsetForDrawingAtPoint.

@Override
public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) {
    MPPointF offset = getOffset();
    mOffset2.x = offset.x;
    mOffset2.y = offset.y;
    Chart chart = getChartView();
    float width = mSize.width;
    float height = mSize.height;
    if (width == 0.f && mDrawable != null) {
        width = mDrawable.getIntrinsicWidth();
    }
    if (height == 0.f && mDrawable != null) {
        height = mDrawable.getIntrinsicHeight();
    }
    if (posX + mOffset2.x < 0) {
        mOffset2.x = -posX;
    } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) {
        mOffset2.x = chart.getWidth() - posX - width;
    }
    if (posY + mOffset2.y < 0) {
        mOffset2.y = -posY;
    } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) {
        mOffset2.y = chart.getHeight() - posY - height;
    }
    return mOffset2;
}
Also used : MPPointF(com.github.mikephil.charting.utils.MPPointF) Chart(com.github.mikephil.charting.charts.Chart)

Example 2 with Chart

use of com.github.mikephil.charting.charts.Chart in project MPAndroidChart by PhilJay.

the class MarkerView method getOffsetForDrawingAtPoint.

@Override
public MPPointF getOffsetForDrawingAtPoint(float posX, float posY) {
    MPPointF offset = getOffset();
    mOffset2.x = offset.x;
    mOffset2.y = offset.y;
    Chart chart = getChartView();
    float width = getWidth();
    float height = getHeight();
    if (posX + mOffset2.x < 0) {
        mOffset2.x = -posX;
    } else if (chart != null && posX + width + mOffset2.x > chart.getWidth()) {
        mOffset2.x = chart.getWidth() - posX - width;
    }
    if (posY + mOffset2.y < 0) {
        mOffset2.y = -posY;
    } else if (chart != null && posY + height + mOffset2.y > chart.getHeight()) {
        mOffset2.y = chart.getHeight() - posY - height;
    }
    return mOffset2;
}
Also used : MPPointF(com.github.mikephil.charting.utils.MPPointF) Chart(com.github.mikephil.charting.charts.Chart)

Example 3 with Chart

use of com.github.mikephil.charting.charts.Chart in project MPAndroidChart by PhilJay.

the class CombinedChartRenderer method drawHighlighted.

@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
    Chart chart = mChart.get();
    if (chart == null)
        return;
    for (DataRenderer renderer : mRenderers) {
        ChartData data = null;
        if (renderer instanceof BarChartRenderer)
            data = ((BarChartRenderer) renderer).mChart.getBarData();
        else if (renderer instanceof LineChartRenderer)
            data = ((LineChartRenderer) renderer).mChart.getLineData();
        else if (renderer instanceof CandleStickChartRenderer)
            data = ((CandleStickChartRenderer) renderer).mChart.getCandleData();
        else if (renderer instanceof ScatterChartRenderer)
            data = ((ScatterChartRenderer) renderer).mChart.getScatterData();
        else if (renderer instanceof BubbleChartRenderer)
            data = ((BubbleChartRenderer) renderer).mChart.getBubbleData();
        int dataIndex = data == null ? -1 : ((CombinedData) chart.getData()).getAllData().indexOf(data);
        mHighlightBuffer.clear();
        for (Highlight h : indices) {
            if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
                mHighlightBuffer.add(h);
        }
        renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
    }
}
Also used : ChartData(com.github.mikephil.charting.data.ChartData) Highlight(com.github.mikephil.charting.highlight.Highlight) CombinedData(com.github.mikephil.charting.data.CombinedData) Chart(com.github.mikephil.charting.charts.Chart) CombinedChart(com.github.mikephil.charting.charts.CombinedChart)

Aggregations

Chart (com.github.mikephil.charting.charts.Chart)3 MPPointF (com.github.mikephil.charting.utils.MPPointF)2 CombinedChart (com.github.mikephil.charting.charts.CombinedChart)1 ChartData (com.github.mikephil.charting.data.ChartData)1 CombinedData (com.github.mikephil.charting.data.CombinedData)1 Highlight (com.github.mikephil.charting.highlight.Highlight)1