com.github.mikephil.charting.formatter.ValueFormatter Java Examples
The following examples show how to use
com.github.mikephil.charting.formatter.ValueFormatter.
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: FragmentTimeBarChart.java From fingen with Apache License 2.0 | 5 votes |
private ValueFormatter getValueFormatter() { if (isShrinkValues()) { return largeValuesFormatter; } else { return mormalValuesFormatter; } }
Example #2
Source File: Utils.java From NetKnight with Apache License 2.0 | 5 votes |
/** * If this component has no ValueFormatter or is only equipped with the * default one (no custom set), return true. * * @return */ public static boolean needsDefaultFormatter(ValueFormatter formatter) { if (formatter == null) return true; if (formatter instanceof DefaultValueFormatter) return true; return false; }
Example #3
Source File: ChartData.java From NetKnight with Apache License 2.0 | 5 votes |
/** * Sets a custom ValueFormatter for all DataSets this data object contains. * * @param f */ public void setValueFormatter(ValueFormatter f) { if (f == null) return; else { for (IDataSet set : mDataSets) { set.setValueFormatter(f); } } }
Example #4
Source File: BaseDataSet.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public void setValueFormatter(ValueFormatter f) { if (f == null) return; else mValueFormatter = f; }
Example #5
Source File: Utils.java From Stayfit with Apache License 2.0 | 5 votes |
/** * If this component has no ValueFormatter or is only equipped with the * default one (no custom set), return true. * * @return */ public static boolean needsDefaultFormatter(ValueFormatter formatter) { if (formatter == null) return true; if (formatter instanceof DefaultValueFormatter) return true; return false; }
Example #6
Source File: ChartData.java From Stayfit with Apache License 2.0 | 5 votes |
/** * Sets a custom ValueFormatter for all DataSets this data object contains. * * @param f */ public void setValueFormatter(ValueFormatter f) { if (f == null) return; else { for (IDataSet set : mDataSets) { set.setValueFormatter(f); } } }
Example #7
Source File: BaseDataSet.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void setValueFormatter(ValueFormatter f) { if (f == null) return; else mValueFormatter = f; }
Example #8
Source File: ChartData.java From iMoney with Apache License 2.0 | 5 votes |
/** * Sets a custom ValueFormatter for all DataSets this data object contains. * * @param f */ public void setValueFormatter(ValueFormatter f) { if (f == null) return; else { for (DataSet<?> set : mDataSets) { set.setValueFormatter(f); } } }
Example #9
Source File: XYMarkerView.java From StockChart-MPAndroidChart with MIT License | 5 votes |
public XYMarkerView(Context context, ValueFormatter xAxisValueFormatter) { super(context, R.layout.custom_marker_view); this.xAxisValueFormatter = xAxisValueFormatter; tvContent = findViewById(R.id.tvContent); format = new DecimalFormat("###.0"); }
Example #10
Source File: KLineChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * 副图指标RSI */ public void setRSIToChart() { if (barChart != null) { if (barChart.getBarData() != null) { barChart.getBarData().clearValues(); } if (barChart.getLineData() != null) { barChart.getLineData().clearValues(); } if (barChart.getCandleData() != null) { barChart.getCandleData().clearValues(); } axisLeftBar.resetAxisMaximum(); axisLeftBar.resetAxisMinimum(); axisLeftBar.setValueFormatter(new ValueFormatter() { @Override public String getAxisLabel(float value, AxisBase axis) { return NumberUtils.keepPrecision(value, precision); } }); CombinedData combinedData = barChart.getData(); combinedData.setData(new LineData(kLineData.getLineDataRSI())); barChart.notifyDataSetChanged(); barChart.invalidate(); } }
Example #11
Source File: KLineChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * 副图指标BOLL */ public void setBOLLToChart() { if (barChart != null) { if (barChart.getBarData() != null) { barChart.getBarData().clearValues(); } if (barChart.getLineData() != null) { barChart.getLineData().clearValues(); } if (barChart.getCandleData() != null) { barChart.getCandleData().clearValues(); } axisLeftBar.resetAxisMaximum(); axisLeftBar.resetAxisMinimum(); axisLeftBar.setValueFormatter(new ValueFormatter() { @Override public String getAxisLabel(float value, AxisBase axis) { return NumberUtils.keepPrecision(value, precision); } }); CombinedData combinedData = barChart.getData(); combinedData.setData(new CandleData(kLineData.getBollCandleDataSet())); combinedData.setData(new LineData(kLineData.getLineDataBOLL())); barChart.notifyDataSetChanged(); barChart.invalidate(); } }
Example #12
Source File: KLineChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * 副图指标KDJ */ public void setKDJToChart() { if (barChart != null) { if (barChart.getBarData() != null) { barChart.getBarData().clearValues(); } if (barChart.getLineData() != null) { barChart.getLineData().clearValues(); } if (barChart.getCandleData() != null) { barChart.getCandleData().clearValues(); } axisLeftBar.resetAxisMaximum(); axisLeftBar.resetAxisMinimum(); axisLeftBar.setValueFormatter(new ValueFormatter() { @Override public String getAxisLabel(float value, AxisBase axis) { return NumberUtils.keepPrecision(value, precision); } }); CombinedData combinedData = barChart.getData(); combinedData.setData(new LineData(kLineData.getLineDataKDJ())); barChart.notifyDataSetChanged(); barChart.invalidate(); } }
Example #13
Source File: KLineChart.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * 副图指标MACD */ public void setMACDToChart() { if (barChart != null) { if (barChart.getBarData() != null) { barChart.getBarData().clearValues(); } if (barChart.getLineData() != null) { barChart.getLineData().clearValues(); } if (barChart.getCandleData() != null) { barChart.getCandleData().clearValues(); } axisLeftBar.resetAxisMaximum(); axisLeftBar.resetAxisMinimum(); axisLeftBar.setValueFormatter(new ValueFormatter() { @Override public String getAxisLabel(float value, AxisBase axis) { return NumberUtils.keepPrecision(value, precision); } }); CombinedData combinedData = barChart.getData(); combinedData.setData(new LineData(kLineData.getLineDataMACD())); combinedData.setData(new BarData(kLineData.getBarDataMACD())); barChart.notifyDataSetChanged(); barChart.invalidate(); } }
Example #14
Source File: FragmentBarChart.java From fingen with Apache License 2.0 | 5 votes |
private ValueFormatter getValueFormatter() { if (isShrinkValues()) { return largeValuesFormatter; } else { return mormalValuesFormatter; } }
Example #15
Source File: FragmentPieChart.java From fingen with Apache License 2.0 | 5 votes |
private ValueFormatter getValueFormatter() { if (isShrinkValues()) { return largeValuesFormatter; } else { return mormalValuesFormatter; } }
Example #16
Source File: BaseDataSet.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public void setValueFormatter(ValueFormatter f) { if (f == null) { return; } else { mValueFormatter = f; } }
Example #17
Source File: BaseDataSet.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override public ValueFormatter getValueFormatter() { if (needsFormatter()) { return Utils.getDefaultValueFormatter(); } return mValueFormatter; }
Example #18
Source File: ChartData.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * Sets a custom IValueFormatter for all DataSets this data object contains. * * @param f */ public void setValueFormatter(ValueFormatter f) { if (f == null) { return; } else { for (IDataSet set : mDataSets) { set.setValueFormatter(f); } } }
Example #19
Source File: PieChartRenderer.java From iMoney with Apache License 2.0 | 4 votes |
@Override public void drawValues(Canvas c) { PointF center = mChart.getCenterCircleBox(); // get whole the radius float r = mChart.getRadius(); float rotationAngle = mChart.getRotationAngle(); float[] drawAngles = mChart.getDrawAngles(); float[] absoluteAngles = mChart.getAbsoluteAngles(); float off = r / 10f * 3.6f; if (mChart.isDrawHoleEnabled()) { off = (r - (r / 100f * mChart.getHoleRadius())) / 2f; } r -= off; // offset to keep things inside the chart PieData data = mChart.getData(); List<PieDataSet> dataSets = data.getDataSets(); boolean drawXVals = mChart.isDrawSliceTextEnabled(); int cnt = 0; for (int i = 0; i < dataSets.size(); i++) { PieDataSet dataSet = dataSets.get(i); if (!dataSet.isDrawValuesEnabled() && !drawXVals) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); float lineHeight = Utils.calcTextHeight(mValuePaint, "Q") + Utils.convertDpToPixel(4f); List<Entry> entries = dataSet.getYVals(); for (int j = 0, maxEntry = Math.min( (int) Math.ceil(entries.size() * mAnimator.getPhaseX()), entries.size()); j < maxEntry; j++) { Entry entry = entries.get(j); // offset needed to center the drawn text in the slice float offset = drawAngles[cnt] / 2; // calculate the text position float x = (float) (r * Math.cos(Math.toRadians((rotationAngle + absoluteAngles[cnt] - offset) * mAnimator.getPhaseY())) + center.x); float y = (float) (r * Math.sin(Math.toRadians((rotationAngle + absoluteAngles[cnt] - offset) * mAnimator.getPhaseY())) + center.y); float value = mChart.isUsePercentValuesEnabled() ? entry.getVal() / data.getYValueSum() * 100f : entry.getVal(); ValueFormatter formatter = dataSet.getValueFormatter(); boolean drawYVals = dataSet.isDrawValuesEnabled(); // draw everything, depending on settings if (drawXVals && drawYVals) { drawValue(c, formatter, value, entry, 0, x, y); if (j < data.getXValCount()) c.drawText(data.getXVals().get(j), x, y + lineHeight, mValuePaint); } else if (drawXVals && !drawYVals) { if (j < data.getXValCount()) c.drawText(data.getXVals().get(j), x, y + lineHeight / 2f, mValuePaint); } else if (!drawXVals && drawYVals) { drawValue(c, formatter, value, entry, 0, x, y + lineHeight / 2f); } cnt++; } } }
Example #20
Source File: ChartMeasurementView.java From openScale with GNU General Public License v3.0 | 4 votes |
private void setXValueFormat(final ViewMode mode) { getXAxis().setValueFormatter(new ValueFormatter() { private final SimpleDateFormat xValueFormat = new SimpleDateFormat(); private final Calendar calendar = Calendar.getInstance(); @Override public String getAxisLabel(float value, AxisBase axis) { calendar.setTime(new Date(0)); switch (mode) { case DAY_OF_MONTH: calendar.set(Calendar.DAY_OF_MONTH, (int)value); xValueFormat.applyLocalizedPattern("dd"); break; case WEEK_OF_MONTH: calendar.set(Calendar.WEEK_OF_MONTH, (int)value); xValueFormat.applyLocalizedPattern("'W'W"); break; case WEEK_OF_YEAR: calendar.set(Calendar.WEEK_OF_YEAR, (int)value); xValueFormat.applyLocalizedPattern("'W'w"); break; case MONTH_OF_YEAR: calendar.set(Calendar.MONTH, (int)value); xValueFormat.applyLocalizedPattern("MMM"); break; case DAY_OF_YEAR: calendar.set(Calendar.DAY_OF_YEAR, (int)value); xValueFormat.applyLocalizedPattern("D"); break; case DAY_OF_ALL: calendar.setTime(convertShortInDate((int)value)); return DateFormat.getDateInstance(DateFormat.SHORT).format(calendar.getTime()); case WEEK_OF_ALL: calendar.setTime(convertShortInDate((int)value)); xValueFormat.applyLocalizedPattern("'W'w yyyy"); return xValueFormat.format(calendar.getTime()); case MONTH_OF_ALL: calendar.setTime(convertShortInDate((int)value)); xValueFormat.applyLocalizedPattern("MMM yyyy"); return xValueFormat.format(calendar.getTime()); case YEAR_OF_ALL: calendar.setTime(convertShortInDate((int)value)); xValueFormat.applyLocalizedPattern("yyyy"); return xValueFormat.format(calendar.getTime()); default: throw new IllegalArgumentException("view mode not implemented"); } return xValueFormat.format(calendar.getTime()); } }); }
Example #21
Source File: HourlyActivity.java From weather with Apache License 2.0 | 4 votes |
private void setChartValues(List<ItemHourlyDB> itemHourlyDBList) { List<Entry> entries = new ArrayList<>(); int i = 0; if (AppUtil.isRTL(this)) { int j = itemHourlyDBList.size() - 1; while (j >= 0) { entries.add(new Entry(i, (float) itemHourlyDBList.get(j).getTemp())); i++; j--; } } else { for (ItemHourlyDB itemHourlyDB : itemHourlyDBList) { entries.add(new Entry(i, (float) itemHourlyDB.getTemp())); i++; } } LineDataSet dataSet = new LineDataSet(entries, "Label"); // add entries to dataset dataSet.setLineWidth(4f); dataSet.setCircleRadius(7f); dataSet.setHighlightEnabled(false); dataSet.setCircleColor(Color.parseColor("#33b5e5")); dataSet.setValueTextSize(12); dataSet.setValueTextColor(Color.WHITE); dataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER); dataSet.setValueTypeface(typeface); dataSet.setValueFormatter(new ValueFormatter() { @Override public String getFormattedValue(float value) { return String.format(Locale.getDefault(), "%.0f", value); } }); LineData lineData = new LineData(dataSet); chart.getDescription().setEnabled(false); chart.getAxisLeft().setDrawLabels(false); chart.getAxisRight().setDrawLabels(false); chart.getXAxis().setDrawLabels(false); chart.getLegend().setEnabled(false); // Hide the legend chart.getXAxis().setDrawGridLines(false); chart.getAxisLeft().setDrawGridLines(false); chart.getAxisRight().setDrawGridLines(false); chart.getAxisLeft().setDrawAxisLine(false); chart.getAxisRight().setDrawAxisLine(false); chart.getXAxis().setDrawAxisLine(false); chart.setScaleEnabled(false); chart.setData(lineData); chart.animateY(1000); }
Example #22
Source File: BaseDataSet.java From NetKnight with Apache License 2.0 | 4 votes |
@Override public ValueFormatter getValueFormatter() { if (mValueFormatter == null) return new DefaultValueFormatter(1); return mValueFormatter; }
Example #23
Source File: BaseDataSet.java From Stayfit with Apache License 2.0 | 4 votes |
@Override public ValueFormatter getValueFormatter() { if (mValueFormatter == null) return new DefaultValueFormatter(1); return mValueFormatter; }
Example #24
Source File: Utils.java From StockChart-MPAndroidChart with MIT License | 4 votes |
private static ValueFormatter generateDefaultValueFormatter() { return new DefaultValueFormatter(1); }
Example #25
Source File: DataSet.java From iMoney with Apache License 2.0 | 4 votes |
/** * Returns the formatter used for drawing the values inside the chart. * * @return */ public ValueFormatter getValueFormatter() { if (mValueFormatter == null) return new DefaultValueFormatter(1); return mValueFormatter; }
Example #26
Source File: RadarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override public void drawValues(Canvas c) { float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); float sliceangle = mChart.getSliceAngle(); // calculate the factor that is needed for transforming the value to // pixels float factor = mChart.getFactor(); MPPointF center = mChart.getCenterOffsets(); MPPointF pOut = MPPointF.getInstance(0, 0); MPPointF pIcon = MPPointF.getInstance(0, 0); float yoffset = Utils.convertDpToPixel(5f); for (int i = 0; i < mChart.getData().getDataSetCount(); i++) { IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i); if (!shouldDrawValues(dataSet)) { continue; } // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); ValueFormatter formatter = dataSet.getValueFormatter(); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < dataSet.getEntryCount(); j++) { RadarEntry entry = dataSet.getEntryForIndex(j); Utils.getPosition( center, (entry.getY() - mChart.getYChartMin()) * factor * phaseY, sliceangle * j * phaseX + mChart.getRotationAngle(), pOut); if (dataSet.isDrawValuesEnabled()) { drawValue(c, formatter.getRadarLabel(entry), pOut.x, pOut.y - yoffset, dataSet.getValueTextColor(j)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.getPosition( center, (entry.getY()) * factor * phaseY + iconsOffset.y, sliceangle * j * phaseX + mChart.getRotationAngle(), pIcon); //noinspection SuspiciousNameCombination pIcon.y += iconsOffset.x; Utils.drawImage( c, icon, (int) pIcon.x, (int) pIcon.y, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } MPPointF.recycleInstance(center); MPPointF.recycleInstance(pOut); MPPointF.recycleInstance(pIcon); }
Example #27
Source File: LineChartTime.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_linechart_time); setTitle("LineChartTime"); tvX = findViewById(R.id.tvXMax); seekBarX = findViewById(R.id.seekBar1); seekBarX.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); // no description text chart.getDescription().setEnabled(false); // enable touch gestures chart.setTouchEnabled(true); chart.setDragDecelerationFrictionCoef(0.9f); // enable scaling and dragging chart.setDragEnabled(true); chart.setScaleEnabled(true); chart.setDrawGridBackground(false); chart.setHighlightPerDragEnabled(true); // set an alternative background color chart.setBackgroundColor(Color.WHITE); chart.setViewPortOffsets(0f, 0f, 0f, 0f); // add data seekBarX.setProgress(100); // get the legend (only possible after setting data) Legend l = chart.getLegend(); l.setEnabled(false); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxis.XAxisPosition.TOP_INSIDE); xAxis.setTypeface(tfLight); xAxis.setTextSize(10f); xAxis.setTextColor(Color.WHITE); xAxis.setDrawAxisLine(false); xAxis.setDrawGridLines(true); xAxis.setTextColor(Color.rgb(255, 192, 56)); xAxis.setCenterAxisLabels(true); xAxis.setGranularity(1f); // one hour xAxis.setValueFormatter(new ValueFormatter() { private final SimpleDateFormat mFormat = new SimpleDateFormat("dd MMM HH:mm", Locale.ENGLISH); @Override public String getFormattedValue(float value) { long millis = TimeUnit.HOURS.toMillis((long) value); return mFormat.format(new Date(millis)); } }); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART); leftAxis.setTypeface(tfLight); leftAxis.setTextColor(ColorTemplate.getHoloBlue()); leftAxis.setDrawGridLines(true); leftAxis.setGranularityEnabled(true); leftAxis.setAxisMinimum(0f); leftAxis.setAxisMaximum(170f); leftAxis.setYOffset(-9f); leftAxis.setTextColor(Color.rgb(255, 192, 56)); YAxis rightAxis = chart.getAxisRight(); rightAxis.setEnabled(false); }
Example #28
Source File: Utils.java From StockChart-MPAndroidChart with MIT License | 4 votes |
public static ValueFormatter getDefaultValueFormatter() { return mDefaultValueFormatter; }
Example #29
Source File: ScatterChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override public void drawValues(Canvas c) { // if values are drawn if (isDrawingValuesAllowed(mChart)) { List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets(); for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) { IScatterDataSet dataSet = dataSets.get(i); if (!shouldDrawValues(dataSet) || dataSet.getEntryCount() < 1) continue; // apply the text-styling defined by the DataSet applyValueTextStyle(dataSet); mXBounds.set(mChart, dataSet); float[] positions = mChart.getTransformer(dataSet.getAxisDependency()) .generateTransformedValuesScatter(dataSet, mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max); float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize()); ValueFormatter formatter = dataSet.getValueFormatter(); MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset()); iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x); iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y); for (int j = 0; j < positions.length; j += 2) { if (!mViewPortHandler.isInBoundsRight(positions[j])) break; // make sure the lines don't do shitty things outside bounds if ((!mViewPortHandler.isInBoundsLeft(positions[j]) || !mViewPortHandler.isInBoundsY(positions[j + 1]))) continue; Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min); if (dataSet.isDrawValuesEnabled()) { drawValue(c, formatter.getPointLabel(entry), positions[j], positions[j + 1] - shapeSize, dataSet.getValueTextColor(j / 2 + mXBounds.min)); } if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) { Drawable icon = entry.getIcon(); Utils.drawImage( c, icon, (int) (positions[j] + iconsOffset.x), (int) (positions[j + 1] + iconsOffset.y), icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); } } MPPointF.recycleInstance(iconsOffset); } } }
Example #30
Source File: BarChartActivity.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@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("BarChartActivity"); tvX = findViewById(R.id.tvXMax); tvY = findViewById(R.id.tvYMax); seekBarX = findViewById(R.id.seekBar1); seekBarY = findViewById(R.id.seekBar2); seekBarY.setOnSeekBarChangeListener(this); seekBarX.setOnSeekBarChangeListener(this); chart = findViewById(R.id.chart1); chart.setOnChartValueSelectedListener(this); chart.setDrawBarShadow(false); chart.setDrawValueAboveBar(true); chart.getDescription().setEnabled(false); // if more than 60 entries are displayed in the chart, no values will be // drawn chart.setMaxVisibleValueCount(60); // scaling can now only be done on x- and y-axis separately chart.setPinchZoom(false); chart.setDrawGridBackground(false); // chart.setDrawYLabels(false); ValueFormatter xAxisFormatter = new DayAxisValueFormatter(chart); XAxis xAxis = chart.getXAxis(); xAxis.setPosition(XAxisPosition.BOTTOM); xAxis.setTypeface(tfLight); xAxis.setDrawGridLines(false); xAxis.setGranularity(1f); // only intervals of 1 day xAxis.setLabelCount(7); xAxis.setValueFormatter(xAxisFormatter); ValueFormatter custom = new MyValueFormatter("$"); YAxis leftAxis = chart.getAxisLeft(); leftAxis.setTypeface(tfLight); leftAxis.setLabelCount(8, false); leftAxis.setValueFormatter(custom); leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART); leftAxis.setSpaceTop(15f); leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) YAxis rightAxis = chart.getAxisRight(); rightAxis.setDrawGridLines(false); rightAxis.setTypeface(tfLight); rightAxis.setLabelCount(8, false); rightAxis.setValueFormatter(custom); rightAxis.setSpaceTop(15f); rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true) Legend l = chart.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); XYMarkerView mv = new XYMarkerView(this, xAxisFormatter); mv.setChartView(chart); // For bounds control chart.setMarker(mv); // Set the marker to the chart // setting data seekBarY.setProgress(50); seekBarX.setProgress(12); // chart.setDrawLegend(false); }