Changes related to highlight full bar
This commit is contained in:
parent
6878220e2e
commit
0eb69d246c
9 changed files with 53 additions and 27 deletions
|
@ -55,6 +55,7 @@ public class CombinedChartActivity extends DemoBase {
|
|||
mChart.setBackgroundColor(Color.WHITE);
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawBarShadow(false);
|
||||
mChart.setHighlightFullBarEnabled(false);
|
||||
|
||||
// draw bars behind lines
|
||||
mChart.setDrawOrder(new DrawOrder[]{
|
||||
|
|
|
@ -69,6 +69,7 @@ public class StackedBarActivity extends DemoBase implements OnSeekBarChangeListe
|
|||
mChart.setDrawBarShadow(false);
|
||||
|
||||
mChart.setDrawValueAboveBar(false);
|
||||
mChart.setHighlightFullBarEnabled(false);
|
||||
|
||||
// change the position of the y-labels
|
||||
YAxis leftAxis = mChart.getAxisLeft();
|
||||
|
|
|
@ -56,6 +56,7 @@ public class StackedBarActivityNegative extends DemoBase implements
|
|||
|
||||
mChart.setDrawBarShadow(false);
|
||||
mChart.setDrawValueAboveBar(true);
|
||||
mChart.setHighlightFullBarEnabled(false);
|
||||
|
||||
mChart.getAxisLeft().setEnabled(false);
|
||||
mChart.getAxisRight().setAxisMaxValue(25f);
|
||||
|
|
|
@ -27,6 +27,11 @@ public class BarChart extends BarLineChartBase<BarData> implements BarDataProvid
|
|||
*/
|
||||
private boolean mDrawHighlightArrow = false;
|
||||
|
||||
/**
|
||||
* flag that indicates whether the highlight should be full-bar oriented, or single-value?
|
||||
*/
|
||||
protected boolean mHighlightFullBarEnabled = false;
|
||||
|
||||
/**
|
||||
* if set to true, all values are drawn above their bars, instead of below their top
|
||||
*/
|
||||
|
@ -183,6 +188,25 @@ public class BarChart extends BarLineChartBase<BarData> implements BarDataProvid
|
|||
return mDrawBarShadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this to true to make the highlight operation full-bar oriented,
|
||||
* false to make it highlight single values (relevant only for stacked).
|
||||
* Default: false
|
||||
*
|
||||
* @param enabled
|
||||
*/
|
||||
public void setHighlightFullBarEnabled(boolean enabled) {
|
||||
mHighlightFullBarEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true the highlight operation is be full-bar oriented, false if single-value
|
||||
*/
|
||||
@Override
|
||||
public boolean isHighlightFullBarEnabled() {
|
||||
return mHighlightFullBarEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlights the value at the given x-position in the given DataSet. Provide
|
||||
* -1 as the dataSetIndex to undo all highlighting.
|
||||
|
|
|
@ -77,11 +77,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
*/
|
||||
protected boolean mHighlightPerDragEnabled = true;
|
||||
|
||||
/**
|
||||
* flag that indicates whether the highlight should be full-bar oriented, or single-value?
|
||||
*/
|
||||
protected boolean mHighlightFullBarEnabled = false;
|
||||
|
||||
/**
|
||||
* if true, dragging is enabled for the chart
|
||||
*/
|
||||
|
@ -1023,23 +1018,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
return mHighlightPerDragEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this to true to make the highlight full-bar oriented,
|
||||
* false to make it highlight single values
|
||||
*
|
||||
* @param enabled
|
||||
*/
|
||||
public void setHighlightFullBarEnabled(boolean enabled) {
|
||||
mHighlightFullBarEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true the highlight is be full-bar oriented, false if single-value
|
||||
*/
|
||||
public boolean isHighlightFullBarEnabled() {
|
||||
return mHighlightFullBarEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color for the background of the chart-drawing area (everything
|
||||
* behind the grid lines).
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.github.mikephil.charting.animation.EasingFunction;
|
|||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.MarkerView;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.formatter.DefaultValueFormatter;
|
||||
|
@ -630,9 +629,6 @@ public abstract class Chart<T extends ChartData<? extends IDataSet<? extends Ent
|
|||
mIndicesToHighlight = null;
|
||||
high = null;
|
||||
} else {
|
||||
if (this instanceof BarLineChartBase
|
||||
&& ((BarLineChartBase) this).isHighlightFullBarEnabled())
|
||||
high = new Highlight(high.getX(), -1);
|
||||
|
||||
// set the indices to highlight
|
||||
mIndicesToHighlight = new Highlight[]{
|
||||
|
|
|
@ -28,6 +28,12 @@ public class CombinedChart extends BarLineChartBase<CombinedData> implements Com
|
|||
*/
|
||||
private boolean mDrawValueAboveBar = true;
|
||||
|
||||
|
||||
/**
|
||||
* flag that indicates whether the highlight should be full-bar oriented, or single-value?
|
||||
*/
|
||||
protected boolean mHighlightFullBarEnabled = false;
|
||||
|
||||
/**
|
||||
* if set to true, a grey area is drawn behind each bar that indicates the
|
||||
* maximum value
|
||||
|
@ -149,6 +155,24 @@ public class CombinedChart extends BarLineChartBase<CombinedData> implements Com
|
|||
mDrawBarShadow = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this to true to make the highlight operation full-bar oriented,
|
||||
* false to make it highlight single values (relevant only for stacked).
|
||||
*
|
||||
* @param enabled
|
||||
*/
|
||||
public void setHighlightFullBarEnabled(boolean enabled) {
|
||||
mHighlightFullBarEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true the highlight operation is be full-bar oriented, false if single-value
|
||||
*/
|
||||
@Override
|
||||
public boolean isHighlightFullBarEnabled() {
|
||||
return mHighlightFullBarEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently set draw order.
|
||||
*
|
||||
|
|
|
@ -7,4 +7,5 @@ public interface BarDataProvider extends BarLineScatterCandleBubbleDataProvider
|
|||
BarData getBarData();
|
||||
boolean isDrawBarShadowEnabled();
|
||||
boolean isDrawValueAboveBarEnabled();
|
||||
boolean isHighlightFullBarEnabled();
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ public class BarChartRenderer extends BarLineScatterCandleBubbleRenderer {
|
|||
final float y1;
|
||||
final float y2;
|
||||
|
||||
if (isStack) {
|
||||
if (isStack && !mChart.isHighlightFullBarEnabled()) {
|
||||
|
||||
Range range = e.getRanges()[high.getStackIndex()];
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue