Duplicate x-axis value in MPAndroidchart library

孤人 提交于 2019-12-25 07:14:08

问题


//map: {2-6-2016=[120.0], 27-5-2016=[100.0], 1-6-2016=[78.0, 59.0]}

LineChart lineChart = (LineChart) findViewById(R.id.chart);
 ArrayList<Entry> graphYValues = new ArrayList<>();
        ArrayList<String> xLabels = new ArrayList<String>();

for (Map.Entry<String, List<Float>> mapKeySet : map.entrySet()) {
                List<Float> lsValue = mapKeySet.getValue();

                for (float v : lsValue) {
                    graphYValues.add(new Entry(v, i));//value ,index
                   xLabels.add(mapKeySet.getKey());//if same label -x-axis have multiple y-axis value on same x-label axis
               }

                i++;
            }
   LineDataSet dataset = new LineDataSet(graphYValues,"Graph for "+spTestSubElement.getSelectedItem().toString());
 LineData data = new LineData(xLabels,dataset);
   lineChart.setData(data); 

It created duplicate entry for x-axis label.How can plot graph for multiple y values on same x-axis point ?How to solve this issue.

来源:https://stackoverflow.com/questions/37656960/duplicate-x-axis-value-in-mpandroidchart-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!