Android MPCharts条形图X标签和can';卷轴

Android MPCharts条形图X标签和can';卷轴,android,charts,mpandroidchart,Android,Charts,Mpandroidchart,我正在制作一个条形图,如下面的代码所示。然而,x标签“12:00”、“12:10”。。。没有显示在图表上。只有第一个显示(“12:00”) 我面临另一个问题。我在同一页上有两个图表,我无法向下滚动页面以查看仅部分显示的底部图表 BarChart bchart = view.findViewById(R.id.barChart); ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>(); yVals1.add(new B

我正在制作一个条形图,如下面的代码所示。然而,x标签“12:00”、“12:10”。。。没有显示在图表上。只有第一个显示(“12:00”)

我面临另一个问题。我在同一页上有两个图表,我无法向下滚动页面以查看仅部分显示的底部图表

BarChart bchart = view.findViewById(R.id.barChart);
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
yVals1.add(new BarEntry(0, 75));
yVals1.add(new BarEntry(10, 74));
yVals1.add(new BarEntry(20, 15));
yVals1.add(new BarEntry(30, 28));
yVals1.add(new BarEntry(40, 59));
yVals1.add(new BarEntry(50, 78));
yVals1.add(new BarEntry(60, 68));
yVals1.add(new BarEntry(70, 81));
yVals1.add(new BarEntry(80, 98));
yVals1.add(new BarEntry(90, 42));
yVals1.add(new BarEntry(100, 100));
BarDataSet set1;

//setting color
set1 = new BarDataSet(yVals1, "Satisfaction %");
set1.setColors(ColorTemplate.MATERIAL_COLORS);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);


String [] values = {"12:00", "12:10", "12:20", "12:30", "12:40", "12:50", "13:00"};
bchart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(values));
//Removing description
Description description = new Description();
description.setText("");
bchart.setDescription(description);
//Removing right y axis labels
YAxis rightYAxis = bchart.getAxisRight();
rightYAxis.setEnabled(false);
//Removing grid background
bchart.setDrawGridBackground(false);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setBarWidth(5f);
bchart.setTouchEnabled(false);
bchart.getAxisRight().setDrawLabels(false);
bchart.getXAxis().setDrawLabels(true);
bchart.getLegend().setEnabled(false);
bchart.setData(data);
BarChart bchart=view.findviewbyd(R.id.BarChart);
ArrayList yVals1=新的ArrayList();
yVals1.add(新巴伦特里(0,75));
yVals1.add(新巴伦特里(10,74));
yVals1.添加(新巴伦特里(20,15));
yVals1.添加(新巴伦特里(30,28));
yVals1.add(新巴伦特里(40,59));
yVals1.添加(新巴伦特里(50,78));
yVals1.添加(新巴伦特里(60,68));
yVals1.添加(新巴伦特里(70,81));
yVals1.add(新巴伦特里(80,98));
yVals1.添加(新巴伦特里(90,42));
yVals1.添加(新巴伦特里(100100));
BarDataSet set1;
//定色
set1=新的数据集(yVals1,“满意度%”);
set1.setColors(颜色模板.材料颜色);
ArrayList数据集=新的ArrayList();
数据集.add(set1);
字符串[]值={“12:00”、“12:10”、“12:20”、“12:30”、“12:40”、“12:50”、“13:00”};
bchart.getXAxis().setValueFormatter(新的IndexaxiValueFormatter(值));
//删除描述
Description Description=新的Description();
description.setText(“”);
bchart.setDescription(说明);
//删除右y轴标签
YAxis rightYAxis=bchart.getAxisRight();
rightYAxis.setEnabled(假);
//删除网格背景
bchart.setDrawGridBackground(假);
BarData数据=新的BarData(数据集);
data.setValueTextSize(10f);
数据。立根宽度(5f);
bchart.setTouchEnabled(假);
bchart.getAxisRight().setDrawLabels(false);
bchart.getXAxis().setDrawLabels(true);
bchart.getLegend().setEnabled(false);
b.设置数据(数据);

对于第一个问题,请遵循以下代码:

    ArrayList<String> labels = new ArrayList<String> ();

    labels.add( "12:00");
    labels.add( "12:10");
    labels.add( "12:20");
    labels.add( "12:30");
    labels.add( "12:40");
    labels.add( "12:50");

    XAxis xAxis = chart.getXAxis();
    xAxis.setValueFormatter(new IndexAxisValueFormatter(labels));
ArrayList标签=新的ArrayList();
标签。添加(“12:00”);
标签。添加(“12:10”);
标签。添加(“12:20”);
标签。添加(“12:30”);
标签。添加(“12:40”);
标签。添加(“12:50”);
XAxis XAxis=chart.getXAxis();
setValueFormatter(新的索引xisValueFormatter(标签));

对于第二个问题,您需要在view.xml中实现scrollview,作为正在创建图表视图的布局的父视图。

遗憾的是,这似乎没有帮助。传奇仍然没有出现在x轴上。你能分享一下你得到的截图吗?你能猜出来吗?