本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setColors方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setColors方法的具体用法?Java BarDataSet.setColors怎么用?Java BarDataSet.setColors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.setColors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
protected BarData generateBarData(int dataSets, float range, int count) {
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
for(int i = 0; i < dataSets; i++) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
for(int j = 0; j < count; j++) {
entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
BarData d = new BarData(ChartData.generateXVals(0, count), sets);
d.setValueTypeface(tf);
return d;
}
示例2: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
protected BarData generateBarData(int dataSets, float range, int count) {
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
for(int i = 0; i < dataSets; i++) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
for(int j = 0; j < count; j++) {
entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
BarData d = new BarData(sets);
d.setValueTypeface(tf);
return d;
}
示例3: generateData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (float) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(sets);
cd.setBarWidth(0.9f);
return cd;
}
示例4: generateDataBar
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateDataBar(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry(i, (int) (Math.random() * 70) + 30));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setHighLightAlpha(255);
BarData cd = new BarData(d);
cd.setBarWidth(0.9f);
return cd;
}
示例5: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(int count) {
ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * count) + 15;
yVals.add(new BarEntry(i, (int) val));
}
BarDataSet set = new BarDataSet(yVals, "Data Set");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setDrawValues(false);
BarData data = new BarData(set);
mChart.setData(data);
mChart.invalidate();
mChart.animateY(800);
}
示例6: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData(List<Integer> progressSoFar) {
ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());
DateTime dateTime = new DateTime();
referenceTime = dateTime.minusDays(7).getMillis();
int totalSeconds = 0;
for (int i = 0; i < progressSoFar.size(); i++) {
int progress = progressSoFar.get(i);
barEntries.add(new BarEntry(i, progress));
totalSeconds += progress;
}
activityTotal.setText(context.getString(R.string.total_project_time,
FormatUtils.getFormattedTime(context, totalSeconds)));
BarDataSet barDataSet = new BarDataSet(barEntries, "");
barDataSet.setColors(blue400);
BarData barData = new BarData(barDataSet);
barData.setBarWidth(0.85f);
barData.setDrawValues(false);
return barData;
}
示例7: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateBarData(int dailyGoal, List<Integer> progressSoFar) {
ArrayList<BarEntry> barEntries = new ArrayList<>(progressSoFar.size());
DateTime dateTime = new DateTime();
referenceTime = dateTime.minusDays(7).getMillis();
for (int i = 0; i < progressSoFar.size(); i++) {
barEntries.add(new BarEntry(i, progressSoFar.get(i)));
}
BarDataSet barDataSet = new BarDataSet(barEntries, "");
int colors[] = new int[progressSoFar.size()];
for (int i = 0; i < progressSoFar.size(); i++) {
colors[i] = (progressSoFar.get(i) >= dailyGoal * 60 * 60) ? green400 : red400;
}
barDataSet.setColors(colors);
BarData barData = new BarData(barDataSet);
barData.setBarWidth(0.85f);
barData.setDrawValues(false);
return barData;
}
示例8: generateData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateData(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setBarSpacePercent(20f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setBarShadowColor(Color.rgb(203, 203, 203));
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
sets.add(d);
BarData cd = new BarData(getMonths(), sets);
return cd;
}
示例9: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Generate bar data bar data.
*
* @param dataSets the data sets
* @param range the range
* @param count the count
* @return the bar data
*/
protected BarData generateBarData(int dataSets, float range, int count) {
ArrayList<IBarDataSet> sets = new ArrayList<IBarDataSet>();
for(int i = 0; i < dataSets; i++) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
for(int j = 0; j < count; j++) {
entries.add(new BarEntry(j, (float) (Math.random() * range) + range / 4));
}
BarDataSet ds = new BarDataSet(entries, getLabel(i));
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
sets.add(ds);
}
BarData d = new BarData(sets);
d.setValueTypeface(tf);
return d;
}
示例10: generateDataBar
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* generates a random ChartData object with just one DataSet
*
* @return
*/
private BarData generateDataBar(int cnt) {
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < 12; i++) {
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
}
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
d.setBarSpacePercent(20f);
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
d.setHighLightAlpha(255);
BarData cd = new BarData(getMonths(), d);
return cd;
}
示例11: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(int count) {
ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * count) + 15;
yVals.add(new BarEntry((int) val, i));
xVals.add((int) val + "");
}
BarDataSet set = new BarDataSet(yVals, "Data Set");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setDrawValues(false);
BarData data = new BarData(xVals, set);
mChart.setData(data);
mChart.invalidate();
mChart.animateY(800);
}
示例12: getBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
public BarData getBarData() {
ArrayList<BarEntry> entries = new ArrayList<>();
float overall_people = 100f;
Log.d(TAG + "barData", barRatingCount[3] + "");
entries.add(new BarEntry(4, barRatingCount[4]));
entries.add(new BarEntry(3, barRatingCount[3]));
entries.add(new BarEntry(2, barRatingCount[2]));
entries.add(new BarEntry(1, barRatingCount[1]));
entries.add(new BarEntry(0, barRatingCount[0]));
BarDataSet dataset = new BarDataSet(entries, "");
dataset.setColors(CUSTOM_COLOR);
dataset.setDrawValues(false);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(dataset);
BarData data = new BarData(dataSets);
// data.setValueTextSize(10f);
// data.setValueTypeface(fontType);
data.setBarWidth(1f);
return data;
}
示例13: setCategoriesBarChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setCategoriesBarChart() {
List<String> categoriesNames = new ArrayList<>();
List<BarEntry> entryPerCategory = new ArrayList<>();
for (int i=0; i < mCategoryList.size(); i++) {
float value = Expense.getCategoryTotalByDate(DateManager.getInstance().getDateFrom(), DateManager.getInstance().getDateTo(), mCategoryList.get(i));
if (value > 0) {
categoriesNames.add(mCategoryList.get(i).getName());
entryPerCategory.add(new BarEntry(value, categoriesNames.size()-1));
}
}
if (categoriesNames.isEmpty()) {
tvBcCategoriesEmpty.setVisibility(View.VISIBLE);
bcCategories.setVisibility(View.GONE);
} else {
tvBcCategoriesEmpty.setVisibility(View.GONE);
bcCategories.setVisibility(View.VISIBLE);
}
BarDataSet dataSet = new BarDataSet(entryPerCategory, getString(R.string.categories));
dataSet.setColors(Util.getListColors());
BarData barData = new BarData(categoriesNames, dataSet);
bcCategories.setData(barData);
bcCategories.invalidate();
}
示例14: getBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData getBarData(FinishedExercise finishedExercise) {
List<FinishedSet> sets = finishedExercise.getSets();
List<BarEntry> entries = new ArrayList<>();
for (int i = 0; i < sets.size(); i++) {
int reps = sets.get(i).getReps();
int maxReps = sets.get(i).getMaxReps();
int openReps = maxReps - reps;
entries.add(new BarEntry(i, new float[]{reps, openReps}));
}
BarDataSet set = new BarDataSet(entries, "sets");
int textColor = activity.getResources().getColor(R.color.primaryTextColor);
set.setValueTextColor(textColor);
set.setValueTextSize(12);
set.setColors(getColors());
BarData barData = new BarData(set);
barData.setValueFormatter(new HideZeroValueFormatter());
return barData;
}
示例15: showBarChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void showBarChart(List<Exam> exams){
pieChart.setVisibility(View.GONE);
barChart.setVisibility(View.VISIBLE);
Map<String, Integer> gradeCount = calculateGradeDistribution(exams);
List<BarEntry> entries = new ArrayList<>();
for(int i = 0; i < GRADES.length; i++){
entries.add(new BarEntry(i, gradeCount.get(GRADES[i])));
}
BarDataSet set = new BarDataSet(entries, getString(R.string.grades_without_weight));
set.setColors(GRADE_COLORS, this);
BarData data = new BarData(set);
barChart.setData(data);
barChart.setFitBars(true);
XAxis xAxis = barChart.getXAxis();
xAxis.setGranularity(1);
xAxis.setValueFormatter((value, axis) -> GRADES[(int)value]);
barChart.setDescription(null);
barChart.invalidate();
}