Search in sources :

Example 1 with BarLineChartBase

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

the class RealmBaseActivity method setup.

protected void setup(Chart<?> chart) {
    mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
    // no description text
    chart.getDescription().setEnabled(false);
    // enable touch gestures
    chart.setTouchEnabled(true);
    if (chart instanceof BarLineChartBase) {
        BarLineChartBase mChart = (BarLineChartBase) chart;
        mChart.setDrawGridBackground(false);
        // enable scaling and dragging
        mChart.setDragEnabled(true);
        mChart.setScaleEnabled(true);
        // if disabled, scaling can be done on x- and y-axis separately
        mChart.setPinchZoom(false);
        YAxis leftAxis = mChart.getAxisLeft();
        // reset all limit lines to avoid overlapping lines
        leftAxis.removeAllLimitLines();
        leftAxis.setTypeface(mTf);
        leftAxis.setTextSize(8f);
        leftAxis.setTextColor(Color.DKGRAY);
        leftAxis.setValueFormatter(new PercentFormatter());
        XAxis xAxis = mChart.getXAxis();
        xAxis.setTypeface(mTf);
        xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
        xAxis.setTextSize(8f);
        xAxis.setTextColor(Color.DKGRAY);
        mChart.getAxisRight().setEnabled(false);
    }
}
Also used : PercentFormatter(com.github.mikephil.charting.formatter.PercentFormatter) BarLineChartBase(com.github.mikephil.charting.charts.BarLineChartBase) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 2 with BarLineChartBase

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

the class ZoomJob method run.

@Override
public void run() {
    Matrix save = mRunMatrixBuffer;
    mViewPortHandler.zoom(scaleX, scaleY, save);
    mViewPortHandler.refresh(save, view, false);
    float yValsInView = ((BarLineChartBase) view).getAxis(axisDependency).mAxisRange / mViewPortHandler.getScaleY();
    float xValsInView = ((BarLineChartBase) view).getXAxis().mAxisRange / mViewPortHandler.getScaleX();
    pts[0] = xValue - xValsInView / 2f;
    pts[1] = yValue + yValsInView / 2f;
    mTrans.pointValuesToPixel(pts);
    mViewPortHandler.translate(pts, save);
    mViewPortHandler.refresh(save, view, false);
    ((BarLineChartBase) view).calculateOffsets();
    view.postInvalidate();
    recycleInstance(this);
}
Also used : Matrix(android.graphics.Matrix) BarLineChartBase(com.github.mikephil.charting.charts.BarLineChartBase)

Aggregations

BarLineChartBase (com.github.mikephil.charting.charts.BarLineChartBase)2 Matrix (android.graphics.Matrix)1 XAxis (com.github.mikephil.charting.components.XAxis)1 YAxis (com.github.mikephil.charting.components.YAxis)1 PercentFormatter (com.github.mikephil.charting.formatter.PercentFormatter)1