Search in sources :

Example 46 with YAxis

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

the class CandleStickChartActivity 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_candlechart);
    setTitle("CandleStickChartActivity");
    tvX = findViewById(R.id.tvXMax);
    tvY = findViewById(R.id.tvYMax);
    seekBarX = findViewById(R.id.seekBar1);
    seekBarX.setOnSeekBarChangeListener(this);
    seekBarY = findViewById(R.id.seekBar2);
    seekBarY.setOnSeekBarChangeListener(this);
    chart = findViewById(R.id.chart1);
    chart.setBackgroundColor(Color.WHITE);
    chart.getDescription().setEnabled(false);
    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    chart.setMaxVisibleValueCount(60);
    // scaling can now only be done on x- and y-axis separately
    chart.setPinchZoom(false);
    chart.setDrawGridBackground(false);
    XAxis xAxis = chart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setDrawGridLines(false);
    YAxis leftAxis = chart.getAxisLeft();
    // leftAxis.setEnabled(false);
    leftAxis.setLabelCount(7, false);
    leftAxis.setDrawGridLines(false);
    leftAxis.setDrawAxisLine(false);
    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setEnabled(false);
    // rightAxis.setStartAtZero(false);
    // setting data
    seekBarX.setProgress(40);
    seekBarY.setProgress(100);
    chart.getLegend().setEnabled(false);
}
Also used : XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 47 with YAxis

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

the class RealtimeLineChartActivity 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_realtime_linechart);
    setTitle("RealtimeLineChartActivity");
    chart = findViewById(R.id.chart1);
    chart.setOnChartValueSelectedListener(this);
    // enable description text
    chart.getDescription().setEnabled(true);
    // enable touch gestures
    chart.setTouchEnabled(true);
    // enable scaling and dragging
    chart.setDragEnabled(true);
    chart.setScaleEnabled(true);
    chart.setDrawGridBackground(false);
    // if disabled, scaling can be done on x- and y-axis separately
    chart.setPinchZoom(true);
    // set an alternative background color
    chart.setBackgroundColor(Color.LTGRAY);
    LineData data = new LineData();
    data.setValueTextColor(Color.WHITE);
    // add empty data
    chart.setData(data);
    // get the legend (only possible after setting data)
    Legend l = chart.getLegend();
    // modify the legend ...
    l.setForm(LegendForm.LINE);
    l.setTypeface(tfLight);
    l.setTextColor(Color.WHITE);
    XAxis xl = chart.getXAxis();
    xl.setTypeface(tfLight);
    xl.setTextColor(Color.WHITE);
    xl.setDrawGridLines(false);
    xl.setAvoidFirstLastClipping(true);
    xl.setEnabled(true);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTypeface(tfLight);
    leftAxis.setTextColor(Color.WHITE);
    leftAxis.setAxisMaximum(100f);
    leftAxis.setAxisMinimum(0f);
    leftAxis.setDrawGridLines(true);
    YAxis rightAxis = chart.getAxisRight();
    rightAxis.setEnabled(false);
}
Also used : LineData(com.github.mikephil.charting.data.LineData) Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 48 with YAxis

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

the class HorizontalBarChartActivity 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_horizontalbarchart);
    setTitle("HorizontalBarChartActivity");
    tvX = findViewById(R.id.tvXMax);
    tvY = findViewById(R.id.tvYMax);
    seekBarX = findViewById(R.id.seekBar1);
    seekBarY = findViewById(R.id.seekBar2);
    seekBarY.setOnSeekBarChangeListener(this);
    seekBarX.setOnSeekBarChangeListener(this);
    chart = findViewById(R.id.chart1);
    chart.setOnChartValueSelectedListener(this);
    // chart.setHighlightEnabled(false);
    chart.setDrawBarShadow(false);
    chart.setDrawValueAboveBar(true);
    chart.getDescription().setEnabled(false);
    // if more than 60 entries are displayed in the chart, no values will be
    // drawn
    chart.setMaxVisibleValueCount(60);
    // scaling can now only be done on x- and y-axis separately
    chart.setPinchZoom(false);
    // draw shadows for each bar that show the maximum value
    // chart.setDrawBarShadow(true);
    chart.setDrawGridBackground(false);
    XAxis xl = chart.getXAxis();
    xl.setPosition(XAxisPosition.BOTTOM);
    xl.setTypeface(tfLight);
    xl.setDrawAxisLine(true);
    xl.setDrawGridLines(false);
    xl.setGranularity(10f);
    YAxis yl = chart.getAxisLeft();
    yl.setTypeface(tfLight);
    yl.setDrawAxisLine(true);
    yl.setDrawGridLines(true);
    // this replaces setStartAtZero(true)
    yl.setAxisMinimum(0f);
    // yl.setInverted(true);
    YAxis yr = chart.getAxisRight();
    yr.setTypeface(tfLight);
    yr.setDrawAxisLine(true);
    yr.setDrawGridLines(false);
    // this replaces setStartAtZero(true)
    yr.setAxisMinimum(0f);
    // yr.setInverted(true);
    chart.setFitBars(true);
    chart.animateY(2500);
    // setting data
    seekBarY.setProgress(50);
    seekBarX.setProgress(12);
    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setFormSize(8f);
    l.setXEntrySpace(4f);
}
Also used : Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 49 with YAxis

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

the class BubbleChartActivity 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_bubblechart);
    setTitle("BubbleChartActivity");
    tvX = findViewById(R.id.tvXMax);
    tvY = findViewById(R.id.tvYMax);
    seekBarX = findViewById(R.id.seekBar1);
    seekBarX.setOnSeekBarChangeListener(this);
    seekBarY = findViewById(R.id.seekBar2);
    seekBarY.setOnSeekBarChangeListener(this);
    chart = findViewById(R.id.chart1);
    chart.getDescription().setEnabled(false);
    chart.setOnChartValueSelectedListener(this);
    chart.setDrawGridBackground(false);
    chart.setTouchEnabled(true);
    // enable scaling and dragging
    chart.setDragEnabled(true);
    chart.setScaleEnabled(true);
    chart.setMaxVisibleValueCount(200);
    chart.setPinchZoom(true);
    seekBarX.setProgress(10);
    seekBarY.setProgress(50);
    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
    l.setOrientation(Legend.LegendOrientation.VERTICAL);
    l.setDrawInside(false);
    l.setTypeface(tfLight);
    YAxis yl = chart.getAxisLeft();
    yl.setTypeface(tfLight);
    yl.setSpaceTop(30f);
    yl.setSpaceBottom(30f);
    yl.setDrawZeroLine(false);
    chart.getAxisRight().setEnabled(false);
    XAxis xl = chart.getXAxis();
    xl.setPosition(XAxis.XAxisPosition.BOTTOM);
    xl.setTypeface(tfLight);
}
Also used : Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 50 with YAxis

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

the class ComplexityFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_line, container, false);
    chart = v.findViewById(R.id.lineChart1);
    chart.getDescription().setEnabled(false);
    chart.setDrawGridBackground(false);
    chart.setData(getComplexity());
    chart.animateX(3000);
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
    Legend l = chart.getLegend();
    l.setTypeface(tf);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setTypeface(tf);
    chart.getAxisRight().setEnabled(false);
    XAxis xAxis = chart.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)

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