Search in sources :

Example 36 with Legend

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);
}
Also used : Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 37 with Legend

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;
}
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 38 with Legend

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;
}
Also used : Legend(com.github.mikephil.charting.components.Legend) Typeface(android.graphics.Typeface) 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 39 with Legend

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);
}
Also used : Legend(com.github.mikephil.charting.components.Legend) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 40 with Legend

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

Aggregations

Legend (com.github.mikephil.charting.components.Legend)41 XAxis (com.github.mikephil.charting.components.XAxis)24 YAxis (com.github.mikephil.charting.components.YAxis)22 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)7 Typeface (android.graphics.Typeface)6 AxisBase (com.github.mikephil.charting.components.AxisBase)6 View (android.view.View)5 MyMarkerView (com.xxmassdeveloper.mpchartexample.custom.MyMarkerView)5 ArrayList (java.util.ArrayList)5 Paint (android.graphics.Paint)3 MarkerView (com.github.mikephil.charting.components.MarkerView)3 LineData (com.github.mikephil.charting.data.LineData)3 LineDataSet (com.github.mikephil.charting.data.LineDataSet)3 LegendEntry (com.github.mikephil.charting.components.LegendEntry)2 Entry (com.github.mikephil.charting.data.Entry)2 MyAxisValueFormatter (com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter)2 RadarMarkerView (com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView)2 DecimalFormat (java.text.DecimalFormat)2 List (java.util.List)2 ValueAnimator (android.animation.ValueAnimator)1