Search in sources :

Example 1 with RadarMarkerView

use of com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView in project MPAndroidChart by PhilJay.

the class RadarChartActivitry 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_radarchart_noseekbar);
    TextView tv = (TextView) findViewById(R.id.textView);
    tv.setTypeface(mTfLight);
    tv.setTextColor(Color.WHITE);
    tv.setBackgroundColor(Color.rgb(60, 65, 82));
    mChart = (RadarChart) findViewById(R.id.chart1);
    mChart.setBackgroundColor(Color.rgb(60, 65, 82));
    mChart.getDescription().setEnabled(false);
    mChart.setWebLineWidth(1f);
    mChart.setWebColor(Color.LTGRAY);
    mChart.setWebLineWidthInner(1f);
    mChart.setWebColorInner(Color.LTGRAY);
    mChart.setWebAlpha(100);
    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
    // For bounds control
    mv.setChartView(mChart);
    // Set the marker to the chart
    mChart.setMarker(mv);
    setData();
    mChart.animateXY(1400, 1400, Easing.EasingOption.EaseInOutQuad, Easing.EasingOption.EaseInOutQuad);
    XAxis xAxis = mChart.getXAxis();
    xAxis.setTypeface(mTfLight);
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private String[] mActivities = new String[] { "Burger", "Steak", "Salad", "Pasta", "Pizza" };

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mActivities[(int) value % mActivities.length];
        }
    });
    xAxis.setTextColor(Color.WHITE);
    YAxis yAxis = mChart.getYAxis();
    yAxis.setTypeface(mTfLight);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(80f);
    yAxis.setDrawLabels(false);
    Legend l = mChart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setTypeface(mTfLight);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
Also used : RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) MarkerView(com.github.mikephil.charting.components.MarkerView) RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) Legend(com.github.mikephil.charting.components.Legend) IAxisValueFormatter(com.github.mikephil.charting.formatter.IAxisValueFormatter) TextView(android.widget.TextView) AxisBase(com.github.mikephil.charting.components.AxisBase) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Example 2 with RadarMarkerView

use of com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView in project MPAndroidChart by PhilJay.

the class RadarChartActivity 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_radarchart);
    setTitle("RadarChartActivity");
    chart = findViewById(R.id.chart1);
    chart.setBackgroundColor(Color.rgb(60, 65, 82));
    chart.getDescription().setEnabled(false);
    chart.setWebLineWidth(1f);
    chart.setWebColor(Color.LTGRAY);
    chart.setWebLineWidthInner(1f);
    chart.setWebColorInner(Color.LTGRAY);
    chart.setWebAlpha(100);
    // create a custom MarkerView (extend MarkerView) and specify the layout
    // to use for it
    MarkerView mv = new RadarMarkerView(this, R.layout.radar_markerview);
    // For bounds control
    mv.setChartView(chart);
    // Set the marker to the chart
    chart.setMarker(mv);
    setData();
    chart.animateXY(1400, 1400, Easing.EaseInOutQuad);
    XAxis xAxis = chart.getXAxis();
    xAxis.setTypeface(tfLight);
    xAxis.setTextSize(9f);
    xAxis.setYOffset(0f);
    xAxis.setXOffset(0f);
    xAxis.setValueFormatter(new IAxisValueFormatter() {

        private final String[] mActivities = new String[] { "Burger", "Steak", "Salad", "Pasta", "Pizza" };

        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return mActivities[(int) value % mActivities.length];
        }
    });
    xAxis.setTextColor(Color.WHITE);
    YAxis yAxis = chart.getYAxis();
    yAxis.setTypeface(tfLight);
    yAxis.setLabelCount(5, false);
    yAxis.setTextSize(9f);
    yAxis.setAxisMinimum(0f);
    yAxis.setAxisMaximum(80f);
    yAxis.setDrawLabels(false);
    Legend l = chart.getLegend();
    l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
    l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
    l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
    l.setDrawInside(false);
    l.setTypeface(tfLight);
    l.setXEntrySpace(7f);
    l.setYEntrySpace(5f);
    l.setTextColor(Color.WHITE);
}
Also used : RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) MarkerView(com.github.mikephil.charting.components.MarkerView) RadarMarkerView(com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView) Legend(com.github.mikephil.charting.components.Legend) IAxisValueFormatter(com.github.mikephil.charting.formatter.IAxisValueFormatter) AxisBase(com.github.mikephil.charting.components.AxisBase) XAxis(com.github.mikephil.charting.components.XAxis) YAxis(com.github.mikephil.charting.components.YAxis)

Aggregations

AxisBase (com.github.mikephil.charting.components.AxisBase)2 Legend (com.github.mikephil.charting.components.Legend)2 MarkerView (com.github.mikephil.charting.components.MarkerView)2 XAxis (com.github.mikephil.charting.components.XAxis)2 YAxis (com.github.mikephil.charting.components.YAxis)2 IAxisValueFormatter (com.github.mikephil.charting.formatter.IAxisValueFormatter)2 RadarMarkerView (com.xxmassdeveloper.mpchartexample.custom.RadarMarkerView)2 TextView (android.widget.TextView)1