本文整理汇总了Java中com.github.mikephil.charting.components.XAxis.setDrawLabels方法的典型用法代码示例。如果您正苦于以下问题:Java XAxis.setDrawLabels方法的具体用法?Java XAxis.setDrawLabels怎么用?Java XAxis.setDrawLabels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.components.XAxis
的用法示例。
在下文中一共展示了XAxis.setDrawLabels方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dataSortedOnDay
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnDay(int year, int month, int dayOfMonth) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(-0.5f);
xaxis.setAxisMaximum(23.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.hour_of_day_string));
String path = String.format("/cow_data/%s/%d/%d/%d", cowId, year, month, dayOfMonth);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例2: dataSortedOnYear
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnYear(int year) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(12.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.month_of_year_string));
String path = String.format("/cow_data/%s/%d", cowId, year);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例3: dataSortedOnMonth
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void dataSortedOnMonth(int year, int month) {
if (graphValuesQuery != null)
graphValuesQuery.removeEventListener(graphValuesListener);
int iMonth = month - 1; // 1 (months begin with 0)
// Create a calendar object and set year and month
Calendar mycal = new GregorianCalendar(year, iMonth, 1);
// Get the number of days in that month
int daysInMonth = mycal.getActualMaximum(Calendar.DAY_OF_MONTH);
XAxis xaxis = chart.getXAxis();
//xaxis.setTextSize(18f);
xaxis.setDrawLabels(true);
xaxis.setAxisMinimum(0.5f);
xaxis.setAxisMaximum(daysInMonth + 0.5f);
xaxis.setPosition(XAxis.XAxisPosition.BOTTOM_INSIDE);
chart.getData().getDataSetByIndex(0).clear();
getBarData().getDataSetByIndex(0).setLabel(getString(R.string.day_of_month_string));
String path = String.format("/cow_data/%s/%d/%d", cowId, year, month);
graphValuesQuery = FirebaseHelper.getInstance().getDatabase().getReference().child(path).orderByKey();
graphValuesQuery.addChildEventListener(graphValuesListener);
}
示例4: setupActivityChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupActivityChart() {
mActivityChart.setBackgroundColor(BACKGROUND_COLOR);
mActivityChart.setDescriptionColor(DESCRIPTION_COLOR);
configureBarLineChartDefaults(mActivityChart);
XAxis x = mActivityChart.getXAxis();
x.setDrawLabels(true);
x.setDrawGridLines(false);
x.setEnabled(true);
x.setTextColor(CHART_TEXT_COLOR);
x.setDrawLimitLinesBehindData(true);
YAxis y = mActivityChart.getAxisLeft();
y.setDrawGridLines(false);
// y.setDrawLabels(false);
// TODO: make fixed max value optional
y.setAxisMaxValue(1f);
y.setAxisMinValue(0);
y.setDrawTopYLabelEntry(false);
y.setTextColor(CHART_TEXT_COLOR);
// y.setLabelCount(5);
y.setEnabled(true);
YAxis yAxisRight = mActivityChart.getAxisRight();
yAxisRight.setDrawGridLines(false);
yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
yAxisRight.setDrawLabels(true);
yAxisRight.setDrawTopYLabelEntry(true);
yAxisRight.setTextColor(CHART_TEXT_COLOR);
yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);
}
示例5: setupWeekStepsChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupWeekStepsChart() {
mWeekStepsChart.setBackgroundColor(BACKGROUND_COLOR);
mWeekStepsChart.setDescriptionColor(DESCRIPTION_COLOR);
mWeekStepsChart.setDescription("");
configureBarLineChartDefaults(mWeekStepsChart);
XAxis x = mWeekStepsChart.getXAxis();
x.setDrawLabels(true);
x.setDrawGridLines(false);
x.setEnabled(true);
x.setTextColor(CHART_TEXT_COLOR);
x.setDrawLimitLinesBehindData(true);
YAxis y = mWeekStepsChart.getAxisLeft();
y.setDrawGridLines(false);
y.setDrawTopYLabelEntry(false);
y.setTextColor(CHART_TEXT_COLOR);
y.setEnabled(true);
YAxis yAxisRight = mWeekStepsChart.getAxisRight();
yAxisRight.setDrawGridLines(false);
yAxisRight.setEnabled(false);
yAxisRight.setDrawLabels(false);
yAxisRight.setDrawTopYLabelEntry(false);
yAxisRight.setTextColor(CHART_TEXT_COLOR);
}
示例6: setupChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupChart() {
mChart.setBackgroundColor(BACKGROUND_COLOR);
mChart.setDescriptionColor(DESCRIPTION_COLOR);
configureBarLineChartDefaults(mChart);
XAxis x = mChart.getXAxis();
x.setDrawLabels(true);
x.setDrawGridLines(false);
x.setEnabled(true);
x.setTextColor(CHART_TEXT_COLOR);
x.setDrawLimitLinesBehindData(true);
YAxis y = mChart.getAxisLeft();
y.setDrawGridLines(false);
// y.setDrawLabels(false);
// TODO: make fixed max value optional
y.setAxisMaxValue(1f);
y.setAxisMinValue(0);
y.setDrawTopYLabelEntry(false);
y.setTextColor(CHART_TEXT_COLOR);
// y.setLabelCount(5);
y.setEnabled(true);
YAxis yAxisRight = mChart.getAxisRight();
yAxisRight.setDrawGridLines(false);
yAxisRight.setEnabled(supportsHeartrate(getChartsHost().getDevice()));
yAxisRight.setDrawLabels(true);
yAxisRight.setDrawTopYLabelEntry(true);
yAxisRight.setTextColor(CHART_TEXT_COLOR);
yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);
// refresh immediately instead of use refreshIfVisible(), for perceived performance
refresh();
}
示例7: initChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的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));
}
示例8: setUI
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
public void setUI() {
final Description des = new Description();
des.setText(".");
lineChart.setDescription(des);
lineChart.setDrawGridBackground(false);
lineChart.setExtraBottomOffset(-50);
XAxis x = lineChart.getXAxis();
x.setPosition(XAxis.XAxisPosition.TOP);
x.setDrawGridLines(false);
x.setDrawAxisLine(false);
x.setDrawLabels(true);
x.setYOffset(25);
x.setLabelRotationAngle(270);
x.setTextSize(12);
x.setTextColor(Color.WHITE);
x.setValueFormatter(new IAxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
// Date dt = new Date((long) value);
// Log.d(Const.TAG2, "sVF Next is "+dt.toString());
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
// String newValue = simpleDateFormat.format(dt);
// return Const.NO_BREAK + newValue;
if(uHi==(int)value){
return "";
}else {
uHi= (int) value;
}
Date d= new Date(dt[(int) value]);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(" hh:mm aaa");
String newValue = simpleDateFormat.format(d);
return Const.NO_BREAK + newValue;
}
});
YAxis yLeft = lineChart.getAxis(YAxis.AxisDependency.LEFT);
yLeft.setDrawGridLines(false);
yLeft.setDrawAxisLine(false);
yLeft.setDrawLabels(false);
YAxis yRight = lineChart.getAxis(YAxis.AxisDependency.RIGHT);
yRight.setDrawGridLines(false);
yRight.setDrawAxisLine(false);
yRight.setDrawLabels(false);
lineChart.setDoubleTapToZoomEnabled(false);
setData();
}
示例9: initChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
* 初始化报表
*
* @param showAnimation 是否显示动画
*/
void initChart(boolean showAnimation) {
int screenWidth = Utils.getScreenWidth(mContext);
combinedChart.getLayoutParams().height = screenWidth * 300 / 640;
//启用缩放和拖动
combinedChart.setDragEnabled(true);//拖动
combinedChart.setScaleEnabled(false);//缩放
combinedChart.setOnChartValueSelectedListener(this);
combinedChart.getDescription().setEnabled(false);
combinedChart.setBackgroundColor(ContextCompat.getColor(mContext, R.color.co10));
combinedChart.setDrawGridBackground(false);
combinedChart.setDrawBarShadow(false);
combinedChart.setHighlightFullBarEnabled(false);
Legend l = combinedChart.getLegend();
l.setForm(Legend.LegendForm.NONE);//底部样式
l.setTextColor(ContextCompat.getColor(mContext, R.color.transparent));
l.setWordWrapEnabled(false);
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
YAxis rightAxis = combinedChart.getAxisRight();
rightAxis.setEnabled(false);
YAxis leftAxis = combinedChart.getAxisLeft();
leftAxis.setDrawGridLines(false);
leftAxis.setGranularityEnabled(false);
leftAxis.setDrawAxisLine(false);
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
leftAxis.setTextColor(ContextCompat.getColor(mContext, R.color.co4));
updateTitle(items.get(dateSelected));
XAxis xAxis = combinedChart.getXAxis();
xAxis.setTypeface(mTfLight);
xAxis.setEnabled(true);//设置轴启用或禁用 如果禁用以下的设置全部不生效
xAxis.setDrawAxisLine(true);//是否绘制轴线
xAxis.setDrawGridLines(false);//设置x轴上每个点对应的线
xAxis.setDrawLabels(true);//绘制标签 指x轴上的对应数值
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);//设置x轴的显示位置
xAxis.setTextSize(10f); //设置X轴文字大小
xAxis.setGranularityEnabled(true);//是否允许X轴上值重复出现
xAxis.setTextColor(ContextCompat.getColor(this, R.color.co4));//设置X轴文字颜色
// //设置竖线的显示样式为虚线
// //lineLength控制虚线段的长度
// //spaceLength控制线之间的空间
xAxis.enableGridDashedLine(10f, 10f, 0f);
xAxis.setAxisMinimum(0f);//设置x轴的最小值
xAxis.setAxisMaximum(mDatas.length);//设置最大值
xAxis.setAvoidFirstLastClipping(true);//图表将避免第一个和最后一个标签条目被减掉在图表或屏幕的边缘
xAxis.setLabelRotationAngle(0f);//设置x轴标签字体的旋转角度
// 设置x轴显示标签数量 还有一个重载方法第二个参数为布尔值强制设置数量 如果启用会导致绘制点出现偏差
xAxis.setLabelCount(10);
xAxis.setGridLineWidth(10f);//设置竖线大小
// xAxis.setGridColor(Color.RED);//设置竖线颜色
xAxis.setAxisLineColor(Color.GRAY);//设置x轴线颜色
xAxis.setAxisLineWidth(1f);//设置x轴线宽度
CombinedData combinedData = new CombinedData();
combinedData.setData(generateLineData());
combinedData.setData(generateBarData());
combinedData.setValueTypeface(mTfLight);
xAxis.setAxisMaximum(combinedData.getXMax() + 0.25f);
//X轴的数据格式
ValueFormatter xAxisFormatter = new ValueFormatter(combinedChart);
xAxisFormatter.setmValues(xAxisValue);
xAxis.setValueFormatter(xAxisFormatter);//格式化x轴标签显示字符
combinedChart.setData(combinedData);
combinedChart.invalidate();
if (showAnimation) {
combinedChart.animateY(2000);
}
}
示例10: setupHistoryChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
private void setupHistoryChart(BarLineChartBase chart) {
configureBarLineChartDefaults(chart);
chart.setTouchEnabled(false); // no zooming or anything, because it's updated all the time
chart.setBackgroundColor(BACKGROUND_COLOR);
chart.setDescriptionColor(DESCRIPTION_COLOR);
chart.setDescription(getString(R.string.live_activity_steps_per_minute_history));
chart.setNoDataText(getString(R.string.live_activity_start_your_activity));
chart.getLegend().setEnabled(false);
Paint infoPaint = chart.getPaint(Chart.PAINT_INFO);
infoPaint.setTextSize(Utils.convertDpToPixel(20f));
infoPaint.setFakeBoldText(true);
chart.setPaint(infoPaint, Chart.PAINT_INFO);
XAxis x = chart.getXAxis();
x.setDrawLabels(true);
x.setDrawGridLines(false);
x.setEnabled(true);
x.setTextColor(CHART_TEXT_COLOR);
x.setDrawLimitLinesBehindData(true);
YAxis y = chart.getAxisLeft();
y.setDrawGridLines(false);
y.setDrawTopYLabelEntry(false);
y.setTextColor(CHART_TEXT_COLOR);
y.setEnabled(true);
y.setAxisMinValue(0);
YAxis yAxisRight = chart.getAxisRight();
yAxisRight.setDrawGridLines(false);
yAxisRight.setEnabled(true);
yAxisRight.setDrawLabels(true);
yAxisRight.setDrawTopYLabelEntry(false);
yAxisRight.setTextColor(CHART_TEXT_COLOR);
yAxisRight.setAxisMaxValue(HeartRateUtils.MAX_HEART_RATE_VALUE);
yAxisRight.setAxisMinValue(HeartRateUtils.MIN_HEART_RATE_VALUE);
mHistorySet = new LineDataSet(new ArrayList<Entry>(), getString(R.string.live_activity_steps_history));
mHistorySet.setAxisDependency(YAxis.AxisDependency.LEFT);
mHistorySet.setColor(akActivity.color);
mHistorySet.setDrawCircles(false);
mHistorySet.setDrawCubic(true);
mHistorySet.setDrawFilled(true);
mHistorySet.setDrawValues(false);
mHeartRateSet = createHeartrateSet(new ArrayList<Entry>(), getString(R.string.live_activity_heart_rate));
mHeartRateSet.setDrawValues(false);
}
示例11: setLineChartStylingAndRefreshChart
import com.github.mikephil.charting.components.XAxis; //导入方法依赖的package包/类
/**
* Set the line charts styling
*
* @param lineData the data to style
*/
private void setLineChartStylingAndRefreshChart(LineData lineData) {
// style axis
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setAxisMinValue(0f);
leftAxis.setDrawGridLines(false);
leftAxis.setTextSize(15);
YAxis rightAxis = chart.getAxisRight();
rightAxis.setDrawLabels(false);
rightAxis.setDrawGridLines(false);
XAxis xAxis = chart.getXAxis();
xAxis.setDrawGridLines(false);
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
xAxis.setDrawLabels(false);
// add threshold limit line
String thresholdDescription = "";
LimitLine limitLine = new LimitLine(100f, thresholdDescription);
limitLine.setLineColor(Color.RED);
limitLine.setLineWidth(1f);
limitLine.setTextColor(Color.RED);
limitLine.setTextSize(15f);
if (leftAxis.getLimitLines().size() < 1)
leftAxis.addLimitLine(limitLine);
// add legend
Legend l = chart.getLegend();
l.setFormSize(10f);
l.setForm(Legend.LegendForm.CIRCLE);
l.setPosition(Legend.LegendPosition.BELOW_CHART_LEFT);
l.setTextSize(12f);
l.setTextColor(Color.BLACK);
l.setXEntrySpace(5f);
l.setYEntrySpace(5f);
String[] labels = {Strings.getStringByRId(R.string.median_performance), Strings.getStringByRId(R.string.median_performance_forecast), Strings.getStringByRId(R.string.pre_operation_performance)};
int[] colors = {ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimary), ContextCompat.getColor(activity.getApplicationContext(), R.color.colorPrimaryLight), Color.RED};
l.setCustom(colors, labels);
// style chart and refresh
chart.setDescription("");
chart.setPinchZoom(false);
chart.setDoubleTapToZoomEnabled(false);
chart.setDrawGridBackground(false);
chart.setData(lineData);
chart.invalidate();
}