本文整理汇总了Java中com.github.mikephil.charting.data.BarDataSet.getStackSize方法的典型用法代码示例。如果您正苦于以下问题:Java BarDataSet.getStackSize方法的具体用法?Java BarDataSet.getStackSize怎么用?Java BarDataSet.getStackSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarDataSet
的用法示例。
在下文中一共展示了BarDataSet.getStackSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initBuffers
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new BarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
BarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new BarBuffer(set.getValueCount() * 4 * set.getStackSize(),
barData.getGroupSpace(),
barData.getDataSetCount(), set.isStacked());
}
}
示例2: initBuffers
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new HorizontalBarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
BarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new HorizontalBarBuffer(set.getValueCount() * 4 * set.getStackSize(),
barData.getGroupSpace(),
barData.getDataSetCount(), set.isStacked());
}
}
示例3: prepareLegend
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Generates an automatically prepared legend depending on the DataSets in
* the chart and their colors.
*/
public void prepareLegend() {
ArrayList<String> labels = new ArrayList<String>();
ArrayList<Integer> colors = new ArrayList<Integer>();
// loop for building up the colors and labels used in the legend
for (int i = 0; i < mData.getDataSetCount(); i++) {
DataSet<? extends Entry> dataSet = mData.getDataSetByIndex(i);
ArrayList<Integer> clrs = dataSet.getColors();
int entryCount = dataSet.getEntryCount();
// if we have a barchart with stacked bars
if (dataSet instanceof BarDataSet && ((BarDataSet) dataSet).getStackSize() > 1) {
BarDataSet bds = (BarDataSet) dataSet;
String[] sLabels = bds.getStackLabels();
for (int j = 0; j < clrs.size() && j < entryCount && j < bds.getStackSize(); j++) {
labels.add(sLabels[j % sLabels.length]);
colors.add(clrs.get(j));
}
// add the legend description label
colors.add(-2);
labels.add(bds.getLabel());
} else if (dataSet instanceof PieDataSet) {
ArrayList<String> xVals = mData.getXVals();
PieDataSet pds = (PieDataSet) dataSet;
for (int j = 0; j < clrs.size() && j < entryCount && j < xVals.size(); j++) {
labels.add(xVals.get(j));
colors.add(clrs.get(j));
}
// add the legend description label
colors.add(-2);
labels.add(pds.getLabel());
} else { // all others
for (int j = 0; j < clrs.size() && j < entryCount; j++) {
// if multiple colors are set for a DataSet, group them
if (j < clrs.size() - 1 && j < entryCount - 1) {
labels.add(null);
} else { // add label to the last entry
String label = mData.getDataSetByIndex(i).getLabel();
labels.add(label);
}
colors.add(clrs.get(j));
}
}
}
Legend l = new Legend(colors, labels);
if (mLegend != null) {
// apply the old legend settings to a potential new legend
l.apply(mLegend);
}
mLegend = l;
}
示例4: prepareLegend
import com.github.mikephil.charting.data.BarDataSet; //导入方法依赖的package包/类
/**
* Generates an automatically prepared legend depending on the DataSets in
* the chart and their colors.
*/
public void prepareLegend() {
ArrayList<String> labels = new ArrayList<String>();
ArrayList<Integer> colors = new ArrayList<Integer>();
// loop for building up the colors and labels used in the legend
for (int i = 0; i < mOriginalData.getDataSetCount(); i++) {
DataSet<? extends Entry> dataSet = mOriginalData.getDataSetByIndex(i);
ArrayList<Integer> clrs = dataSet.getColors();
int entryCount = dataSet.getEntryCount();
// if we have a barchart with stacked bars
if (dataSet instanceof BarDataSet && ((BarDataSet) dataSet).getStackSize() > 1) {
BarDataSet bds = (BarDataSet) dataSet;
String[] sLabels = bds.getStackLabels();
for (int j = 0; j < clrs.size() && j < entryCount && j < bds.getStackSize(); j++) {
labels.add(sLabels[j % sLabels.length]);
colors.add(clrs.get(j));
}
// add the legend description label
colors.add(-2);
labels.add(bds.getLabel());
} else if (dataSet instanceof PieDataSet) {
ArrayList<String> xVals = mOriginalData.getXVals();
PieDataSet pds = (PieDataSet) dataSet;
for (int j = 0; j < clrs.size() && j < entryCount && j < xVals.size(); j++) {
labels.add(xVals.get(j));
colors.add(clrs.get(j));
}
// add the legend description label
colors.add(-2);
labels.add(pds.getLabel());
} else { // all others
for (int j = 0; j < clrs.size() && j < entryCount; j++) {
// if multiple colors are set for a DataSet, group them
if (j < clrs.size() - 1 && j < entryCount - 1) {
labels.add(null);
} else { // add label to the last entry
String label = mOriginalData.getDataSetByIndex(i).getLabel();
labels.add(label);
}
colors.add(clrs.get(j));
}
}
}
Legend l = new Legend(colors, labels);
if (mLegend != null) {
// apply the old legend settings to a potential new legend
l.apply(mLegend);
}
mLegend = l;
}