use of com.github.mikephil.charting.components.Legend 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.Legend 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;
}
use of com.github.mikephil.charting.components.Legend in project MPAndroidChart by PhilJay.
the class ScatterChartFrag method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
chart = v.findViewById(R.id.scatterChart1);
chart.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
// For bounds control
mv.setChartView(chart);
chart.setMarker(mv);
chart.setDrawGridBackground(false);
chart.setData(generateScatterData(6, 10000, 200));
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(true);
xAxis.setPosition(XAxisPosition.BOTTOM);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setTypeface(tf);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setTypeface(tf);
rightAxis.setDrawGridLines(false);
Legend l = chart.getLegend();
l.setWordWrapEnabled(true);
l.setTypeface(tf);
l.setFormSize(14f);
l.setTextSize(9f);
// increase the space between legend & bottom and legend & content
l.setYOffset(13f);
chart.setExtraBottomOffset(16f);
return v;
}
use of com.github.mikephil.charting.components.Legend in project MPAndroidChart by PhilJay.
the class ScatterChartActivity 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_scatterchart);
setTitle("ScatterChartActivity");
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);
chart.setMaxHighlightDistance(50f);
// enable scaling and dragging
chart.setDragEnabled(true);
chart.setScaleEnabled(true);
chart.setMaxVisibleValueCount(200);
chart.setPinchZoom(true);
seekBarX.setProgress(45);
seekBarY.setProgress(100);
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);
l.setXOffset(5f);
YAxis yl = chart.getAxisLeft();
yl.setTypeface(tfLight);
// this replaces setStartAtZero(true)
yl.setAxisMinimum(0f);
chart.getAxisRight().setEnabled(false);
XAxis xl = chart.getXAxis();
xl.setTypeface(tfLight);
xl.setDrawGridLines(false);
}
use of com.github.mikephil.charting.components.Legend 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);
setTitle("StackedBarActivity");
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.setOnChartValueSelectedListener(this);
chart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
chart.setMaxVisibleValueCount(40);
// scaling can now only be done on x- and y-axis separately
chart.setPinchZoom(false);
chart.setDrawGridBackground(false);
chart.setDrawBarShadow(false);
chart.setDrawValueAboveBar(false);
chart.setHighlightFullBarEnabled(false);
// change the position of the y-labels
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setValueFormatter(new MyAxisValueFormatter());
// this replaces setStartAtZero(true)
leftAxis.setAxisMinimum(0f);
chart.getAxisRight().setEnabled(false);
XAxis xLabels = chart.getXAxis();
xLabels.setPosition(XAxisPosition.TOP);
// chart.setDrawXLabels(false);
// chart.setDrawYLabels(false);
// setting data
seekBarX.setProgress(12);
seekBarY.setProgress(100);
Legend l = chart.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);
// chart.setDrawLegend(false);
}
Aggregations