Java Code Examples for com.github.mikephil.charting.interfaces.datasets.IBarDataSet#getBarBorderWidth()
The following examples show how to use
com.github.mikephil.charting.interfaces.datasets.IBarDataSet#getBarBorderWidth() .
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: HorizontalBarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 4 votes |
@Override protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { mShadowPaint.setColor(dataSet.getBarShadowColor()); BarData barData = mChart.getBarData(); final float barWidth = barData.getBarWidth(); final float barWidthHalf = barWidth / 2.0f; float x; for (int i = 0, count = Math.min((int) (Math.ceil((float) (dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount()); i < count; i++) { BarEntry e = dataSet.getEntryForIndex(i); x = e.getX(); mBarShadowRectBuffer.top = x - barWidthHalf; mBarShadowRectBuffer.bottom = x + barWidthHalf; trans.rectValueToPixel(mBarShadowRectBuffer); if (!mViewPortHandler.isInBoundsTop(mBarShadowRectBuffer.bottom)) { continue; } if (!mViewPortHandler.isInBoundsBottom(mBarShadowRectBuffer.top)) { break; } mBarShadowRectBuffer.left = mViewPortHandler.contentLeft(); mBarShadowRectBuffer.right = mViewPortHandler.contentRight(); c.drawRect(mBarShadowRectBuffer, mShadowPaint); } } // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.setBarWidth(mChart.getBarData().getBarWidth()); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); final boolean isSingleColor = dataSet.getColors().size() == 1; if (isSingleColor) { mRenderPaint.setColor(dataSet.getColor()); } for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3])) { break; } if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1])) { continue; } if (!isSingleColor) { // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); } c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }
Example 2
Source File: BarChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { mShadowPaint.setColor(dataSet.getBarShadowColor()); BarData barData = mChart.getBarData(); final float barWidth = barData.getBarWidth(); final float barWidthHalf = barWidth / 2.0f; float x; for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount()); i < count; i++) { BarEntry e = dataSet.getEntryForIndex(i); x = e.getX(); mBarShadowRectBuffer.left = x - barWidthHalf; mBarShadowRectBuffer.right = x + barWidthHalf; trans.rectValueToPixel(mBarShadowRectBuffer); if (!mViewPortHandler.isInBoundsLeft(mBarShadowRectBuffer.right)) continue; if (!mViewPortHandler.isInBoundsRight(mBarShadowRectBuffer.left)) break; mBarShadowRectBuffer.top = mViewPortHandler.contentTop(); mBarShadowRectBuffer.bottom = mViewPortHandler.contentBottom(); c.drawRect(mBarShadowRectBuffer, mShadowPaint); } } // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.setBarWidth(mChart.getBarData().getBarWidth()); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); final boolean isSingleColor = dataSet.getColors().size() == 1; if (isSingleColor) { mRenderPaint.setColor(dataSet.getColor()); } for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) continue; if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; if (!isSingleColor) { // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); } c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }
Example 3
Source File: HorizontalBarChartRenderer.java From Ticket-Analysis with MIT License | 4 votes |
@Override protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { mShadowPaint.setColor(dataSet.getBarShadowColor()); BarData barData = mChart.getBarData(); final float barWidth = barData.getBarWidth(); final float barWidthHalf = barWidth / 2.0f; float x; for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount()); i < count; i++) { BarEntry e = dataSet.getEntryForIndex(i); x = e.getX(); mBarShadowRectBuffer.top = x - barWidthHalf; mBarShadowRectBuffer.bottom = x + barWidthHalf; trans.rectValueToPixel(mBarShadowRectBuffer); if (!mViewPortHandler.isInBoundsTop(mBarShadowRectBuffer.bottom)) continue; if (!mViewPortHandler.isInBoundsBottom(mBarShadowRectBuffer.top)) break; mBarShadowRectBuffer.left = mViewPortHandler.contentLeft(); mBarShadowRectBuffer.right = mViewPortHandler.contentRight(); c.drawRect(mBarShadowRectBuffer, mShadowPaint); } } // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.setBarWidth(mChart.getBarData().getBarWidth()); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); final boolean isSingleColor = dataSet.getColors().size() == 1; if (isSingleColor) { mRenderPaint.setColor(dataSet.getColor()); } for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3])) break; if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1])) continue; if (!isSingleColor) { // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); } c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }
Example 4
Source File: BarChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { mShadowPaint.setColor(dataSet.getBarShadowColor()); BarData barData = mChart.getBarData(); final float barWidth = barData.getBarWidth(); final float barWidthHalf = barWidth / 2.0f; float x; for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount()); i < count; i++) { BarEntry e = dataSet.getEntryForIndex(i); x = e.getX(); mBarShadowRectBuffer.left = x - barWidthHalf; mBarShadowRectBuffer.right = x + barWidthHalf; trans.rectValueToPixel(mBarShadowRectBuffer); if (!mViewPortHandler.isInBoundsLeft(mBarShadowRectBuffer.right)) continue; if (!mViewPortHandler.isInBoundsRight(mBarShadowRectBuffer.left)) break; mBarShadowRectBuffer.top = mViewPortHandler.contentTop(); mBarShadowRectBuffer.bottom = mViewPortHandler.contentBottom(); c.drawRect(mBarShadowRectBuffer, mShadowPaint); } } // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.setBarWidth(mChart.getBarData().getBarWidth()); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); final boolean isSingleColor = dataSet.getColors().size() == 1; if (isSingleColor) { mRenderPaint.setColor(dataSet.getColor()); } for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) continue; if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; if (!isSingleColor) { // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); } c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }
Example 5
Source File: HorizontalBarChartRenderer.java From android-kline with Apache License 2.0 | 4 votes |
@Override protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { mShadowPaint.setColor(dataSet.getBarShadowColor()); BarData barData = mChart.getBarData(); final float barWidth = barData.getBarWidth(); final float barWidthHalf = barWidth / 2.0f; float x; for (int i = 0, count = Math.min((int)(Math.ceil((float)(dataSet.getEntryCount()) * phaseX)), dataSet.getEntryCount()); i < count; i++) { BarEntry e = dataSet.getEntryForIndex(i); x = e.getX(); mBarShadowRectBuffer.top = x - barWidthHalf; mBarShadowRectBuffer.bottom = x + barWidthHalf; trans.rectValueToPixel(mBarShadowRectBuffer); if (!mViewPortHandler.isInBoundsTop(mBarShadowRectBuffer.bottom)) continue; if (!mViewPortHandler.isInBoundsBottom(mBarShadowRectBuffer.top)) break; mBarShadowRectBuffer.left = mViewPortHandler.contentLeft(); mBarShadowRectBuffer.right = mViewPortHandler.contentRight(); c.drawRect(mBarShadowRectBuffer, mShadowPaint); } } // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.setBarWidth(mChart.getBarData().getBarWidth()); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); final boolean isSingleColor = dataSet.getColors().size() == 1; if (isSingleColor) { mRenderPaint.setColor(dataSet.getColor()); } for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3])) break; if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1])) continue; if (!isSingleColor) { // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); } c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }
Example 6
Source File: BarChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mShadowPaint.setColor(dataSet.getBarShadowColor()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setBarSpace(dataSet.getBarSpace()); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); // draw the bar shadow before the values if (mChart.isDrawBarShadowEnabled()) { for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) continue; if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; c.drawRect(buffer.buffer[j], mViewPortHandler.contentTop(), buffer.buffer[j + 2], mViewPortHandler.contentBottom(), mShadowPaint); } } // if multiple colors if (dataSet.getColors().size() > 1) { for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) continue; if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } } else { mRenderPaint.setColor(dataSet.getColor()); for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) continue; if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } } }
Example 7
Source File: HorizontalBarChartRenderer.java From NetKnight with Apache License 2.0 | 4 votes |
@Override protected void drawDataSet(Canvas c, IBarDataSet dataSet, int index) { Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); mShadowPaint.setColor(dataSet.getBarShadowColor()); mBarBorderPaint.setColor(dataSet.getBarBorderColor()); mBarBorderPaint.setStrokeWidth(Utils.convertDpToPixel(dataSet.getBarBorderWidth())); final boolean drawBorder = dataSet.getBarBorderWidth() > 0.f; float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); // initialize the buffer BarBuffer buffer = mBarBuffers[index]; buffer.setPhases(phaseX, phaseY); buffer.setBarSpace(dataSet.getBarSpace()); buffer.setDataSet(index); buffer.setInverted(mChart.isInverted(dataSet.getAxisDependency())); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); for (int j = 0; j < buffer.size(); j += 4) { if (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 3])) break; if (!mViewPortHandler.isInBoundsBottom(buffer.buffer[j + 1])) continue; if (mChart.isDrawBarShadowEnabled()) { c.drawRect(mViewPortHandler.contentLeft(), buffer.buffer[j + 1], mViewPortHandler.contentRight(), buffer.buffer[j + 3], mShadowPaint); } // Set the color for the currently drawn value. If the index // is out of bounds, reuse colors. mRenderPaint.setColor(dataSet.getColor(j / 4)); c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); if (drawBorder) { c.drawRect(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mBarBorderPaint); } } }