Java Code Examples for com.github.mikephil.charting.charts.ScatterChart#getXAxis()

The following examples show how to use com.github.mikephil.charting.charts.ScatterChart#getXAxis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScatterChartFrag.java    From Stayfit with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
    
    mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
    mChart.setDescription("");
    
    Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
    
    MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);

    mChart.setMarkerView(mv);

    mChart.setDrawGridBackground(false);
    mChart.setData(generateScatterData(6, 10000, 200));
    
    XAxis xAxis = mChart.getXAxis();
    xAxis.setEnabled(true);
    xAxis.setPosition(XAxisPosition.BOTTOM);
    
    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(tf);
    
    YAxis rightAxis = mChart.getAxisRight();
    rightAxis.setTypeface(tf);
    rightAxis.setDrawGridLines(false);
    
    Legend l = mChart.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);       
    mChart.setExtraBottomOffset(16f);
    
    return v;
}
 
Example 2
Source File: CalibrationLinearityActivity.java    From NoiseCapture with GNU General Public License v3.0 5 votes vote down vote up
private void initScatter() {
    final ScatterChart scatterChart = getScatterChart();
    if(scatterChart == null) {
        return;
    }
    scatterChart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Show
            AlertDialog.Builder builder = new AlertDialog.Builder(CalibrationLinearityActivity.this);
            builder.setTitle(CalibrationLinearityActivity.this.getText(R.string.calibration_select_frequency));
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(CalibrationLinearityActivity.this,
                    R.array.calibrate_type_list_array, android.R.layout.simple_selectable_list_item);
            builder.setAdapter(adapter,
                    new ItemActionOnClickListener(CalibrationLinearityActivity.this, scatterChart));
            builder.show();
        }
    });

    scatterChart.setDescription("");

    scatterChart.setDrawGridBackground(false);

    scatterChart.setMaxVisibleValueCount(200);

    Legend l = scatterChart.getLegend();
    l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
    l.setTextColor(Color.WHITE);

    YAxis yl = scatterChart.getAxisLeft();
    yl.setTextColor(Color.WHITE);
    yl.setGridColor(Color.WHITE);
    scatterChart.getAxisRight().setEnabled(false);

    XAxis xl = scatterChart.getXAxis();
    xl.setDrawGridLines(false);
    xl.setTextColor(Color.WHITE);
    xl.setGridColor(Color.WHITE);
}
 
Example 3
Source File: ScatterChartActivity.java    From Stayfit with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_scatterchart);

    tvX = (TextView) findViewById(R.id.tvXMax);
    tvY = (TextView) findViewById(R.id.tvYMax);

    mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBarX.setOnSeekBarChangeListener(this);

    mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
    mSeekBarY.setOnSeekBarChangeListener(this);

    mChart = (ScatterChart) findViewById(R.id.chart1);
    mChart.setDescription("");

    tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

    mChart.setOnChartValueSelectedListener(this);

    mChart.setDrawGridBackground(false);

    mChart.setTouchEnabled(true);

    // enable scaling and dragging
    mChart.setDragEnabled(true);
    mChart.setScaleEnabled(true);

    mChart.setMaxVisibleValueCount(200);
    mChart.setPinchZoom(true);

    mSeekBarX.setProgress(45);
    mSeekBarY.setProgress(100);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.RIGHT_OF_CHART);
    l.setTypeface(tf);

    YAxis yl = mChart.getAxisLeft();
    yl.setTypeface(tf);
    yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
    
    mChart.getAxisRight().setEnabled(false);

    XAxis xl = mChart.getXAxis();
    xl.setTypeface(tf);
    xl.setDrawGridLines(false);
}