Skip to content

Commit

Permalink
Merge pull request #93 from AppDevNext/FixScatterShape
Browse files Browse the repository at this point in the history
Fix scatter shape size bug
  • Loading branch information
hannesa2 committed Jan 9, 2023
2 parents 5699181 + 94d0fbe commit 9cc87ea
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
import com.github.mikephil.charting.renderer.scatter.IShapeRenderer;
import com.github.mikephil.charting.utils.Utils;
import com.github.mikephil.charting.utils.ViewPortHandler;

/**
Expand All @@ -18,7 +19,7 @@ public class CustomScatterShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
final float shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f;

c.drawLine(
posX - shapeHalf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ChevronDownShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
final float shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f;

renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ChevronUpShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
final float shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f;

renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CircleShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeSize = dataSet.getScatterShapeSize();
final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CrossShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
final float shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f;

renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SquareShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeSize = dataSet.getScatterShapeSize();
final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TriangleShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeSize = dataSet.getScatterShapeSize();
final float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class XShapeRenderer implements IShapeRenderer
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler,
float posX, float posY, Paint renderPaint) {

final float shapeHalf = dataSet.getScatterShapeSize() / 2f;
final float shapeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeSize()) / 2f;

renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
Expand Down

0 comments on commit 9cc87ea

Please sign in to comment.