本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setDrawValues方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setDrawValues方法的具体用法?Java BarDataSet.setDrawValues怎么用?Java BarDataSet.setDrawValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.setDrawValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: generateBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* 柱形图数据
*/
private BarData generateBarData() {
BarData barData = new BarData();
ArrayList<BarEntry> entries1 = new ArrayList<>();
for (int index = 0; index < items.size(); index++) {
entries1.add(new BarEntry(index + 1f, (float) items.get(index).main_data.getData()));
}
BarDataSet barDataSet = new BarDataSet(entries1, "当前数据");
barDataSet.setValues(entries1);
barDataSet.setDrawValues(false);//是否在线上显示值
barDataSet.setColor(Color.rgb(230, 230, 230));
barDataSet.setHighLightColor(Color.parseColor(items.get(dateSelected).state.getColor()));
barDataSet.setValueTextColor(Color.rgb(60, 220, 78));
barDataSet.setValueTextSize(10f);
barDataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
float barWidth = 0.45f;
barData.addDataSet(barDataSet);
barData.setBarWidth(barWidth);
return barData;
}
示例3: 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);
}
示例4: generateOrderBarData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarData generateOrderBarData(List<MarketHistory> historyEntries) {
SimpleDateFormat format = new SimpleDateFormat("MMM dd", Locale.getDefault());
int size = historyEntries.size();
List<BarEntry> entries = new ArrayList<>(size);
List<String> xAxis = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
MarketHistory history = historyEntries.get(i);
Date recordDate = new Date(history.getRecordDate());
xAxis.add(format.format(recordDate));
entries.add(new BarEntry((float) history.getOrderCount(), i));
}
BarDataSet set = new BarDataSet(entries, "Order Count");
set.setColor(Color.parseColor("#99FF99"));
// set.setValueTextSize(0f);
set.setDrawValues(false);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
return new BarData(xAxis, set);
}
示例5: 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;
}
示例6: createActivitySet
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
protected BarDataSet createActivitySet(List<BarEntry> values, List<Integer> colors, String label) {
BarDataSet set1 = new BarDataSet(values, label);
set1.setColors(colors);
// set1.setDrawCubic(true);
// set1.setCubicIntensity(0.2f);
// //set1.setDrawFilled(true);
// set1.setDrawCircles(false);
// set1.setLineWidth(2f);
// set1.setCircleSize(5f);
// set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setDrawValues(false);
// set1.setHighLightColor(Color.rgb(128, 0, 255));
// set1.setColor(Color.rgb(89, 178, 44));
set1.setValueTextColor(CHART_TEXT_COLOR);
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
return set1;
}
示例7: createLightSleepSet
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
protected BarDataSet createLightSleepSet(List<BarEntry> values, String label) {
BarDataSet set1 = new BarDataSet(values, label);
// set1.setDrawCubic(true);
// set1.setCubicIntensity(0.2f);
// //set1.setDrawFilled(true);
// set1.setDrawCircles(false);
// set1.setLineWidth(2f);
// set1.setCircleSize(5f);
// set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setDrawValues(false);
// set1.setHighLightColor(Color.rgb(244, 117, 117));
// set1.setColor(Color.rgb(182, 191, 255));
set1.setValueTextColor(CHART_TEXT_COLOR);
// set1.setColor(Color.CYAN);
return set1;
}
示例8: onProgressChanged
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tvX.setText("" + (mSeekBarX.getProgress() + 1));
tvY.setText("" + (mSeekBarY.getProgress()));
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
float mult = (mSeekBarY.getProgress() + 1);
float val1 = (float) (Math.random() * mult) + mult / 3;
yVals1.add(new BarEntry((int) val1, i));
}
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
xVals.add((int) yVals1.get(i).getVal() + "");
}
BarDataSet set1 = new BarDataSet(yVals1, "Data Set");
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
set1.setDrawValues(false);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
mChart.setData(data);
mChart.invalidate();
}
示例9: createDeepSleepSet
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
protected BarDataSet createDeepSleepSet(List<BarEntry> values, String label) {
BarDataSet set1 = new BarDataSet(values, label);
// set1.setDrawCubic(true);
// set1.setCubicIntensity(0.2f);
// //set1.setDrawFilled(true);
// set1.setDrawCircles(false);
// set1.setLineWidth(2f);
// set1.setCircleSize(5f);
// set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setDrawValues(false);
// set1.setHighLightColor(Color.rgb(244, 117, 117));
// set1.setColor(Color.rgb(76, 90, 255));
set1.setValueTextColor(CHART_TEXT_COLOR);
return set1;
}
示例10: setupCommonChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private BarDataSet setupCommonChart(CustomBarChart chart, BarEntry entry, String title) {
chart.setSinglAnimationEntry(entry);
// chart.getXAxis().setPosition(XAxis.XAxisPosition.TOP);
chart.getXAxis().setDrawLabels(false);
chart.getXAxis().setEnabled(false);
chart.setBackgroundColor(BACKGROUND_COLOR);
chart.setDescriptionColor(DESCRIPTION_COLOR);
chart.setDescription(title);
chart.setNoDataTextDescription("");
chart.setNoDataText("");
chart.getAxisRight().setEnabled(false);
List<BarEntry> entries = new ArrayList<>();
List<String> xLabels = new ArrayList<>();
List<Integer> colors = new ArrayList<>();
entries.add(new BarEntry(0, 0));
entries.add(entry);
entries.add(new BarEntry(0, 2));
colors.add(akActivity.color);
colors.add(akActivity.color);
colors.add(akActivity.color);
//we don't want labels
xLabels.add("");
xLabels.add("");
xLabels.add("");
BarDataSet set = new BarDataSet(entries, "");
set.setDrawValues(false);
set.setColors(colors);
BarData data = new BarData(xLabels, set);
data.setGroupSpace(0);
chart.setData(data);
chart.getLegend().setEnabled(false);
return set;
}
示例11: setupSleepEventsChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setupSleepEventsChart(int sleep, int movement, int snore) {
HorizontalBarChart pieChart = (HorizontalBarChart) findViewById(R.id.sleepevents);
ArrayList<BarEntry> pieComp1 = new ArrayList<BarEntry>();
BarEntry c1e1 = new BarEntry(sleep, 0);
pieComp1.add(c1e1);
BarEntry c1e2 = new BarEntry(movement, 1);
pieComp1.add(c1e2);
BarEntry c1e3 = new BarEntry(snore, 1);
pieComp1.add(c1e3);
BarDataSet pieDataSet = new BarDataSet(pieComp1, "Sleep events");
pieDataSet.setColors(ColorTemplate.PASTEL_COLORS);
pieDataSet.setDrawValues(false);
ArrayList<String> xPieVals = new ArrayList<String>();
xPieVals.add("None");
xPieVals.add("Movement");
xPieVals.add("Snore");
BarData pieData = new BarData(xPieVals,pieDataSet);
pieData.setValueTextSize(14);
pieData.setValueTextColor(Color.WHITE);
pieChart.setData(pieData);
Legend pieLegend = pieChart.getLegend();
pieLegend.setEnabled(false);
pieChart.getAxisLeft().setEnabled(false);
pieChart.getAxisRight().setEnabled(false);
pieChart.setGridBackgroundColor(Color.parseColor("#52B19D"));
pieChart.setDescription("Sleep events");
pieChart.setHardwareAccelerationEnabled(true);
pieChart.setDrawBorders(false);
pieChart.invalidate();
}
示例12: initGradeDistributionChart
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Initializes the grade distribution bar chart.
*
* @param gradeDistribution array with grade distributions
*/
private void initGradeDistributionChart(int[] gradeDistribution) {
// y-values
ArrayList<BarEntry> yValues = new ArrayList<>();
for(int i = 0; i < gradeDistribution.length; i++) {
yValues.add(new BarEntry(gradeDistribution[i], i));
}
// x-values
ArrayList<String> xValues = new ArrayList<>();
xValues.add("1,0 - 1,3");
xValues.add("1,7 - 2,3");
xValues.add("2,7 - 3,3");
xValues.add("3,7 - 4,0");
xValues.add("4,3 - 5,0");
xValues.add("Andere");
BarDataSet dataSet = new BarDataSet(yValues, "");
dataSet.setValueTextSize(12);
dataSet.setValueTextColor(ContextCompat.getColor(getContext(), R.color.text87));
dataSet.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
dataSet.setDrawValues(true);
dataSet.setBarSpacePercent(35);
BarData barData = new BarData(xValues, dataSet);
barData.setValueFormatter(new DecimalValueFormatter("#"));
barData.setHighlightEnabled(false);
chartGradeDistribution.setData(barData);
setChartStyle(chartGradeDistribution);
chartGradeDistribution.getXAxis().setLabelsToSkip(0);
chartGradeDistribution.invalidate();
}
示例13: addEntries
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
public void addEntries(ArrayList<BarEntry> entries)
{
BarDataSet addData = new BarDataSet(entries, "");
addData.setDrawValues(false);
addData.setColor(0xFF2196F3);
this.data.addDataSet(addData);
}
示例14: generateMonthlyData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Заполнение графика данными
*/
private BarData generateMonthlyData() {
final Context ctx = getActivity();
// получение категорий
final String[] bars = ctx.getResources().getStringArray(R.array.categories);
// получение данных
final long month = getArguments().getLong(DB.TIMESTAMP);
List<Float> stats = DB.getStatData(ctx, month, bars.length); // Статистика за текущий месяц
final int count = stats.size();
ArrayList<BarEntry> entries = new ArrayList<>();
final ArrayList<String> usedBars = new ArrayList<>();
int j = 0;
for (int i = 0; i < count; i++) {
float value = stats.get(i);
if (value > 0f) {
usedBars.add(bars[i]);
entries.add(new BarEntry(value, j, bars[i]));
j++;
}
}
// данные графика
BarDataSet ds = new BarDataSet(entries, null);
ds.setDrawValues(true);
ds.setColor(getResources().getColor(R.color.accent));
// подписи к линиям графика
BarData d = new BarData(usedBars, ds);
d.setValueTextColor(getResources().getColor(R.color.primary_text));
d.setValueTextSize(14f);
d.setValueFormatter(new FinanceFormatter());
return d;
}
示例15: onCreateView
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.chart_frag, container, false);
// Set up timeline chart
chart = view.findViewById(R.id.timeline);
entries = new ArrayList<>();
// Set up the x-axis
XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
formatter = DateTimeFormatter.ofPattern("MMM d");
dates = new ArrayList<>();
int numDays = 14;
LocalDate today = LocalDate.now();
minimumDate = today.minusDays(numDays);
LocalDate currentDay = minimumDate;
dateMap = new HashMap<>();
for (int i = 0; i < numDays + 1; i++) {
float index = (float) i;
String dateString = currentDay.format(formatter);
dates.add(dateString);
dateMap.put(dateString, i);
BarEntry barEntry = new BarEntry(index, new float[] { 0, 0, 0, 0 });
entries.add(barEntry);
currentDay = currentDay.plusDays(1);
}
xAxis.setValueFormatter(new MyXAxisValueFormatter(dates));
xAxis.setLabelCount(numDays);
xAxis.setGranularity(1f);
xAxis.setLabelRotationAngle(45f);
UserAccount currentUser = HabitUpApplication.getCurrentUser();
// Get user events
ArrayList<HabitEvent> eventList = currentUser.getEventList().getEvents();
for (HabitEvent event : eventList) {
if (withinDateRange(event.getCompletedate(), minimumDate)) {
addChartEntry(event);
}
}
set = new BarDataSet(entries, "");
int red = Color.parseColor(Attributes.getColour("Physical"));
int purple = Color.parseColor(Attributes.getColour("Mental"));
int green = Color.parseColor(Attributes.getColour("Discipline"));
int blue = Color.parseColor(Attributes.getColour("Social"));
int[] colors = {red, purple, green, blue};
set.setColors(colors);
set.setStackLabels(new String[]{"Physical", "Mental", "Discipline", "Social"});
set.setDrawValues(false);
BarData data = new BarData(set);
data.setBarWidth(0.6f);
YAxis leftAxis = chart.getAxisLeft();
leftAxis.setValueFormatter(new MyYAxisValueFormatter());
leftAxis.setGranularity(1f);
leftAxis.setAxisMinimum(0f);
chart.getAxisRight().setEnabled(false);
chart.setData(data);
chart.setFitBars(true);
chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getDescription().setEnabled(false);
animateChart();
chart.invalidate();
return view;
}