com.github.mikephil.charting.utils.Transformer Java Examples
The following examples show how to use
com.github.mikephil.charting.utils.Transformer.
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: LineChartRenderer.java From Ticket-Analysis with MIT License | 6 votes |
protected void drawCubicFill(Canvas c, ILineDataSet dataSet, Path spline, Transformer trans, XBounds bounds) { float fillMin = dataSet.getFillFormatter() .getFillLinePosition(dataSet, mChart); spline.lineTo(dataSet.getEntryForIndex(bounds.min + bounds.range).getX(), fillMin); spline.lineTo(dataSet.getEntryForIndex(bounds.min).getX(), fillMin); spline.close(); trans.pathValueToPixel(spline); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, spline, drawable); } else { drawFilledPath(c, spline, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
Example #2
Source File: AxisRenderer.java From android-kline with Apache License 2.0 | 6 votes |
public AxisRenderer(ViewPortHandler viewPortHandler, Transformer trans, AxisBase axis) { super(viewPortHandler); this.mTrans = trans; this.mAxis = axis; if(mViewPortHandler != null) { mAxisLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGridPaint = new Paint(); mGridPaint.setColor(Color.GRAY); mGridPaint.setStrokeWidth(1f); mGridPaint.setStyle(Style.STROKE); mGridPaint.setAlpha(90); mAxisLinePaint = new Paint(); mAxisLinePaint.setColor(Color.BLACK); mAxisLinePaint.setStrokeWidth(1f); mAxisLinePaint.setStyle(Style.STROKE); mLimitLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLimitLinePaint.setStyle(Paint.Style.STROKE); } }
Example #3
Source File: AxisRenderer.java From StockChart-MPAndroidChart with MIT License | 6 votes |
public AxisRenderer(ViewPortHandler viewPortHandler, Transformer trans, AxisBase axis) { super(viewPortHandler); this.mTrans = trans; this.mAxis = axis; if (mViewPortHandler != null) { mAxisLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mGridPaint = new Paint(); mGridPaint.setColor(Color.GRAY); mGridPaint.setStrokeWidth(1f); mGridPaint.setStyle(Style.STROKE); mGridPaint.setAlpha(90); mAxisLinePaint = new Paint(); mAxisLinePaint.setColor(Color.BLACK); mAxisLinePaint.setStrokeWidth(1f); mAxisLinePaint.setStyle(Style.STROKE); mLimitLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLimitLinePaint.setStyle(Paint.Style.STROKE); } }
Example #4
Source File: LineChartRenderer.java From NetKnight with Apache License 2.0 | 6 votes |
protected void drawLinearFill(Canvas c, ILineDataSet dataSet, int minx, int maxx, Transformer trans) { Path filled = generateFilledPath( dataSet, minx, maxx); trans.pathValueToPixel(filled); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, filled, drawable); } else { drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha()); } }
Example #5
Source File: YAxisRenderer.java From StockChart-MPAndroidChart with MIT License | 6 votes |
public YAxisRenderer(ViewPortHandler viewPortHandler, YAxis yAxis, Transformer trans) { super(viewPortHandler, trans, yAxis); this.mYAxis = yAxis; if (mViewPortHandler != null) { mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); mZeroLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mZeroLinePaint.setColor(Color.GRAY); mZeroLinePaint.setStrokeWidth(1f); mZeroLinePaint.setStyle(Paint.Style.STROKE); } }
Example #6
Source File: AnimatedViewPortJob.java From StockChart-MPAndroidChart with MIT License | 5 votes |
public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) { super(viewPortHandler, xValue, yValue, trans, v); this.xOrigin = xOrigin; this.yOrigin = yOrigin; animator = ObjectAnimator.ofFloat(this, "phase", 0f, 1f); animator.setDuration(duration); animator.addUpdateListener(this); animator.addListener(this); }
Example #7
Source File: LineChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
/** * Draws a filled linear path on the canvas. * * @param c * @param dataSet * @param trans * @param bounds */ protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) { final Path filled = mGenerateFilledPathBuffer; final int startingIndex = bounds.min; final int endingIndex = bounds.range + bounds.min; final int indexInterval = 128; int currentStartIndex = 0; int currentEndIndex = indexInterval; int iterations = 0; // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets. do { currentStartIndex = startingIndex + (iterations * indexInterval); currentEndIndex = currentStartIndex + indexInterval; currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex; if (currentStartIndex <= currentEndIndex) { generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled); trans.pathValueToPixel(filled); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, filled, drawable); } else { drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha()); } } iterations++; } while (currentStartIndex <= currentEndIndex); }
Example #8
Source File: ZoomJob.java From android-kline with Apache License 2.0 | 5 votes |
public ZoomJob(ViewPortHandler viewPortHandler, float scaleX, float scaleY, float xValue, float yValue, Transformer trans, YAxis.AxisDependency axis, View v) { super(viewPortHandler, xValue, yValue, trans, v); this.scaleX = scaleX; this.scaleY = scaleY; this.axisDependency = axis; }
Example #9
Source File: AnimatedZoomJob.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@SuppressLint("NewApi") public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration); this.zoomCenterX = zoomCenterX; this.zoomCenterY = zoomCenterY; this.zoomOriginX = zoomOriginX; this.zoomOriginY = zoomOriginY; this.animator.addListener(this); this.yAxis = axis; this.xAxisRange = xAxisRange; }
Example #10
Source File: ZoomJob.java From Ticket-Analysis with MIT License | 5 votes |
public static ZoomJob getInstance(ViewPortHandler viewPortHandler, float scaleX, float scaleY, float xValue, float yValue, Transformer trans, YAxis.AxisDependency axis, View v) { ZoomJob result = pool.get(); result.xValue = xValue; result.yValue = yValue; result.scaleX = scaleX; result.scaleY = scaleY; result.mViewPortHandler = viewPortHandler; result.mTrans = trans; result.axisDependency = axis; result.view = v; return result; }
Example #11
Source File: YAxisRenderer.java From NetKnight with Apache License 2.0 | 5 votes |
public YAxisRenderer(ViewPortHandler viewPortHandler, YAxis yAxis, Transformer trans) { super(viewPortHandler, trans); this.mYAxis = yAxis; mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); mZeroLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mZeroLinePaint.setColor(Color.GRAY); mZeroLinePaint.setStrokeWidth(1f); mZeroLinePaint.setStyle(Paint.Style.STROKE); }
Example #12
Source File: BarLineChartBase.java From Stayfit with Apache License 2.0 | 5 votes |
@Override protected void init() { super.init(); mAxisLeft = new YAxis(AxisDependency.LEFT); mAxisRight = new YAxis(AxisDependency.RIGHT); mXAxis = new XAxis(); mLeftAxisTransformer = new Transformer(mViewPortHandler); mRightAxisTransformer = new Transformer(mViewPortHandler); mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer); mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer); mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer); setHighlighter(new ChartHighlighter(this)); mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch()); mGridBackgroundPaint = new Paint(); mGridBackgroundPaint.setStyle(Style.FILL); // mGridBackgroundPaint.setColor(Color.WHITE); mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240)); // light // grey mBorderPaint = new Paint(); mBorderPaint.setStyle(Style.STROKE); mBorderPaint.setColor(Color.BLACK); mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); }
Example #13
Source File: MoveViewJob.java From StockChart-MPAndroidChart with MIT License | 5 votes |
public static MoveViewJob getInstance(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) { MoveViewJob result = pool.get(); result.mViewPortHandler = viewPortHandler; result.xValue = xValue; result.yValue = yValue; result.mTrans = trans; result.view = v; return result; }
Example #14
Source File: BarLineChartBase.java From Ticket-Analysis with MIT License | 5 votes |
@Override protected void init() { super.init(); mAxisLeft = new YAxis(AxisDependency.LEFT); mAxisRight = new YAxis(AxisDependency.RIGHT); mLeftAxisTransformer = new Transformer(mViewPortHandler); mRightAxisTransformer = new Transformer(mViewPortHandler); mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer); mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer); mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer); setHighlighter(new ChartHighlighter(this)); mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch(), 3f); mGridBackgroundPaint = new Paint(); mGridBackgroundPaint.setStyle(Style.FILL); // mGridBackgroundPaint.setColor(Color.WHITE); mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240)); // light // grey mBorderPaint = new Paint(); mBorderPaint.setStyle(Style.STROKE); mBorderPaint.setColor(Color.BLACK); mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); }
Example #15
Source File: MoveViewJob.java From iMoney with Apache License 2.0 | 5 votes |
public MoveViewJob(ViewPortHandler viewPortHandler, float xIndex, float yValue, Transformer trans, View v) { this.mViewPortHandler = viewPortHandler; this.xIndex = xIndex; this.yValue = yValue; this.mTrans = trans; this.view = v; }
Example #16
Source File: AnimatedZoomJob.java From Ticket-Analysis with MIT License | 5 votes |
@SuppressLint("NewApi") public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration); this.zoomCenterX = zoomCenterX; this.zoomCenterY = zoomCenterY; this.zoomOriginX = zoomOriginX; this.zoomOriginY = zoomOriginY; this.animator.addListener(this); this.yAxis = axis; this.xAxisRange = xAxisRange; }
Example #17
Source File: BarLineChartBase.java From android-kline with Apache License 2.0 | 5 votes |
@Override protected void init() { super.init(); mAxisLeft = new YAxis(AxisDependency.LEFT); mAxisRight = new YAxis(AxisDependency.RIGHT); mLeftAxisTransformer = new Transformer(mViewPortHandler); mRightAxisTransformer = new Transformer(mViewPortHandler); mAxisRendererLeft = new YAxisRenderer(mViewPortHandler, mAxisLeft, mLeftAxisTransformer); mAxisRendererRight = new YAxisRenderer(mViewPortHandler, mAxisRight, mRightAxisTransformer); mXAxisRenderer = new XAxisRenderer(mViewPortHandler, mXAxis, mLeftAxisTransformer); setHighlighter(new ChartHighlighter(this)); mChartTouchListener = new BarLineChartTouchListener(this, mViewPortHandler.getMatrixTouch(), 3f); mGridBackgroundPaint = new Paint(); mGridBackgroundPaint.setStyle(Style.FILL); // mGridBackgroundPaint.setColor(Color.WHITE); mGridBackgroundPaint.setColor(Color.rgb(240, 240, 240)); // light // grey mBorderPaint = new Paint(); mBorderPaint.setStyle(Style.STROKE); mBorderPaint.setColor(Color.BLACK); mBorderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); }
Example #18
Source File: BarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
protected void prepareBarHighlight(float x, float y1, float y2, float barWidthHalf, Transformer trans) { float left = x - barWidthHalf; float right = x + barWidthHalf; float top = y1; float bottom = y2; mBarRect.set(left, top, right, bottom); trans.rectToPixelPhase(mBarRect, mAnimator.getPhaseY()); }
Example #19
Source File: AnimatedZoomJob.java From android-kline with Apache License 2.0 | 5 votes |
public static AnimatedZoomJob getInstance(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { AnimatedZoomJob result = pool.get(); result.mViewPortHandler = viewPortHandler; result.xValue = scaleX; result.yValue = scaleY; result.mTrans = trans; result.view = v; result.xOrigin = xOrigin; result.yOrigin = yOrigin; result.resetAnimator(); result.animator.setDuration(duration); return result; }
Example #20
Source File: XAxisRenderer.java From Stayfit with Apache License 2.0 | 5 votes |
public XAxisRenderer(ViewPortHandler viewPortHandler, XAxis xAxis, Transformer trans) { super(viewPortHandler, trans); this.mXAxis = xAxis; mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextAlign(Align.CENTER); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); }
Example #21
Source File: ZoomJob.java From StockChart-MPAndroidChart with MIT License | 5 votes |
public ZoomJob(ViewPortHandler viewPortHandler, float scaleX, float scaleY, float xValue, float yValue, Transformer trans, YAxis.AxisDependency axis, View v) { super(viewPortHandler, xValue, yValue, trans, v); this.scaleX = scaleX; this.scaleY = scaleY; this.axisDependency = axis; }
Example #22
Source File: AnimatedZoomJob.java From android-kline with Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") public AnimatedZoomJob(ViewPortHandler viewPortHandler, View v, Transformer trans, YAxis axis, float xAxisRange, float scaleX, float scaleY, float xOrigin, float yOrigin, float zoomCenterX, float zoomCenterY, float zoomOriginX, float zoomOriginY, long duration) { super(viewPortHandler, scaleX, scaleY, trans, v, xOrigin, yOrigin, duration); this.zoomCenterX = zoomCenterX; this.zoomCenterY = zoomCenterY; this.zoomOriginX = zoomOriginX; this.zoomOriginY = zoomOriginY; this.animator.addListener(this); this.yAxis = axis; this.xAxisRange = xAxisRange; }
Example #23
Source File: YAxisRenderer.java From iMoney with Apache License 2.0 | 5 votes |
public YAxisRenderer(ViewPortHandler viewPortHandler, YAxis yAxis, Transformer trans) { super(viewPortHandler, trans); this.mYAxis = yAxis; mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); }
Example #24
Source File: HorizontalBarChartRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override protected void prepareBarHighlight(float x, float y1, float y2, float barWidthHalf, Transformer trans) { float top = x - barWidthHalf; float bottom = x + barWidthHalf; float left = y1; float right = y2; mBarRect.set(left, top, right, bottom); trans.rectToPixelPhaseHorizontal(mBarRect, mAnimator.getPhaseY()); }
Example #25
Source File: XAxisRenderer.java From Ticket-Analysis with MIT License | 5 votes |
public XAxisRenderer(ViewPortHandler viewPortHandler, XAxis xAxis, Transformer trans) { super(viewPortHandler, trans, xAxis); this.mXAxis = xAxis; mAxisLabelPaint.setColor(Color.BLACK); mAxisLabelPaint.setTextAlign(Align.CENTER); mAxisLabelPaint.setTextSize(Utils.convertDpToPixel(10f)); }
Example #26
Source File: ViewPortJob.java From Stayfit with Apache License 2.0 | 5 votes |
public ViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) { this.mViewPortHandler = viewPortHandler; this.xValue = xValue; this.yValue = yValue; this.mTrans = trans; this.view = v; }
Example #27
Source File: LineChartRenderer.java From android-kline with Apache License 2.0 | 5 votes |
/** * Draws a filled linear path on the canvas. * * @param c * @param dataSet * @param trans * @param bounds */ protected void drawLinearFill(Canvas c, ILineDataSet dataSet, Transformer trans, XBounds bounds) { final Path filled = mGenerateFilledPathBuffer; final int startingIndex = bounds.min; final int endingIndex = bounds.range + bounds.min; final int indexInterval = 128; int currentStartIndex = 0; int currentEndIndex = indexInterval; int iterations = 0; // Doing this iteratively in order to avoid OutOfMemory errors that can happen on large bounds sets. do { currentStartIndex = startingIndex + (iterations * indexInterval); currentEndIndex = currentStartIndex + indexInterval; currentEndIndex = currentEndIndex > endingIndex ? endingIndex : currentEndIndex; if (currentStartIndex <= currentEndIndex) { generateFilledPath(dataSet, currentStartIndex, currentEndIndex, filled); trans.pathValueToPixel(filled); final Drawable drawable = dataSet.getFillDrawable(); if (drawable != null) { drawFilledPath(c, filled, drawable); } else { drawFilledPath(c, filled, dataSet.getFillColor(), dataSet.getFillAlpha()); } } iterations++; } while (currentStartIndex <= currentEndIndex); }
Example #28
Source File: HorizontalBarChartRenderer.java From Ticket-Analysis with MIT License | 5 votes |
@Override protected void prepareBarHighlight(float x, float y1, float y2, float barWidthHalf, Transformer trans) { float top = x - barWidthHalf; float bottom = x + barWidthHalf; float left = y1; float right = y2; mBarRect.set(left, top, right, bottom); trans.rectToPixelPhaseHorizontal(mBarRect, mAnimator.getPhaseY()); }
Example #29
Source File: AnimatedMoveViewJob.java From android-kline with Apache License 2.0 | 4 votes |
public AnimatedMoveViewJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) { super(viewPortHandler, xValue, yValue, trans, v, xOrigin, yOrigin, duration); }
Example #30
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); } } }