2017-08-13 21 views
0

私はMPAndroidChartsライブラリを使用して円グラフを作成しています。すべては、私は黒のfontColorでValueTextColor円チャートのXValueTextフォントの色が変更されない

Pie_chart

Pie_chart(zoomed in)

XValuesLabelホワイトフォントの色で来ている

、およびYValueLabelに関する直面M、うまくただ一つの問題を行ってきました。私は黒い色で、それの両方をしたい、何とかsetValueTextColor() は助けてくださいXValuesLabel

Log.d("PIECHART dataset", "addDataSet started"); 
ArrayList yEntrys = new ArrayList<>(); 
ArrayList xEntrys = new ArrayList<>(); 

for(int i = 0; i < yData.length; i++){ 
    if(yData[i]>0) { 

    switch(i){ 
     case 0: 
      yEntrys.add(new PieEntry(yData[i], "banana")); 
      break; 
     case 1: 
      yEntrys.add(new PieEntry(yData[i], "guava")); 
      break; 
     case 2: 
      yEntrys.add(new PieEntry(yData[i], "apple")); 
      break; 
     case 3: 
      yEntrys.add(new PieEntry(yData[i], "pineapple")); 
      break; 
     case 4: 
      yEntrys.add(new PieEntry(yData[i], "mango")); 
      break; 
     case 5: 
      yEntrys.add(new PieEntry(yData[i], "papaya")); 
      break; 
     case 6: 
      yEntrys.add(new PieEntry(yData[i], "dates")); 
      break; 
     default : ; 
    } 

    } 
} 
//create the data set 

pieDataSet = new PieDataSet(yEntrys, ""); 
pieDataSet.setSliceSpace(2f); 
pieDataSet.setValueTextSize(15f); 
pieDataSet.setValueTextColor(Color.RED);/* this line not working */ 
pieDataSet.setSelectionShift(10f); 
pieDataSet.setValueLinePart1OffsetPercentage(80.f); 
pieDataSet.setValueLinePart1Length(1f); 
pieDataSet.setValueLinePart2Length(0.9f); 
pieDataSet.setXValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE); 
//pieDataSet.setYValuePosition(PieDataSet.ValuePosition.OUTSIDE_SLICE); 

//add colors to dataset 
ArrayList<Integer> colors = new ArrayList<>(); 
colors.add(Color.rgb(156,254,230)); 
colors.add(Color.rgb(159,185,235)); 
colors.add(Color.rgb(143,231,161)); 
colors.add(Color.rgb(160,239,136)); 
colors.add(Color.rgb(200,246,139)); 
colors.add(Color.rgb(176,219,233)); 
colors.add(Color.rgb(183,176,253)); 

pieDataSet.setColors(colors); 

///// disabling chart legend 
pieChart.getLegend().setEnabled(false); 

Log.d("PIECHART dataset2", xEntrys.size()+" "); 

//create pie data object 
PieData pieData = new PieData(pieDataSet); 
pieData.setValueTextColor(Color.RED);/* only YValue color changes, Xvalues   remains white*/ 
pieData.setValueFormatter(new valueFormat()); 
pieChart.setData(pieData); 
//pieDataSet.notifyDataSetChanged(); 
//pieChart.invalidate(); 

内の任意の影響を与えていません。おかげ

答えて

0

てみてください、これを追加する:

int colorBlack = Color.parseColor("#000000"); 
pieChart.setEntryLabelColor(colorBlack); 
+0

おかげでロットを、これは完全にうまく働いた。.. :) –

関連する問題