本文整理匯總了Java中com.github.mikephil.charting.charts.BarChart.getXAxis方法的典型用法代碼示例。如果您正苦於以下問題:Java BarChart.getXAxis方法的具體用法?Java BarChart.getXAxis怎麽用?Java BarChart.getXAxis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.mikephil.charting.charts.BarChart
的用法示例。
在下文中一共展示了BarChart.getXAxis方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
// create a new chart object
mChart = new BarChart(getActivity());
mChart.getDescription().setEnabled(false);
mChart.setOnChartGestureListener(this);
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
mChart.setData(generateBarData(1, 20000, 12));
Legend l = mChart.getLegend();
l.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
// programatically add the chart
FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout);
parent.addView(mChart);
return v;
}
示例2: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scrollview);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.getDescription().setEnabled(false);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getLegend().setEnabled(false);
setData(10);
mChart.setFitBars(true);
}
示例3: setHorizontalBarChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
* Set the horizontal bar pattern
* @param barChart chart
* @param chartData horizontal bar chart data
* @param jobs string array of job titles
* @param typeface Typeface font
*/
public static void setHorizontalBarChart(BarChart barChart, final ChartData<?> chartData,
final String[] jobs, Typeface typeface) {
barChart.setDrawGridBackground(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setLabelCount(jobs.length);
xAxis.setTypeface(typeface);
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
leftAxis.setGranularity(1f);
leftAxis.setDrawAxisLine(true);
leftAxis.setDrawGridLines(true);
YAxis axisRight = barChart.getAxisRight();
axisRight.setTypeface(typeface);
axisRight.setDrawAxisLine(true);
axisRight.setDrawGridLines(false);
axisRight.setGranularity(1f);
axisRight.setAxisMinimum(0f);
final Legend legend = barChart.getLegend();
legend.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
legend.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
legend.setOrientation(Legend.LegendOrientation.HORIZONTAL);
legend.setDrawInside(false);
legend.setFormSize(8f);
legend.setXEntrySpace(4f);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_LONG);
xAxis.setValueFormatter(new HorizontalBarValueFormatter(jobs));
}
示例4: setVerticalBarChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
* Set the vertical bar pattern
* @param barChart chart
* @param chartData pie chart data
* @param typeface Typeface font
*/
public static void setVerticalBarChart(Context context, BarChart barChart, ChartData<?> chartData,
Typeface typeface) {
// create a custom MarkerView (extend MarkerView) and specify the layout to use for it
ExperienceMarker marker = new ExperienceMarker(context, R.layout.marker_exp_age);
marker.setChartView(barChart); // For bounds control
barChart.setMarker(marker);
//fix crash com.github.mikephil.charting.charts.Chart.drawMarkers(Chart.java:731)
barChart.setDrawMarkers(false);
barChart.getDescription().setEnabled(false);
barChart.setDrawGridBackground(false);
barChart.setDrawBarShadow(false);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
//Sets the number of labels for the x-axis (display all the x-axis values)
// xAxis.setLabelCount(chartData.getEntryCount());
xAxis.setTypeface(typeface);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(true);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setTypeface(typeface);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinimum(0f);
YAxis rightAxis = barChart.getAxisRight();
rightAxis.setTypeface(typeface);
rightAxis.setSpaceTop(20f);
rightAxis.setAxisMinimum(0f);
chartData.setValueTypeface(typeface);
barChart.setData((BarData) chartData);
barChart.setFitBars(true);
barChart.animateY(DURATION_SHORT);
}
示例5: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_idpt, container, false);
BarChart chart = (BarChart) view.findViewById(R.id.chart);
BarData data = new BarData(getXAxisValues(), getDataSet());
//legend coding
Legend l=chart.getLegend();
l.setFormSize(10f);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setTextSize(12f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f);
l.setYEntrySpace(5f);
//l.setCustom();
XAxis xaxis=chart.getXAxis();
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xaxis.setTextSize(7f);
xaxis.setTextColor(Color.parseColor("#212121"));
xaxis.setDrawAxisLine(true);
xaxis.setDrawGridLines(false);
chart.setData(data);
chart.setDescription("");
chart.animateXY(2000, 2000);
chart.invalidate();
// chart.zoom(100, 10, 10, 10);
return view;
}
示例6: onCreateView
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
// create a new chart object
mChart = new BarChart(getActivity());
mChart.setDescription("");
mChart.setOnChartGestureListener(this);
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
mChart.setMarkerView(mv);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
mChart.setData(generateBarData(1, 20000, 12));
Legend l = mChart.getLegend();
l.setTypeface(tf);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(tf);
leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
// programatically add the chart
FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout);
parent.addView(mChart);
return v;
}
示例7: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_scrollview);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDescription("");
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setLabelsToSkip(0);
xAxis.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getLegend().setEnabled(false);
setData(10);
}
示例8: initChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void initChart(BarChart chart) {
float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setScaleXEnabled(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setPinchZoom(false);
chart.setHighlightPerDragEnabled(false);
chart.setHighlightPerTapEnabled(false);
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setDrawValueAboveBar(false);
chart.getAxisLeft().setEnabled(false);
XAxis xAxis = chart.getXAxis();
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
xAxis.setDrawLabels(false);
xAxis.setDrawLimitLinesBehindData(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis yAxis = chart.getAxisRight();
yAxis.setDrawAxisLine(false);
yAxis.setStartAtZero(false);
yAxis.setSpaceTop(10f);
yAxis.setSpaceBottom(0f);
yAxis.setTextSize(10 * scaledDensity);
yAxis.setTextColor(ContextCompat.getColor(this, R.color.text));
chart.getLegend().setEnabled(false);
chart.setDescription(" ");
chart.setNoDataText("Can't see sh*t captain!");
Paint p = chart.getPaint(Chart.PAINT_INFO);
DisplayMetrics dm = getResources().getDisplayMetrics();
int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, dm); //TODO use styles
p.setTextSize(size);
p.setColor(ContextCompat.getColor(this, R.color.gray600));
p.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
}
示例9: initChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
/**
* initiliaze chart
*/
private void initChart() {
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDescriptionColor(Color.parseColor("#000000"));
XAxis xAxis = mChart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setSpaceBetweenLabels(0);
YAxisValueFormatter custom = new DataAxisFormatter("%");
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setValueFormatter(custom);
rightAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setDrawGridLines(true);
rightAxis.setDrawGridLines(false);
mChart.animateY(1000);
mChart.getLegend().setEnabled(true);
mChart.setVisibility(View.GONE);
}
示例10: initChart
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void initChart() {
barChart = (BarChart)findViewById(R.id.chart);
barChart.setBorderColor(getResources().getColor(R.color.primary_dark));
barChart.setDrawBarShadow(false);
barChart.setDrawValueAboveBar(true);
barChart.setDescription("Operations/second");
barChart.setMaxVisibleValueCount(20);
barChart.setPinchZoom(false);
barChart.setDrawGridBackground(false);
XAxis xl = barChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(true);
xl.setGridLineWidth(0.3f);
YAxis yl = barChart.getAxisLeft();
yl.setDrawAxisLine(true);
yl.setDrawGridLines(true);
yl.setGridLineWidth(0.3f);
YAxis yr = barChart.getAxisRight();
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
Legend l = barChart.getLegend();
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setFormSize(8f);
l.setXEntrySpace(4f);
}
示例11: initBar
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
private void initBar() {
BarChart barChart = getBarChart();
if(barChart == null) {
return;
}
barChart.setDescription("");
barChart.setDrawGridBackground(false);
barChart.setMaxVisibleValueCount(200);
Legend l = barChart.getLegend();
l.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
l.setTextColor(Color.WHITE);
YAxis yl = barChart.getAxisLeft();
yl.setTextColor(Color.WHITE);
yl.setGridColor(Color.WHITE);
barChart.getAxisRight().setEnabled(false);
XAxis xl = barChart.getXAxis();
xl.setDrawGridLines(false);
xl.setTextColor(Color.WHITE);
xl.setGridColor(Color.WHITE);
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setDrawAxisLine(true);
xl.setLabelRotationAngle(-90);
xl.setDrawLabels(true);
xl.setLabelsToSkip(0);
}
示例12: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
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 = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(40);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(false);
mChart.setHighlightFullBarEnabled(false);
// change the position of the y-labels
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(new MyAxisValueFormatter());
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xLabels = mChart.getXAxis();
xLabels.setPosition(XAxisPosition.TOP);
// mChart.setDrawXLabels(false);
// mChart.setDrawYLabels(false);
// setting data
mSeekBarX.setProgress(12);
mSeekBarY.setProgress(100);
Legend l = mChart.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);
// mChart.setDrawLegend(false);
}
示例13: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_sinus);
mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
tvX = (TextView) findViewById(R.id.tvValueCount);
mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// if more than 60 entries are displayed in the chart, no values will be
// drawn
mChart.setMaxVisibleValueCount(60);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
// draw shadows for each bar that show the maximum value
// mChart.setDrawBarShadow(true);
// mChart.setDrawXLabels(false);
mChart.setDrawGridBackground(false);
// mChart.setDrawYLabels(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinimum(-2.5f);
leftAxis.setAxisMaximum(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinimum(-2.5f);
rightAxis.setAxisMaximum(2.5f);
rightAxis.setGranularity(0.1f);
mSeekBarX.setOnSeekBarChangeListener(this);
mSeekBarX.setProgress(150); // set data
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
l.setForm(LegendForm.SQUARE);
l.setFormSize(9f);
l.setTextSize(11f);
l.setXEntrySpace(4f);
mChart.animateXY(2000, 2000);
}
示例14: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart);
tvX = (TextView) findViewById(R.id.tvXMax);
tvX.setTextSize(10);
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 = (BarChart) findViewById(R.id.chart1);
mChart.setOnChartValueSelectedListener(this);
mChart.getDescription().setEnabled(false);
// mChart.setDrawBorders(true);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawBarShadow(false);
mChart.setDrawGridBackground(false);
// create a custom MarkerView (extend MarkerView) and specify the layout
// to use for it
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
mv.setChartView(mChart); // For bounds control
mChart.setMarker(mv); // Set the marker to the chart
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
Legend l = mChart.getLegend();
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
l.setOrientation(Legend.LegendOrientation.VERTICAL);
l.setDrawInside(true);
l.setTypeface(mTfLight);
l.setYOffset(0f);
l.setXOffset(10f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTfLight);
xAxis.setGranularity(1f);
xAxis.setCenterAxisLabels(true);
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return String.valueOf((int) value);
}
});
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setValueFormatter(new LargeValueFormatter());
leftAxis.setDrawGridLines(false);
leftAxis.setSpaceTop(35f);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
}
示例15: onCreate
import com.github.mikephil.charting.charts.BarChart; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_barchart_noseekbar);
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mChart = (BarChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setExtraTopOffset(-30f);
mChart.setExtraBottomOffset(10f);
mChart.setExtraLeftOffset(70f);
mChart.setExtraRightOffset(70f);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.getDescription().setEnabled(false);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
xAxis.setDrawAxisLine(false);
xAxis.setTextColor(Color.LTGRAY);
xAxis.setTextSize(13f);
xAxis.setLabelCount(5);
xAxis.setCenterAxisLabels(true);
xAxis.setGranularity(1f);
YAxis left = mChart.getAxisLeft();
left.setDrawLabels(false);
left.setSpaceTop(25f);
left.setSpaceBottom(25f);
left.setDrawAxisLine(false);
left.setDrawGridLines(false);
left.setDrawZeroLine(true); // draw a zero line
left.setZeroLineColor(Color.GRAY);
left.setZeroLineWidth(0.7f);
mChart.getAxisRight().setEnabled(false);
mChart.getLegend().setEnabled(false);
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
final List<Data> data = new ArrayList<>();
data.add(new Data(0f, -224.1f, "12-29"));
data.add(new Data(1f, 238.5f, "12-30"));
data.add(new Data(2f, 1280.1f, "12-31"));
data.add(new Data(3f, -442.3f, "01-01"));
data.add(new Data(4f, -2280.1f, "01-02"));
xAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
}
});
setData(data);
}