本文整理汇总了Java中com.github.mikephil.charting.components.YAxis.setValueFormatter方法的典型用法代码示例。如果您正苦于以下问题:Java YAxis.setValueFormatter方法的具体用法?Java YAxis.setValueFormatter怎么用?Java YAxis.setValueFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.YAxis
的用法示例。
在下文中一共展示了YAxis.setValueFormatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupYAxis
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setupYAxis()
{
int valuesSelectedItemPos = cache.getValuesSpinner().getSelectedItemPosition();
YAxis leftAxis = this.chart.getAxisLeft();
leftAxis.setLabelCount(10, false);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(20f);
leftAxis.setAxisMinValue(0f);
leftAxis.setValueFormatter(new PFAYAxisLabels(context, valuesSelectedItemPos, cache.getNumberScale()));
if ( valuesSelectedItemPos == StatisticsQuery.QUANTITY )
{
leftAxis.setGranularity(1f); // interval 1
}
YAxis rightAxis = this.chart.getAxisRight();
rightAxis.setEnabled(false);
}
示例2: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.getDescription().setEnabled(false);
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
示例3: setData
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = "reception rate per second";
if (!format.equals("%"))
legend = "packet count per second";
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例4: setup
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
protected void setup(Chart<?> chart) {
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
// no description text
chart.setDescription("");
chart.setNoDataTextDescription("You need to provide data for the chart.");
// enable touch gestures
chart.setTouchEnabled(true);
if (chart instanceof BarLineChartBase) {
BarLineChartBase mChart = (BarLineChartBase) chart;
mChart.setDrawGridBackground(false);
// enable scaling and dragging
mChart.setDragEnabled(true);
mChart.setScaleEnabled(true);
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
leftAxis.setTypeface(mTf);
leftAxis.setTextSize(8f);
leftAxis.setTextColor(Color.DKGRAY);
leftAxis.setValueFormatter(new PercentFormatter());
XAxis xAxis = mChart.getXAxis();
xAxis.setTypeface(mTf);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setTextSize(8f);
xAxis.setTextColor(Color.DKGRAY);
mChart.getAxisRight().setEnabled(false);
}
}
示例5: setData
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
if (valueList != null) {
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!format.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例6: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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);
}
示例7: setData
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* update data for visualization chart
*
* @param valueList list of values for the chart
* @param unit data unit
*/
private void setData(List<Integer> valueList, String unit) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!unit.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(unit);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例8: configureWeatherChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Configure styles of weather charts.
*
* @param entries chart data.
* @param formatter value formatter.
* @param minVal min value to show.
* @param maxVal max value to show.
* @return chart formatted.
*/
private LineDataSet configureWeatherChart(
LineChart chart, int chartName, int colorLineTempChart, int colorFillTempChart,
List<Entry> entries, IAxisValueFormatter formatter, double minVal, double maxVal) {
LineDataSet lineDataSet = new LineDataSet(entries, getString(chartName));
lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
lineDataSet.setDrawValues(false);
lineDataSet.setValueTextSize(10f);
lineDataSet.setDrawCircles(false);
lineDataSet.setLineWidth(1.8f);
lineDataSet.setColor(ContextCompat.getColor(getContext(), colorLineTempChart));
lineDataSet.setLineWidth(2f);
lineDataSet.setDrawFilled(true);
lineDataSet.setFillColor(ContextCompat.getColor(getContext(), colorFillTempChart));
lineDataSet.setFillAlpha(255);
// General setup
chart.setDrawGridBackground(false);
chart.setDrawBorders(false);
chart.setViewPortOffsets(0, 0, 0, 0);
chart.getDescription().setEnabled(false);
chart.getLegend().setEnabled(false);
chart.setTouchEnabled(false);
// X axis setup
XAxis xAxis = chart.getXAxis();
xAxis.setEnabled(false);
xAxis.setAxisMinimum(0);
xAxis.setAxisMaximum(lastTimestamp);
// Y axis setup
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setEnabled(false);
leftAxis.setAxisMaximum((float) (maxVal));
leftAxis.setAxisMinimum((float) (minVal));
YAxis rightAxis = chart.getAxisRight();
rightAxis.setAxisMaximum((float) (maxVal));
rightAxis.setAxisMinimum((float) (minVal));
rightAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
rightAxis.setValueFormatter(formatter);
return lineDataSet;
}
示例9: getFormattedLineChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
/**
* Formats a line chart in a standardized manner
* @param c App context
* @param chart LineChart to format
* @param listener Listener to attach to chart
* @param xLabels Labels to use for the x-axis
* @param valueFormatter True if large value formatter should be used
* @param skip Number of values to skip
* @param legend True if show legend, false if hide legend
* @return Formatted linechart
*/
public static LineChart getFormattedLineChart(Context c, LineChart chart, OnChartValueSelectedListener listener, List<String> xLabels, boolean valueFormatter, int skip, boolean legend) {
Legend cLegend = chart.getLegend();
cLegend.setEnabled(legend);
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(skip);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setValueFormatter(new XAxisLabelFormatter(xLabels));
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setEnabled(false);
YAxis yAxisLeft = chart.getAxisLeft();
if (valueFormatter) {
yAxisLeft.setValueFormatter(new LargeNumberAxisFormatter(c));
}
if (SettingsActivity.getTheme(c) == SettingsActivity.THEME_NOIR) {
int textColorNoir = ContextCompat.getColor(c, R.color.colorPrimaryTextNoir);
cLegend.setTextColor(textColorNoir);
xAxis.setTextColor(textColorNoir);
yAxisLeft.setTextColor(textColorNoir);
}
chart.setDoubleTapToZoomEnabled(false);
chart.setDescription(EMPTY_CHART_DESCRIPTION);
chart.setDragEnabled(true);
chart.setScaleYEnabled(false);
chart.setDrawGridBackground(false);
chart.setOnChartValueSelectedListener(listener);
return chart;
}
示例10: setupChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setupChart() {
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(true);
mChart.setDescription("");
mChart.setMaxVisibleValueCount(60);
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);
YAxisValueFormatter custom = new PercentFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setLabelCount(8, false);
leftAxis.setValueFormatter(custom);
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinValue(0f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setLabelCount(8, false);
rightAxis.setValueFormatter(custom);
rightAxis.setSpaceTop(15f);
rightAxis.setAxisMinValue(0f);
Legend legend = mChart.getLegend();
legend.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
legend.setForm(Legend.LegendForm.CIRCLE);
legend.setFormSize(9f);
legend.setTextSize(11f);
legend.setXEntrySpace(4f);
mChart.animateXY(1000, 1000);
}
示例11: initChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void initChart() {
barChart.setDrawBarShadow(false);
barChart.setDrawValueAboveBar(true);
barChart.getDescription().setEnabled(false);
barChart.setPinchZoom(false);
barChart.setMaxVisibleValueCount(60);
barChart.getLegend().setEnabled(false);
barChart.setDrawGridBackground(false);
barChart.getAxisRight().setEnabled(false);
barChart.setScaleYEnabled(false);
dayAxisValueFormatter = new DayAxisValueFormatter();
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setLabelRotationAngle(270);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
xAxis.setTextColor(getOutlayTheme().secondaryTextColor);
xAxis.setValueFormatter(dayAxisValueFormatter);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setValueFormatter(new AmountValueFormatter());
leftAxis.setPosition(YAxis.YAxisLabelPosition.OUTSIDE_CHART);
leftAxis.setTextColor(getOutlayTheme().secondaryTextColor);
leftAxis.setSpaceTop(15f);
leftAxis.setAxisMinimum(0f);
}
示例12: onCreate
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的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.components.YAxis; //导入方法依赖的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);
}
示例14: setUpBarChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setUpBarChart() {
BarData barData = generateBarData(project.getTimeSpent());
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setAxisLineColor(Color.WHITE);
xAxis.setTextColor(Color.WHITE);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
xAxis.setAxisLineWidth(2f);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.setDrawGridLines(false);
leftAxis.setAxisLineColor(Color.WHITE);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setGranularity(60 * 60);
leftAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
int hours = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(value));
return (hours == 0)
? "" : context.getString(R.string.hours, hours);
}
});
leftAxis.setAxisLineWidth(2f);
int maxYData = (int) (Math.ceil(barData.getYMax()) + 3600);
leftAxis.setAxisMaximum(maxYData);
leftAxis.setAxisMinimum(0f);
CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
barChart.setMarker(customMarkerView);
barChart.getAxisRight().setEnabled(false);
barChart.getLegend().setEnabled(false);
barChart.getDescription().setEnabled(false);
barChart.setBackground(context.getResources().getDrawable(R.color.colorPrimaryDark));
barChart.setDrawGridBackground(false);
barChart.setDragEnabled(false);
barChart.setScaleEnabled(false);
barChart.setDragDecelerationEnabled(false);
barChart.setPinchZoom(false);
barChart.setDoubleTapToZoomEnabled(false);
barChart.setDrawBorders(false);
barChart.setData(barData);
customMarkerView.setChartView(barChart);
barChart.setVisibility(View.VISIBLE);
barChart.animateY(1500, Easing.EasingOption.Linear);
}
示例15: setUpBarChart
import com.github.mikephil.charting.components.YAxis; //导入方法依赖的package包/类
private void setUpBarChart(int dailyGoal, List<Integer> progressSoFar) {
BarData barData = generateBarData(dailyGoal, progressSoFar);
//Set up a limit line indicating the goal
LimitLine limitLine = new LimitLine(dailyGoal * 60 * 60, context.getString(R.string.goal));
limitLine.setLineWidth(4f);
limitLine.setLineColor(blue400);
limitLine.setTextSize(12f);
limitLine.setTextColor(Color.WHITE);
//Format Xaxis
XAxis xAxis = goalBarChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawGridLines(false);
xAxis.setAxisLineColor(Color.WHITE);
xAxis.setTextColor(Color.WHITE);
xAxis.setGranularity(1f);
xAxis.setValueFormatter(new FormatUtils().getBarXAxisValueFormatterInstance(referenceTime));
xAxis.setAxisLineWidth(2f);
//Format Yaxis
YAxis leftAxis = goalBarChart.getAxisLeft();
leftAxis.removeAllLimitLines();
leftAxis.addLimitLine(limitLine);
leftAxis.setDrawGridLines(false);
leftAxis.setAxisLineColor(Color.WHITE);
leftAxis.setTextColor(Color.WHITE);
leftAxis.setGranularity(60 * 60);
leftAxis.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
/* Do not display zero value and format the value as time*/
return (value == 0)
? "" : FormatUtils.getFormattedTime(context, (int) value);
}
});
leftAxis.setAxisLineWidth(2f);
//Set a maximum value on purpose so that marker view is visible
int maximum;
int maxYData = (int) TimeUnit.SECONDS.toHours((long) Math.ceil(barData.getYMax()));
maximum = (maxYData > dailyGoal) ? maxYData : dailyGoal;
maximum += 2;
leftAxis.setAxisMaximum(maximum * 60 * 60);
leftAxis.setAxisMinimum(0f);
// Setup a marker view to display details of the selected dataItem
CustomMarkerView customMarkerView = new CustomMarkerView(context, R.layout.marker_view, referenceTime);
goalBarChart.setMarker(customMarkerView);
// Disable interactions
goalBarChart.getAxisRight().setEnabled(false);
goalBarChart.getLegend().setEnabled(false);
goalBarChart.getDescription().setEnabled(false);
goalBarChart.setBackgroundColor(windowColor);
goalBarChart.setDrawGridBackground(false);
goalBarChart.setDragEnabled(false);
goalBarChart.setScaleEnabled(false);
goalBarChart.setDragDecelerationEnabled(false);
goalBarChart.setPinchZoom(false);
goalBarChart.setDoubleTapToZoomEnabled(false);
goalBarChart.setDrawBorders(false);
goalBarChart.setData(barData);
customMarkerView.setChartView(goalBarChart);
goalBarChart.setVisibility(View.VISIBLE);
goalBarChart.animateY(1500, Easing.EasingOption.Linear);
}