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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations