Search in sources :

Example 1 with YAxis

use of com.github.mikephil.charting.components.YAxis 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 YAxis

use of com.github.mikephil.charting.components.YAxis in project MPAndroidChart by PhilJay.

the class RadarChartActivitry method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_radarchart_noseekbar);
    TextView tv = (TextView) findViewById(R.id.textView);
    tv.setTypeface(mTfLight);
    tv.setTextColor(Color.WHITE);
    tv.setBackgroundColor(Color.rgb(60, 65, 82));
    mChart = (RadarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.rgb(60, 65, 82));
    mChart.getDescription().setEnabled(false);
    mChart.setWebLineWidth(1f);
    mChart.setWebColor(Color.LTGRAY);
    mChart.setWebLineWidthInner(1f);
    mChart.setWebColorInner(Color.LTGRAY);
    mChart.setWebAlpha(100);
    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
    // For bounds control
    mv.setChartView(mChart);
    // Set the marker to the chart
    mChart.setMarker(mv);
    setData();
    mChart.animateXY(1400, 1400, Easing.EasingOption.EaseInOutQuad, Easing.EasingOption.EaseInOutQuad);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(mTfLight);
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private String[] mActivities = new String[] { "Burger", "Steak", "Salad", "Pasta", "Pizza" };

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mActivities[(int) value % mActivities.length];
        }
    });
    xAxis.setTextColor(Color.WHITE);
    YAxis yAxis = mChart.getYAxis();
    yAxis.setTypeface(mTfLight);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(80f);
    yAxis.setDrawLabels(false);
    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setTypeface(mTfLight);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
Also used : RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) MarkerView(com.github.mikephil.charting.components.MarkerView) RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) Legend(com.github.mikephil.charting.components.Legend) IAxisValueFormatter(com.github.mikephil.charting.formatter.IAxisValueFormatter) TextView(android.widget.TextView) AxisBase(com.github.mikephil.charting.components.AxisBase) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 3 with YAxis

use of com.github.mikephil.charting.components.YAxis in project AmazeFileManager by TeamAmaze.

the class ProcessViewerFragment method chartInit.

/**
 * Initialize chart for the first time
 * @param totalBytes maximum value for x-axis
 */
private void chartInit(long totalBytes) {
    mLineChart.setBackgroundColor(accentColor);
    mLineChart.getLegend().setEnabled(false);
    // no description text
    mLineChart.getDescription().setEnabled(false);
    XAxis xAxis = mLineChart.getXAxis();
    YAxis yAxisLeft = mLineChart.getAxisLeft();
    mLineChart.getAxisRight().setEnabled(false);
    yAxisLeft.setTextColor(Color.WHITE);
    yAxisLeft.setAxisLineColor(Color.TRANSPARENT);
    yAxisLeft.setTypeface(Typeface.DEFAULT_BOLD);
    yAxisLeft.setGridColor(Utils.getColor(getContext(), R.color.white_translucent));
    xAxis.setAxisMaximum(FileUtils.readableFileSizeFloat(totalBytes));
    xAxis.setAxisMinimum(0.0f);
    xAxis.setAxisLineColor(Color.TRANSPARENT);
    xAxis.setGridColor(Color.TRANSPARENT);
    xAxis.setTextColor(Color.WHITE);
    xAxis.setTypeface(Typeface.DEFAULT_BOLD);
    mLineChart.setData(mLineData);
    mLineChart.invalidate();
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 4 with YAxis

use of com.github.mikephil.charting.components.YAxis in project android-client by GenesisVision.

the class ProfitChartView method initView.

private void initView() {
    inflate(getContext(), R.layout.view_profit_chart, this);
    ButterKnife.bind(this);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setDragEnabled(false);
    chart.setTouchEnabled(false);
    chart.getXAxis().setEnabled(false);
    chart.getLegend().setEnabled(false);
    chart.getAxisLeft().setEnabled(true);
    chart.getAxisRight().setEnabled(false);
    chart.setDrawBorders(false);
    chart.setAutoScaleMinMaxEnabled(true);
    chart.setNoDataText(getContext().getResources().getString(R.string.not_enough_data));
    chart.setNoDataTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimaryDark));
    YAxis yAxis = chart.getAxisLeft();
    yAxis.setDrawLabels(false);
    yAxis.setDrawAxisLine(false);
    yAxis.setDrawGridLines(false);
    LimitLine ll = new LimitLine(0f, "");
    ll.setLineColor(ContextCompat.getColor(getContext(), R.color.grey400));
    ll.setLineWidth(1f);
    int lineLength = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getContext().getResources().getDisplayMetrics());
    int spaceLength = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 7, getContext().getResources().getDisplayMetrics());
    ll.enableDashedLine(lineLength, spaceLength, 0);
    yAxis.setDrawLimitLinesBehindData(true);
    yAxis.addLimitLine(ll);
    chart.setHardwareAccelerationEnabled(false);
}
Also used : LimitLine(com.github.mikephil.charting.components.LimitLine) YAxis(com.github.mikephil.charting.components.YAxis)

Example 5 with YAxis

use of com.github.mikephil.charting.components.YAxis in project CryptoBuddy by Patchett.

the class GraphFragment method setUpChart.

public void setUpChart() {
    XAxis xAxis = lineChart.getXAxis();
    xAxis.setDrawAxisLine(true);
    xAxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
    xAxis.setAvoidFirstLastClipping(true);
    lineChart.getAxisLeft().setEnabled(true);
    lineChart.getAxisLeft().setDrawGridLines(false);
    lineChart.getXAxis().setDrawGridLines(false);
    lineChart.getAxisRight().setEnabled(false);
    lineChart.getLegend().setEnabled(false);
    lineChart.setDoubleTapToZoomEnabled(false);
    lineChart.setScaleEnabled(false);
    lineChart.getDescription().setEnabled(false);
    lineChart.setContentDescription("");
    lineChart.setNoDataText(getString(R.string.noChartDataString));
    lineChart.setNoDataTextColor(R.color.darkRed);
    lineChart.setOnChartValueSelectedListener(this);
    lineChart.setOnChartGestureListener(new OnChartGestureListener() {

        @Override
        public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
            YAxis yAxis = lineChart.getAxisLeft();
            // Allow scrolling in the right and left margins
            if (me.getX() > yAxis.getLongestLabel().length() * yAxis.getTextSize() && me.getX() < displayWidth - lineChart.getViewPortHandler().offsetRight()) {
                viewPager.setPagingEnabled(false);
                nestedScrollView.setScrollingEnabled(false);
            }
        }

        @Override
        public void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
            viewPager.setPagingEnabled(true);
            nestedScrollView.setScrollingEnabled(true);
        }

        @Override
        public void onChartLongPressed(MotionEvent me) {
        }

        @Override
        public void onChartDoubleTapped(MotionEvent me) {
        }

        @Override
        public void onChartSingleTapped(MotionEvent me) {
        }

        @Override
        public void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) {
        }

        @Override
        public void onChartScale(MotionEvent me, float scaleX, float scaleY) {
        }

        @Override
        public void onChartTranslate(MotionEvent me, float dX, float dY) {
        }
    });
}
Also used : OnChartGestureListener(com.github.mikephil.charting.listener.OnChartGestureListener) ChartTouchListener(com.github.mikephil.charting.listener.ChartTouchListener) XAxis(com.github.mikephil.charting.components.XAxis) MotionEvent(android.view.MotionEvent) YAxis(com.github.mikephil.charting.components.YAxis)

Aggregations

YAxis (com.github.mikephil.charting.components.YAxis)54 XAxis (com.github.mikephil.charting.components.XAxis)48 Legend (com.github.mikephil.charting.components.Legend)22 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)11 AxisBase (com.github.mikephil.charting.components.AxisBase)10 LineData (com.github.mikephil.charting.data.LineData)8 LineDataSet (com.github.mikephil.charting.data.LineDataSet)7 XFormatter (com.a5corp.weather.utils.XFormatter)5 Entry (com.github.mikephil.charting.data.Entry)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 ArrayList (java.util.ArrayList)5 Typeface (android.graphics.Typeface)4 View (android.view.View)4 OsmandSettings (net.osmand.plus.OsmandSettings)4 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 SpannableString (android.text.SpannableString)3 LimitLine (com.github.mikephil.charting.components.LimitLine)3 MarkerView (com.github.mikephil.charting.components.MarkerView)2 YAxisRenderer (com.github.mikephil.charting.renderer.YAxisRenderer)2