Java Code Examples for com.github.mikephil.charting.data.BarData#getDataSetCount()
The following examples show how to use
com.github.mikephil.charting.data.BarData#getDataSetCount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistogramChart.java From walt with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: BarChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@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); } } }
Example 3
Source File: XAxisRendererHorizontalBarChart.java From Stayfit with Apache License 2.0 | 5 votes |
/** * 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); } } }
Example 4
Source File: XAxisRendererBarChart.java From NetKnight with Apache License 2.0 | 5 votes |
@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(); int step = bd.getDataSetCount(); for (int i = mMinX; i < mMaxX; i += mXAxis.mAxisLabelModulus) { position[0] = i * step + i * bd.getGroupSpace() - 0.5f; mTrans.pointValuesToPixel(position); if (mViewPortHandler.isInBoundsX(position[0])) { c.drawLine(position[0], mViewPortHandler.offsetTop(), position[0], mViewPortHandler.contentBottom(), mGridPaint); } } }
Example 5
Source File: BarChartRenderer.java From Stayfit with Apache License 2.0 | 5 votes |
@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()); } }
Example 6
Source File: XAxisRendererHorizontalBarChart.java From NetKnight with Apache License 2.0 | 5 votes |
/** * 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); } } }
Example 7
Source File: XAxisRendererBarChart.java From iMoney with Apache License 2.0 | 5 votes |
@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(); int step = bd.getDataSetCount(); for (int i = mMinX; i < mMaxX; i += mXAxis.mAxisLabelModulus) { position[0] = i * step + i * bd.getGroupSpace() - 0.5f; mTrans.pointValuesToPixel(position); if (mViewPortHandler.isInBoundsX(position[0])) { c.drawLine(position[0], mViewPortHandler.offsetTop(), position[0], mViewPortHandler.contentBottom(), mGridPaint); } } }
Example 8
Source File: XAxisRendererHorizontalBarChart.java From iMoney with Apache License 2.0 | 5 votes |
@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); } } }
Example 9
Source File: BarChartRenderer.java From NetKnight with Apache License 2.0 | 5 votes |
@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); } } }
Example 10
Source File: XAxisRendererHorizontalBarChart.java From Stayfit with Apache License 2.0 | 5 votes |
@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); } } }
Example 11
Source File: BarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@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()); } }
Example 12
Source File: BarChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@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()); } }
Example 13
Source File: HorizontalBarChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@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()); } }
Example 14
Source File: BarChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
@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); } } }
Example 15
Source File: HorizontalBarChartRenderer.java From Stayfit with Apache License 2.0 | 5 votes |
@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()); } }
Example 16
Source File: BarChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
@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); } } }
Example 17
Source File: BarChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
@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()); } }
Example 18
Source File: BarChartRenderer.java From NetKnight with Apache License 2.0 | 5 votes |
@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()); } }
Example 19
Source File: BarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@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); } } }
Example 20
Source File: HorizontalBarHighlighter.java From NetKnight with Apache License 2.0 | 4 votes |
@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[0] = y; // take any transformer to determine the x-axis value mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts); return getStackedHighlight(selectionDetail, set, xIndex, pts[0]); } return new Highlight( xIndex, selectionDetail.value, selectionDetail.dataIndex, selectionDetail.dataSetIndex, -1); }