0
막대 그래프를 사용하여 단일 막대 종교 값을 표시하는 MPAndroid 차트 라이브러리에서 작업 중입니다. 나는 이슬람 "녹색", "기독교"= 파란색 등의 종교 이름마다 각 BarEntry에 색을주고 싶습니다.이 포럼에서 많은 예제를 검색했지만이를 해결할 수는 없습니다.막대 그래프 모음의 사용자 정의 색상 세트 MPAndroid 라이브러리
List<BarEntry> entries = new ArrayList<>();
entries.add(new BarEntry(0f, 20,"Islam"));
entries.add(new BarEntry(1f, 20,"Christianity"));
entries.add(new BarEntry(2f, 20,"Judaism"));
entries.add(new BarEntry(3f,20,"Sikhism"));
entries.add(new BarEntry(4f,20,"Hinduism"));
BarDataSet bSet = new BarDataSet(entries, "Marks");
bSet.setColors(ColorTemplate.VORDIPLOM_COLORS);
ArrayList<String> barFactors = new ArrayList<>();
barFactors.add("Islam");
barFactors.add("Christianity");
barFactors.add("Judaism");
barFactors.add("Sikhism");
barFactors.add("Hinduism");
XAxis xAxis = chart.getXAxis();
xAxis.setGranularity(1f);
xAxis.setGranularityEnabled(true);
BarData data = new BarData(bSet);
data.setBarWidth(1f); // set custom bar width
data.setValueTextSize(12);
Description description = new Description();
description.setTextColor(R.color.colorPrimary);
description.setText("Religion analysis");
chart.setDescription(description);
chart.setData(data);
chart.setFitBars(true); // make the x-axis fit exactly all bars
chart.invalidate(); // refresh
chart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(barFactors));
나는이 라이브러리 링크를 사용하고 있습니다 :
는implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
나는이 그림의 하단에 같은 색상 막대 색상을합니다. 이 문제를 어떻게 해결할 수 있습니까?