本文整理汇总了Java中com.github.mikephil.charting.data.BarData.setValueTextColor方法的典型用法代码示例。如果您正苦于以下问题:Java BarData.setValueTextColor方法的具体用法?Java BarData.setValueTextColor怎么用?Java BarData.setValueTextColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarData
的用法示例。
在下文中一共展示了BarData.setValueTextColor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
private void setData() {
RealmResults<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "floatValue"); // stacked entries
set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
set.setLabel("Mobile OS distribution");
set.setStackLabels(new String[]{"iOS", "Android", "Other"});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
data.setValueTextColor(Color.WHITE);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
示例2: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
mDashboardHelper = new DashboardHelper(getActivity());
HashMap<String, ArrayList> holder = mDashboardHelper.generateTimesPerDayMap();
ArrayList<String> xVals = holder.get("dayOfThisMonth");
ArrayList<BarEntry> yVals1 = holder.get("episodesPerDay");
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例3: refreshWeekBeforeSteps
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
private DefaultChartsData refreshWeekBeforeSteps(DBHandler db, CombinedChart combinedChart, Calendar day, GBDevice device) {
ActivityAnalysis analysis = new ActivityAnalysis();
day = (Calendar) day.clone(); // do not modify the caller's argument
day.add(Calendar.DATE, -7);
List<BarEntry> entries = new ArrayList<>();
List<String> labels = new ArrayList<>();
for (int counter = 0; counter < 7; counter++) {
entries.add(new BarEntry(analysis.calculateTotalSteps(getSamplesOfDay(db, day, device)), counter));
labels.add(day.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, mLocale));
day.add(Calendar.DATE, 1);
}
BarDataSet set = new BarDataSet(entries, "");
set.setColor(akActivity.color);
BarData barData = new BarData(labels, set);
barData.setValueTextColor(Color.GRAY); //prevent tearing other graph elements with the black text. Another approach would be to hide the values cmpletely with data.setDrawValues(false);
LimitLine target = new LimitLine(mTargetSteps);
combinedChart.getAxisLeft().removeAllLimitLines();
combinedChart.getAxisLeft().addLimitLine(target);
CombinedData combinedData = new CombinedData(labels);
combinedData.setData(barData);
return new DefaultChartsData(combinedData);
}
示例4: showAnalysis
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void showAnalysis(Report report) {
List<BarEntry> barEntries = new ArrayList<>();
List<Expense> expenses = report.getExpenses();
for (int i = 0; i < expenses.size(); i++) {
Expense expense = expenses.get(i);
barEntries.add(new BarEntry(
i,
expense.getAmount().floatValue())
);
}
BarDataSet barSet = new BarDataSet(barEntries, "");
barSet.setColor(selectedCategory.getColor());
List<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(barSet);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setValueTextColor(getOutlayTheme().secondaryTextColor);
data.setBarWidth(0.9f);
dayAxisValueFormatter.setExpenses(expenses);
barChart.setData(data);
barChart.invalidate();
barChart.animateY(500);
}
示例5: createBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry((val == 0 ? 1 : val), i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColor(0xFF2196f3);
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例6: createStackedBarChartData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
public BarData createStackedBarChartData()
{
NumberFormat numberFormat = NumberFormat.getInstance();
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(2);
ArrayList<String> xVals = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
xVals.add(i + "");
}
ArrayList<BarEntry> yVals1 = new ArrayList<>();
for(int i = 0; i < 12; i++)
{
float mult = (5 + 1);
int val = (int) (Math.random() * mult);
yVals1.add(new BarEntry(new float[] {(val == 0 ? 1 : val - 1), 1}, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setColors(new int[] {0xFF2196f3, 0xFF3f51b5});
set1.setBarSpacePercent(40f);
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10);
data.setValueTypeface(Typeface.create("sans-serif-medium", Typeface.BOLD));
data.setValueTextColor(Color.WHITE);
data.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> numberFormat.format(
value));
return data;
}
示例7: getView
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
BarData data = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
data.setValueTypeface(mTfLight);
data.setValueTextColor(Color.BLACK);
holder.chart.getDescription().setEnabled(false);
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(15f);
// set data
holder.chart.setData(data);
holder.chart.setFitBars(true);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700);
return convertView;
}
示例8: getView
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
BarData data = getItem(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item_barchart, null);
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// apply styling
data.setValueTypeface(mTf);
data.setValueTextColor(Color.BLACK);
holder.chart.setDescription("");
holder.chart.setDrawGridBackground(false);
XAxis xAxis = holder.chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTf);
xAxis.setDrawGridLines(false);
YAxis leftAxis = holder.chart.getAxisLeft();
leftAxis.setTypeface(mTf);
leftAxis.setLabelCount(5, false);
leftAxis.setSpaceTop(15f);
YAxis rightAxis = holder.chart.getAxisRight();
rightAxis.setTypeface(mTf);
rightAxis.setLabelCount(5, false);
rightAxis.setSpaceTop(15f);
// set data
holder.chart.setData(data);
// do not forget to refresh the chart
// holder.chart.invalidate();
holder.chart.animateY(700, Easing.EasingOption.EaseInCubic);
return convertView;
}