Skip to content

Commit

Permalink
fix: padding on charts
Browse files Browse the repository at this point in the history
  • Loading branch information
vcellu committed Dec 2, 2022
1 parent e9560f7 commit 4f3aa53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -12,7 +12,7 @@ public class MiniChartRenderer {
Rect bounds = new Rect();
Paint paint = new Paint();
float horizontalPadding = 20.0f;
float verticalPadding = 8.0f;
float verticalPadding = 16.0f;
float bandwidth = 0.0f;
float padding = 0.0f;
float scale = 0.0f;
Expand Down Expand Up @@ -57,7 +57,8 @@ protected void setBandwidth() {
protected void setScales() {
float height = bounds.height() - (verticalPadding * 2.0f);
scale = height / yScale;
xAxis = miniChartData.qMin < 0.0 ? (float)bounds.height() + ((float)miniChartData.qMin * scale) : bounds.height();
xAxis = miniChartData.qMin < 0.0 ? height + ((float)miniChartData.qMin * scale) : height;
xAxis = xAxis + (verticalPadding * 1.25f );
}

protected void setColor(int index, float value, int count) {
Expand Down
Expand Up @@ -18,7 +18,7 @@ public void render(Canvas canvas) {
for(int i = 0; i < miniChartData.matrix.rows.size(); i++) {
float value = (float) miniChartData.matrix.rows.get(i).columns.get(1).qNum;
float height = value * scale;
float y = xAxis - height ;
float y = xAxis - height;
setColor(i, value, miniChartData.matrix.rows.size());
canvas.drawCircle(x, y, dotRadius, paint);
x += padding * 2.0f + bandwidth;
Expand Down

0 comments on commit 4f3aa53

Please sign in to comment.