本文整理汇总了Java中com.github.mikephil.charting.data.BarData.getDataSetCount方法的典型用法代码示例。如果您正苦于以下问题:Java BarData.getDataSetCount方法的具体用法?Java BarData.getDataSetCount怎么用?Java BarData.getDataSetCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.data.BarData
的用法示例。
在下文中一共展示了BarData.getDataSetCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recalculateDataSet
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
void recalculateDataSet(final BarData barData) {
minBin = Math.floor(min / binWidth) * binWidth;
maxBin = Math.floor(max / binWidth) * binWidth;
int[][] bins = new int[rawData.size()][getNumBins()];
for (int setNum = 0; setNum < rawData.size(); setNum++) {
for (Double d : rawData.get(setNum)) {
++bins[setNum][(int) (Math.floor((d - minBin) / binWidth))];
}
}
for (int setNum = 0; setNum < barData.getDataSetCount(); setNum++) {
final IBarDataSet dataSet = barData.getDataSetByIndex(setNum);
dataSet.clear();
for (int i = 0; i < bins[setNum].length; i++) {
dataSet.addEntry(new BarEntry(i, bins[setNum][i]));
}
}
groupBars(barData);
barData.notifyDataChanged();
}
示例2: initBuffers
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new BarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new BarBuffer(set.getEntryCount() * 4 * (set.isStacked() ? set.getStackSize() : 1),
barData.getDataSetCount(), set.isStacked());
}
}
示例3: drawData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void drawData(Canvas c) {
BarData barData = mChart.getBarData();
for (int i = 0; i < barData.getDataSetCount(); i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
if (set.isVisible()) {
drawDataSet(c, set, i);
}
}
}
示例4: initBuffers
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new HorizontalBarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new HorizontalBarBuffer(set.getEntryCount() * 4 * (set.isStacked() ? set.getStackSize() : 1),
barData.getDataSetCount(), set.isStacked());
}
}
示例5: drawLabels
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
/**
* draws the x-labels on the specified y-position
*
* @param pos
*/
@Override
protected void drawLabels(Canvas c, float pos, PointF anchor) {
final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
// pre allocate to save performance (dont allocate in loop)
float[] position = new float[] {
0f, 0f
};
BarData bd = mChart.getData();
int step = bd.getDataSetCount();
for (int i = mMinX; i <= mMaxX; i += mXAxis.mAxisLabelModulus) {
position[1] = i * step + i * bd.getGroupSpace()
+ bd.getGroupSpace() / 2f;
// consider groups (center label for each group)
if (step > 1) {
position[1] += ((float) step - 1f) / 2f;
}
mTrans.pointValuesToPixel(position);
if (mViewPortHandler.isInBoundsY(position[1])) {
String label = mXAxis.getValues().get(i);
drawLabel(c, label, i, pos, position[1], anchor, labelRotationAngleDegrees);
}
}
}
示例6: drawData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void drawData(Canvas c) {
BarData barData = mChart.getBarData();
for (int i = 0; i < barData.getDataSetCount(); i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
if (set.isVisible() && set.getEntryCount() > 0) {
drawDataSet(c, set, i);
}
}
}
示例7: renderGridLines
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void renderGridLines(Canvas c) {
if (!mXAxis.isDrawGridLinesEnabled() || !mXAxis.isEnabled())
return;
float[] position = new float[] {
0f, 0f
};
mGridPaint.setColor(mXAxis.getGridColor());
mGridPaint.setStrokeWidth(mXAxis.getGridLineWidth());
BarData bd = mChart.getData();
// take into consideration that multiple DataSets increase mDeltaX
int step = bd.getDataSetCount();
for (int i = mMinX; i <= mMaxX; i += mXAxis.mAxisLabelModulus) {
position[1] = i * step + i * bd.getGroupSpace() - 0.5f;
mTrans.pointValuesToPixel(position);
if (mViewPortHandler.isInBoundsY(position[1])) {
c.drawLine(mViewPortHandler.contentLeft(), position[1],
mViewPortHandler.contentRight(), position[1], mGridPaint);
}
}
}
示例8: initBuffers
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new BarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new BarBuffer(set.getEntryCount() * 4 * (set.isStacked() ? set.getStackSize() : 1),
barData.getGroupSpace(),
barData.getDataSetCount(), set.isStacked());
}
}
示例9: generateTransformedValuesBarChart
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
/**
* Transforms an List of Entry into a float array containing the x and
* y values transformed with all matrices for the BARCHART.
*
* @param entries
* @param dataSet the dataset index
* @return
*/
public float[] generateTransformedValuesBarChart(List<? extends Entry> entries,
int dataSet, BarData bd, float phaseY) {
float[] valuePoints = new float[entries.size() * 2];
int setCount = bd.getDataSetCount();
float space = bd.getGroupSpace();
for (int j = 0; j < valuePoints.length; j += 2) {
Entry e = entries.get(j / 2);
int i = e.getXIndex();
// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + i * (setCount - 1) + dataSet + space * i
+ space / 2f;
float y = e.getVal();
valuePoints[j] = x;
valuePoints[j + 1] = y * phaseY;
}
getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
示例10: generateTransformedValuesBarChart
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
/**
* Transforms an List of Entry into a float array containing the x and
* y values transformed with all matrices for the BARCHART.
*
* @param data
* @param dataSetIndex the dataset index
* @param bd
* @param phaseY
* @return
*/
public float[] generateTransformedValuesBarChart(IBarDataSet data,
int dataSetIndex, BarData bd, float phaseY) {
float[] valuePoints = new float[data.getEntryCount() * 2];
int setCount = bd.getDataSetCount();
float space = bd.getGroupSpace();
for (int j = 0; j < valuePoints.length; j += 2) {
Entry e = data.getEntryForIndex(j / 2);
int i = e.getXIndex();
// calculate the x-position, depending on datasetcount
float x = e.getXIndex() + i * (setCount - 1) + dataSetIndex + space * i
+ space / 2f;
float y = e.getVal();
valuePoints[j] = x;
valuePoints[j + 1] = y * phaseY;
}
getValueToPixelMatrix().mapPoints(valuePoints);
return valuePoints;
}
示例11: initBuffers
import com.github.mikephil.charting.data.BarData; //导入方法依赖的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());
}
}
示例12: initBuffers
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void initBuffers() {
BarData barData = mChart.getBarData();
mBarBuffers = new HorizontalBarBuffer[barData.getDataSetCount()];
for (int i = 0; i < mBarBuffers.length; i++) {
IBarDataSet set = barData.getDataSetByIndex(i);
mBarBuffers[i] = new HorizontalBarBuffer(set.getEntryCount() * 4 * (set.isStacked() ? set.getStackSize() : 1),
barData.getGroupSpace(),
barData.getDataSetCount(), set.isStacked());
}
}
示例13: drawData
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public void drawData(Canvas c) {
BarData barData = mChart.getBarData();
for (int i = 0; i < barData.getDataSetCount(); i++) {
BarDataSet set = barData.getDataSetByIndex(i);
if (set.isVisible() && set.getEntryCount() > 0) {
drawDataSet(c, set, i);
}
}
}
示例14: onProgressUpdate
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
protected void onProgressUpdate(TestCase.Metrics... values) {
super.onProgressUpdate(values);
mDataSetIndex = mChart.getData().getIndexOfDataSet(mDataSet);
if (mDataSetIndex < 0) {
mChart.getData().addDataSet(mDataSet);
mDataSetIndex = mChart.getData().getIndexOfDataSet(mDataSet);
}
BarData data = mChart.getData();
for (TestCase.Metrics m : values) {
data.addEntry(new BarEntry(m.getVariable(), (float) m.getElapsedTime()), mDataSetIndex);
}
if (data.getDataSetCount() > 1) {
int count = data.getDataSetCount();
float groupSpace = 0.06f;
float barSpace = 0.02f;
float numBars = count;
float barWidth = (1.0f - ((count - 1) * barSpace) - groupSpace) / numBars;
Collections.sort(
data.getDataSets(),
new Comparator<IBarDataSet>() {
@Override
public int compare(IBarDataSet o1, IBarDataSet o2) {
float[] hsl1 = new float[3];
float[] hsl2 = new float[3];
ColorUtils.colorToHSL(o1.getColor(), hsl1);
ColorUtils.colorToHSL(o2.getColor(), hsl2);
if (Math.abs(hsl1[0] - hsl2[0]) > 10) {
return Float.compare(hsl1[0], hsl2[0]);
}
if (Math.abs(hsl1[2] - hsl2[2]) > 0.1) {
return Float.compare(hsl1[2], hsl2[2]);
}
return Float.compare(hsl1[1], hsl2[1]);
}
}
);
data.setBarWidth(barWidth);
data.groupBars(2, groupSpace, barSpace);
}
mChart.setFitBars(true);
data.notifyDataChanged();
mChart.notifyDataSetChanged();
mChart.invalidate();
}
示例15: getHighlight
import com.github.mikephil.charting.data.BarData; //导入方法依赖的package包/类
@Override
public Highlight getHighlight(float x, float y) {
BarData barData = mChart.getBarData();
final int xIndex = getXIndex(x);
final float baseNoSpace = getBase(x);
final int setCount = barData.getDataSetCount();
int dataSetIndex = ((int)baseNoSpace) % setCount;
if (dataSetIndex < 0) {
dataSetIndex = 0;
} else if (dataSetIndex >= setCount) {
dataSetIndex = setCount - 1;
}
SelectionDetail selectionDetail = getSelectionDetail(xIndex, y, dataSetIndex);
if (selectionDetail == null)
return null;
IBarDataSet set = barData.getDataSetByIndex(dataSetIndex);
if (set.isStacked()) {
float[] pts = new float[2];
pts[1] = y;
// take any transformer to determine the x-axis value
mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts);
return getStackedHighlight(selectionDetail,
set,
xIndex,
pts[1]);
}
return new Highlight(
xIndex,
selectionDetail.value,
selectionDetail.dataIndex,
selectionDetail.dataSetIndex,
-1);
}