use of com.github.mikephil.charting.components.XAxis in project MPAndroidChart by PhilJay.
the class ScatterChartFrag method onCreateView.
@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.getDescription().setEnabled(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
// For bounds control
mv.setChartView(mChart);
mChart.setMarker(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;
}
use of com.github.mikephil.charting.components.XAxis in project MPAndroidChart by PhilJay.
the class SineCosineFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_line, container, false);
mChart = (LineChart) v.findViewById(R.id.lineChart1);
mChart.getDescription().setEnabled(false);
mChart.setDrawGridBackground(false);
mChart.setData(generateLineData());
mChart.animateX(3000);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf");
Legend l = mChart.getLegend();
l.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setAxisMaximum(1.2f);
leftAxis.setAxisMinimum(-1.2f);
mChart.getAxisRight().setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
return v;
}
use of com.github.mikephil.charting.components.XAxis in project MPAndroidChart by PhilJay.
the class BarChartItem method getView.
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
holder.chart.setDrawBarShadow(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(20f);
// this replaces setStartAtZero(true)
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(20f);
// this replaces setStartAtZero(true)
rightAxis.setAxisMinimum(0f);
mChartData.setValueTypeface(mTf);
// set data
holder.chart.setData((BarData) mChartData);
holder.chart.setFitBars(true);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700);
return convertView;
}
use of com.github.mikephil.charting.components.XAxis in project MPAndroidChart by PhilJay.
the class LineChartItem method getView.
@Override
public View getView(int position, View convertView, Context c) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(c).inflate(R.layout.list_item_linechart, null);
holder.chart = (LineChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
// holder.chart.setValueTypeface(mTf);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(5, false);
// this replaces setStartAtZero(true)
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(5, false);
rightAxis.setDrawGridLines(false);
// this replaces setStartAtZero(true)
rightAxis.setAxisMinimum(0f);
// set data
holder.chart.setData((LineData) mChartData);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateX(750);
return convertView;
}
use of com.github.mikephil.charting.components.XAxis 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);
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.getDescription().setEnabled(false);
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
mChart.setMaxHighlightDistance(50f);
// 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.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(false);
l.setTypeface(mTfLight);
l.setXOffset(5f);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
// this replaces setStartAtZero(true)
yl.setAxisMinimum(0f);
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setTypeface(mTfLight);
xl.setDrawGridLines(false);
}
Aggregations