use of com.github.mikephil.charting.data.BarDataSet in project Gadgetbridge by Freeyourgadget.
the class AbstractChartFragment method createLightSleepSet.
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;
}
use of com.github.mikephil.charting.data.BarDataSet in project Gadgetbridge by Freeyourgadget.
the class AbstractChartFragment method createActivitySet.
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;
}
use of com.github.mikephil.charting.data.BarDataSet in project LeMondeRssReader by MBach.
the class GraphExtractor method generate.
Object generate() {
BarChart barChart = new BarChart(context);
List<BarEntry> yVals1 = new ArrayList<>();
for (int i = 0; i < 30; i++) {
float mult = 5;
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(i, val));
}
BarDataSet set1 = new BarDataSet(yVals1, "The year 2017");
List<IBarDataSet> dataSets = new ArrayList<>();
dataSets.add(set1);
BarData barData = new BarData(dataSets);
barChart.setData(barData);
return barChart;
}
use of com.github.mikephil.charting.data.BarDataSet in project Thrift-box by Sash0k.
the class ChartsFragment method generateMonthlyData.
// ============================================================================
/**
* Заполнение графика данными
*/
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 = new DB(ctx).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;
}
use of com.github.mikephil.charting.data.BarDataSet in project android by lucadln.
the class ScoreChart method disposeHorizontalBarChart.
/**
* Method to set data and design for the bar chart
*/
public void disposeHorizontalBarChart(float[] scores, int[] correctConjugationsCount, int[] totalConjugationsCount) {
/* Set a custom renderer. This helps to show chart labels either
* inside or outside the chart bars depending on their values */
barChart.setRenderer(new CustomHorizontalBarChartRenderer(barChart, barChart.getAnimator(), barChart.getViewPortHandler(), scores));
barChart.invalidate();
// Add entry values for every tense
ArrayList<BarEntry> barEntries = new ArrayList<>();
for (int i = 0; i < tenses.length; i++) {
barEntries.add(new BarEntry((float) i, scores[i]));
}
// Create a data set from the entry values
BarDataSet dataSet = new BarDataSet(barEntries, "Tenses");
// Set data set values to be visible on the graph
dataSet.setDrawValues(true);
// Create a data object from the data set
BarData data = new BarData(dataSet);
// Set the width of the bars
data.setBarWidth(0.68f);
// Make the chart use the acquired data
barChart.setData(data);
// Display data as <correctAnswers>/<totalAnswers>
data.setValueFormatter(new CustomValueFormatter(correctConjugationsCount, totalConjugationsCount));
// Create explanation labels for each bar
final ArrayList<String> barLabels = new ArrayList<>();
barLabels.add("Present");
barLabels.add("Pres. Perfect");
barLabels.add("Simple Past");
barLabels.add("Past Perfect");
barLabels.add("Conditional");
barLabels.add("Cond. Perfect");
barLabels.add("Future");
// Display explanation labels
barChart.getXAxis().setValueFormatter(new IndexAxisValueFormatter(barLabels));
// Set the minimum and maximum bar values
barChart.getAxisLeft().setAxisMaximum(100);
barChart.getAxisLeft().setAxisMinimum(0);
// Set a color for each bar in the chart based on its value
setBarChartColors(scores);
// Animate chart so that bars are sliding from left to right
barChart.animateXY(1000, 1000);
// Hide grid lines
barChart.getAxisLeft().setEnabled(false);
barChart.getAxisRight().setEnabled(false);
// Hide graph description
barChart.getDescription().setEnabled(false);
// Hide graph legend
barChart.getLegend().setEnabled(false);
// Set colors and font style
dataSet.setColors(colors);
data.setValueTextSize(13f);
data.setValueTextColor(Color.DKGRAY);
}
Aggregations