本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.setBarSpacePercent方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.setBarSpacePercent方法的具体用法?Java BarDataSet.setBarSpacePercent怎么用?Java BarDataSet.setBarSpacePercent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.setBarSpacePercent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: generateDataBar
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* 生成柱状图的数据
*/
private BarData generateDataBar() {
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 ");
// 设置柱状图之间的间距
d.setBarSpacePercent(20f);
// 设置显示的柱状图的颜色
d.setColors(ColorTemplate.VORDIPLOM_COLORS);
// 设置高亮的透明度:当点击柱状图时显示的透明度
d.setHighLightAlpha(255);
BarData cd = new BarData(getMonths(), d);
return cd;
}
示例4: dataSetConfig
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
void dataSetConfig(IDataSet<BarEntry> dataSet, ReadableMap config) {
BarDataSet barDataSet = (BarDataSet) dataSet;
ChartDataSetConfigUtils.commonConfig(barDataSet, config);
ChartDataSetConfigUtils.commonBarLineScatterCandleBubbleConfig(barDataSet, config);
if (BridgeUtils.validate(config, ReadableType.Number, "barSpacePercent")) {
barDataSet.setBarSpacePercent((float) config.getDouble("barSpacePercent"));
}
if (BridgeUtils.validate(config, ReadableType.String, "barShadowColor")) {
barDataSet.setBarShadowColor(Color.parseColor(config.getString("barShadowColor")));
}
if (BridgeUtils.validate(config, ReadableType.Number, "highlightAlpha")) {
barDataSet.setHighLightAlpha(config.getInt("highlightAlpha"));
}
if (BridgeUtils.validate(config, ReadableType.Array, "stackLabels")) {
barDataSet.setStackLabels(BridgeUtils.convertToStringArray(config.getArray("stackLabels")));
}
}
示例5: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = "reception rate per second";
if (!format.equals("%"))
legend = "packet count per second";
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例6: createBarChartData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的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;
}
示例7: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(int count, float range) {
ArrayList<String> xVals = new ArrayList<String>();
for (int i = 0; i < count; i++) {
xVals.add(mMonths[i % 12]);
}
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(val, i));
}
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
set1.setBarSpacePercent(35f);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(mTf);
mChart.setData(data);
}
示例8: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(int count) {
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
xVals.add(i+"");
entries.add(mSinusData.get(i));
}
BarDataSet set = new BarDataSet(entries, "Sinus Function");
set.setBarSpacePercent(40f);
set.setColor(Color.rgb(240, 120, 124));
BarData data = new BarData(xVals, set);
data.setValueTextSize(10f);
data.setValueTypeface(mTf);
data.setDrawValues(false);
mChart.setData(data);
}
示例9: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(List<Data> dataList) {
ArrayList<BarEntry> values = new ArrayList<BarEntry>();
String[] dates = new String[dataList.size()];
List<Integer> colors = new ArrayList<Integer>();
int green = Color.rgb(110, 190, 102);
int red = Color.rgb(211, 74, 88);
for (int i = 0; i < dataList.size(); i++) {
Data d = dataList.get(i);
BarEntry entry = new BarEntry(d.yValue, d.xIndex);
values.add(entry);
dates[i] = dataList.get(i).xAxisValue;
// specific colors
if (d.yValue >= 0)
colors.add(red);
else
colors.add(green);
}
BarDataSet set = new BarDataSet(values, "Values");
set.setBarSpacePercent(40f);
set.setColors(colors);
set.setValueTextColors(colors);
BarData data = new BarData(dates, set);
data.setValueTextSize(13f);
data.setValueTypeface(mTf);
data.setValueFormatter(new ValueFormatter());
mChart.setData(data);
mChart.invalidate();
}
示例10: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
private void setData(List<Integer> valueList, String format) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
if (valueList != null) {
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!format.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(format);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例11: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* update data for visualization chart
*
* @param valueList list of values for the chart
* @param unit data unit
*/
private void setData(List<Integer> valueList, String unit) {
mChart.setVisibility(View.VISIBLE);
ArrayList<String> xVals = new ArrayList<String>();
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < valueList.size(); i++) {
xVals.add(i + "s");
yVals1.add(new BarEntry(valueList.get(i), i));
}
String legend = getResources().getString(R.string.caption_receptin_rate);
if (!unit.equals("%"))
legend = getResources().getString(R.string.caption_packet_count);
BarDataSet set1 = new BarDataSet(yVals1, legend);
set1.setBarSpacePercent(35f);
set1.setColor(Color.parseColor("#0288D1"));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(xVals, dataSets);
data.setValueTextSize(10f);
data.setDrawValues(false);
YAxisValueFormatter custom = new DataAxisFormatter(unit);
YAxis leftAxis = mChart.getAxisLeft();
YAxis rightAxis = mChart.getAxisRight();
leftAxis.setValueFormatter(custom);
rightAxis.setValueFormatter(custom);
mChart.setData(data);
}
示例12: setData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
public boolean setData(List<Day> list) {
int count = list.size();
if (count > 0) {
ArrayList<Day> days = new ArrayList<>(list);
ArrayList<String> chartLabel = new ArrayList<>();
ArrayList<BarEntry> chartValue = new ArrayList<>();
for (int i = 0; i < count; i++) {
chartLabel.add(days.get(i).getThedate());
chartValue.add(new BarEntry((float) days.get(i).getPushups(), i));
}
BarDataSet dataSet = new BarDataSet(chartValue, "PUSH UP");
dataSet.setBarSpacePercent(35f);
dataSet.setColors(ColorTemplate.VORDIPLOM_COLORS);
ArrayList<IBarDataSet> barDataSets = new ArrayList<>();
barDataSets.add(dataSet);
BarData barData = new BarData(chartLabel, barDataSets);
barData.setValueTextSize(10f);
mChart.setData(barData);
return true;
}
return false;
}
示例13: createBarChartData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的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;
}
示例14: createStackedBarChartData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的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;
}
示例15: setCaloriesBarChartData
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
public void setCaloriesBarChartData() {
int numberOfWeeks = 4;
WeeklyConsumption weeklyConsumption = databaseAdapter.getWeeklyConsumption(numberOfWeeks);
List<Double> caloriesConsumed = weeklyConsumption.getCaloriesConsumed();
List<String> weeks = weeklyConsumption.getWeeks();
int listLimit = weeks.size() - 1;
// Load the labels for the X axis.
ArrayList<String> xValues = new ArrayList<>();
for (int i = listLimit; i >= 0; i--) {
xValues.add(weeks.get(i));
}
ArrayList<BarEntry> calorieValues = new ArrayList<>();
for (int i = listLimit; i >= 0; i--) {
float value = (float) caloriesConsumed.get(i).doubleValue();
calorieValues.add(new BarEntry(value, listLimit - i));
}
// Create one dataset for each macro.
BarDataSet calorieSet = new BarDataSet(calorieValues, "Calorie Intake");
calorieSet.setColor(getResources().getColor(R.color.color_fiber_dark));
calorieSet.setBarSpacePercent(55f);
ArrayList<BarDataSet> dataSet = new ArrayList<>();
dataSet.add(calorieSet);
BarData data = new BarData(xValues, dataSet);
// Add space between the dataset groups in percent of bar-width.
data.setValueTextSize(10f);
caloriesBarChart.setData(data);
caloriesBarChart.invalidate();
}