Search in sources :

Example 31 with XAxis

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

the class ScrollViewActivity 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_scrollview);
    mChart = (BarChart) findViewById(R.id.chart1);
    mChart.getDescription().setEnabled(false);
    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);
    mChart.setDrawBarShadow(false);
    mChart.setDrawGridBackground(false);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setDrawGridLines(false);
    mChart.getAxisLeft().setDrawGridLines(false);
    mChart.getLegend().setEnabled(false);
    setData(10);
    mChart.setFitBars(true);
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis)

Example 32 with XAxis

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

the class StackedBarActivity 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_barchart);
    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);
    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarX.setOnSeekBarChangeListener(this);
    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
    mSeekBarY.setOnSeekBarChangeListener(this);
    mChart = (BarChart) findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.getDescription().setEnabled(false);
    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    mChart.setMaxVisibleValueCount(40);
    // scaling can now only be done on x- and y-axis separately
    mChart.setPinchZoom(false);
    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(false);
    mChart.setHighlightFullBarEnabled(false);
    // change the position of the y-labels
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setValueFormatter(new MyAxisValueFormatter());
    // this replaces setStartAtZero(true)
    leftAxis.setAxisMinimum(0f);
    mChart.getAxisRight().setEnabled(false);
    XAxis xLabels = mChart.getXAxis();
    xLabels.setPosition(XAxisPosition.TOP);
    // mChart.setDrawXLabels(false);
    // mChart.setDrawYLabels(false);
    // setting data
    mSeekBarX.setProgress(12);
    mSeekBarY.setProgress(100);
    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setFormSize(8f);
    l.setFormToTextSpace(4f);
    l.setXEntrySpace(6f);
// mChart.setDrawLegend(false);
}
Also used : Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis) MyAxisValueFormatter(com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter)

Example 33 with XAxis

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

the class BarChartFrag method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
    // create a new chart object
    mChart = new BarChart(getActivity());
    mChart.getDescription().setEnabled(false);
    mChart.setOnChartGestureListener(this);
    MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
    // For bounds control
    mv.setChartView(mChart);
    mChart.setMarker(mv);
    mChart.setDrawGridBackground(false);
    mChart.setDrawBarShadow(false);
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
    mChart.setData(generateBarData(1, 20000, 12));
    Legend l = mChart.getLegend();
    l.setTypeface(tf);
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(tf);
    // this replaces setStartAtZero(true)
    leftAxis.setAxisMinimum(0f);
    mChart.getAxisRight().setEnabled(false);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(false);
    // programatically add the chart
    FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout);
    parent.addView(mChart);
    return v;
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) FrameLayout(android.widget.FrameLayout) BarChart(com.github.mikephil.charting.charts.BarChart) View(android.view.View) MyMarkerView(com.xxmassdeveloper.mpchartexample.custom.MyMarkerView) MyMarkerView(com.xxmassdeveloper.mpchartexample.custom.MyMarkerView) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 34 with XAxis

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

the class ComplexityFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_line, container, false);
    mChart = (LineChart) v.findViewById(R.id.lineChart1);
    mChart.getDescription().setEnabled(false);
    mChart.setDrawGridBackground(false);
    mChart.setData(getComplexity());
    mChart.animateX(3000);
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
    Legend l = mChart.getLegend();
    l.setTypeface(tf);
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(tf);
    mChart.getAxisRight().setEnabled(false);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(false);
    return v;
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) View(android.view.View) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 35 with XAxis

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

the class Chart method init.

/**
     * initialize all paints and stuff
     */
protected void init() {
    setWillNotDraw(false);
    if (android.os.Build.VERSION.SDK_INT < 11)
        mAnimator = new ChartAnimator();
    else
        mAnimator = new ChartAnimator(new AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                // ViewCompat.postInvalidateOnAnimation(Chart.this);
                postInvalidate();
            }
        });
    // initialize the utils
    Utils.init(getContext());
    mMaxHighlightDistance = Utils.convertDpToPixel(500f);
    mDescription = new Description();
    mLegend = new Legend();
    mLegendRenderer = new LegendRenderer(mViewPortHandler, mLegend);
    mXAxis = new XAxis();
    mDescPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    // orange
    mInfoPaint.setColor(Color.rgb(247, 189, 51));
    mInfoPaint.setTextAlign(Align.CENTER);
    mInfoPaint.setTextSize(Utils.convertDpToPixel(12f));
    if (mLogEnabled)
        Log.i("", "Chart.init()");
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Description(com.github.mikephil.charting.components.Description) LegendRenderer(com.github.mikephil.charting.renderer.LegendRenderer) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) Paint(android.graphics.Paint) ValueAnimator(android.animation.ValueAnimator) ChartAnimator(com.github.mikephil.charting.animation.ChartAnimator) XAxis(com.github.mikephil.charting.components.XAxis)

Aggregations

XAxis (com.github.mikephil.charting.components.XAxis)40 YAxis (com.github.mikephil.charting.components.YAxis)35 Legend (com.github.mikephil.charting.components.Legend)21 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)7 Typeface (android.graphics.Typeface)6 AxisBase (com.github.mikephil.charting.components.AxisBase)6 LineData (com.github.mikephil.charting.data.LineData)6 LineDataSet (com.github.mikephil.charting.data.LineDataSet)6 XFormatter (com.a5corp.weather.utils.XFormatter)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 View (android.view.View)4 ArrayList (java.util.ArrayList)3 Paint (android.graphics.Paint)2 BarData (com.github.mikephil.charting.data.BarData)2 MyAxisValueFormatter (com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter)2 ValueAnimator (android.animation.ValueAnimator)1 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 ChartAnimator (com.github.mikephil.charting.animation.ChartAnimator)1