Skip to content

Commit 4ec22d7

Browse files
committed
Allow to setHighlightEnabled on a single DataSet
ChartsOrg/Charts#114
1 parent f32cfd0 commit 4ec22d7

20 files changed

Lines changed: 70 additions & 46 deletions

MPChartExample/src/com/xxmassdeveloper/mpchartexample/InvertedLineChartActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected void onCreate(Bundle savedInstanceState) {
8787

8888
// enable/disable highlight indicators (the lines that indicate the
8989
// highlighted Entry)
90-
mChart.setHighlightIndicatorEnabled(false);
90+
mChart.setHighlightEnabled(false);
9191

9292
XAxis xl = mChart.getXAxis();
9393
xl.setAvoidFirstLastClipping(true);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {
9696

9797
// enable/disable highlight indicators (the lines that indicate the
9898
// highlighted Entry)
99-
mChart.setHighlightIndicatorEnabled(false);
99+
mChart.setHighlightEnabled(false);
100100

101101
// x-axis limit line
102102
// LimitLine llXAxis = new LimitLine(10f, "Index 10");

MPChartExample/src/com/xxmassdeveloper/mpchartexample/PerformanceLineChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected void onCreate(Bundle savedInstanceState) {
6060

6161
// enable/disable highlight indicators (the lines that indicate the
6262
// highlighted Entry)
63-
mChart.setHighlightIndicatorEnabled(false);
63+
mChart.setHighlightEnabled(false);
6464

6565
mChart.getAxisLeft().setDrawGridLines(false);
6666
mChart.getAxisRight().setEnabled(false);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/BarChartFrag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3939

4040
mChart.setMarkerView(mv);
4141

42-
mChart.setHighlightIndicatorEnabled(false);
42+
mChart.setHighlightEnabled(false);
4343

4444
mChart.setDrawGridBackground(false);
4545
mChart.setDrawBarShadow(false);

MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/ComplexityFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
2929

3030
mChart.setDescription("");
3131

32-
mChart.setHighlightIndicatorEnabled(false);
32+
mChart.setHighlightEnabled(false);
3333
mChart.setDrawGridBackground(false);
3434

3535
mChart.setData(getComplexity());

MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/ScatterChartFrag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3636

3737
mChart.setMarkerView(mv);
3838

39-
mChart.setHighlightIndicatorEnabled(false);
39+
mChart.setHighlightEnabled(false);
4040
mChart.setDrawGridBackground(false);
4141
mChart.setData(generateScatterData(6, 10000, 200));
4242

MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
3030
mChart.setDescription("");
3131
// mChart.setCircleSize(5f);
3232

33-
mChart.setHighlightIndicatorEnabled(false);
33+
mChart.setHighlightEnabled(false);
3434
mChart.setDrawGridBackground(false);
3535

3636
mChart.setData(generateLineData());

MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleData<? exte
7575
*/
7676
protected boolean mHighlightPerDragEnabled = true;
7777

78-
/**
79-
* if set to true, the highlight indicator (lines for linechart, dark bar
80-
* for barchart) will be drawn upon selecting values.
81-
*/
82-
protected boolean mHighLightIndicatorEnabled = true;
83-
8478
/** if true, dragging is enabled for the chart */
8579
private boolean mDragEnabled = true;
8680

@@ -244,7 +238,7 @@ protected void onDraw(Canvas canvas) {
244238
mAxisRendererRight.renderLimitLines(canvas);
245239

246240
// if highlighting is enabled
247-
if (mHighlightEnabled && mHighLightIndicatorEnabled && valuesToHighlight())
241+
if (valuesToHighlight())
248242
mRenderer.drawHighlighted(canvas, mIndicesToHightlight);
249243

250244
// Removes clipping rectangle
@@ -889,18 +883,6 @@ public int getMaxVisibleCount() {
889883
return mMaxVisibleCount;
890884
}
891885

892-
/**
893-
* If set to true, the highlight indicator (vertical line for LineChart and
894-
* ScatterChart, dark bar overlay for BarChart) that gives visual indication
895-
* that an Entry has been selected will be drawn upon selecting values. This
896-
* does not depend on the MarkerView. Default: true
897-
*
898-
* @param enabled
899-
*/
900-
public void setHighlightIndicatorEnabled(boolean enabled) {
901-
mHighLightIndicatorEnabled = enabled;
902-
}
903-
904886
/**
905887
* Set this to true to allow highlighting per dragging over the chart
906888
* surface when it is fully zoomed out. Default: true

MPChartLib/src/com/github/mikephil/charting/charts/Chart.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ public abstract class Chart<T extends ChartData<? extends DataSet<? extends Entr
116116
/** if true, touch gestures are enabled on the chart */
117117
protected boolean mTouchEnabled = true;
118118

119-
/** if true, value highlightning is enabled */
120-
protected boolean mHighlightEnabled = true;
121-
122119
/** the legend object containing all data associated with the legend */
123120
protected Legend mLegend;
124121

@@ -865,7 +862,8 @@ public OnChartGestureListener getOnChartGestureListener() {
865862
* @param enabled
866863
*/
867864
public void setHighlightEnabled(boolean enabled) {
868-
mHighlightEnabled = enabled;
865+
if (mData != null)
866+
mData.setHighlightEnabled(enabled);
869867
}
870868

871869
/**
@@ -874,7 +872,7 @@ public void setHighlightEnabled(boolean enabled) {
874872
* @return
875873
*/
876874
public boolean isHighlightEnabled() {
877-
return mHighlightEnabled;
875+
return mData == null ? true : mData.isHighlightEnabled();
878876
}
879877

880878
/**

MPChartLib/src/com/github/mikephil/charting/charts/PieChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected void onDraw(Canvas canvas) {
102102

103103
mRenderer.drawData(canvas);
104104

105-
if (mHighlightEnabled && valuesToHighlight())
105+
if (valuesToHighlight())
106106
mRenderer.drawHighlighted(canvas, mIndicesToHightlight);
107107

108108
mRenderer.drawExtras(canvas);

0 commit comments

Comments
 (0)