Skip to content

Commit

Permalink
add option to draw limit lines on top of data
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgoli committed Sep 23, 2017
1 parent 72031d3 commit c97b8d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,14 @@ protected void onDraw(Canvas canvas) {
mAxisRendererLeft.renderAxisLine(canvas);
mAxisRendererRight.renderAxisLine(canvas);

mXAxisRenderer.renderGridLines(canvas);
mAxisRendererLeft.renderGridLines(canvas);
mAxisRendererRight.renderGridLines(canvas);
if (mXAxis.isDrawGridLinesBehindDataEnabled())
mXAxisRenderer.renderGridLines(canvas);

if (mAxisLeft.isDrawGridLinesBehindDataEnabled())
mAxisRendererLeft.renderGridLines(canvas);

if (mAxisRight.isDrawGridLinesBehindDataEnabled())
mAxisRendererRight.renderGridLines(canvas);

if (mXAxis.isEnabled() && mXAxis.isDrawLimitLinesBehindDataEnabled())
mXAxisRenderer.renderLimitLines(canvas);
Expand All @@ -231,6 +236,15 @@ protected void onDraw(Canvas canvas) {

mRenderer.drawData(canvas);

if (!mXAxis.isDrawGridLinesBehindDataEnabled())
mXAxisRenderer.renderGridLines(canvas);

if (!mAxisLeft.isDrawGridLinesBehindDataEnabled())
mAxisRendererLeft.renderGridLines(canvas);

if (!mAxisRight.isDrawGridLinesBehindDataEnabled())
mAxisRendererRight.renderGridLines(canvas);

// if highlighting is enabled
if (valuesToHighlight())
mRenderer.drawHighlighted(canvas, mIndicesToHighlight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public abstract class AxisBase extends ComponentBase {
*/
protected boolean mDrawLimitLineBehindData = false;

/**
* flag indicating the grid lines layer depth
*/
protected boolean mDrawGridLinesBehindData = true;

/**
* Extra spacing for `axisMinimum` to be added to automatically calculated `axisMinimum`
*/
Expand Down Expand Up @@ -444,6 +449,18 @@ public boolean isDrawLimitLinesBehindDataEnabled() {
return mDrawLimitLineBehindData;
}

/**
* If this is set to false, the grid lines are draw on top of the actual data,
* otherwise behind. Default: true
*
* @param enabled
*/
public void setDrawGridLinesBehindData(boolean enabled) { mDrawGridLinesBehindData = enabled; }

public boolean isDrawGridLinesBehindDataEnabled() {
return mDrawGridLinesBehindData;
}

/**
* Returns the longest formatted label (in terms of characters), this axis
* contains.
Expand Down

0 comments on commit c97b8d5

Please sign in to comment.