Open Vidxyz opened 7 years ago
hi sir.... I am having one issue ,when I click on the barchart its getting highlight with the gray color,I want to remove that background color what i want to do please help me...........
@vinod-hosamani To remove background color use setHighLightAlpha(0); For example
BarDataSet barDataSet = new BarDataSet(entries, ""); barDataSet.setHighLightAlpha(0);
barDataSet.setHighLightAlpha(0) is not working for me
highlightPerTapEnabled must be true Then add the following code to onValueSelected:
@Override
public void onValueSelected(Entry entry, Highlight highlight) {
chart.getOnTouchListener().setLastHighlighted(null);
chart.highlightValues(null);
// YOUR CODE
}
Basically removing the highlights immediately after the click was detected
With some custom modifications, working fine for me.
For Pie Chart:
piechart.onTouchListener = object : PieRadarChartTouchListener(pieChart){
override fun onSingleTapUp(e: MotionEvent?): Boolean {
super.onSingleTapUp(e)
return super.onSingleTapUp(e)
}
}
For Bar Chart:
barChart.onTouchListener = object : BarLineChartTouchListener(barChart, barChart.viewPortHandler.matrixTouch, 3f){
override fun onSingleTapUp(e: MotionEvent?): Boolean {
super.onSingleTapUp(e)
return super.onSingleTapUp(e)
}
}
onValuesSelected
can be overridden to perform the required functionality
Ideology: onValuesSelected
is been called only when highlighted but not on unhighlighting.
So, in onSingleTapUp(e:MotionEvent?)
we force it to highlight initially and then unhighlight as it programmed.
dataSet.highLightColor = Color.TRANSPARENT
dataSet.highLightAlpha = 0
Adding the above two lines hides the highlight and doesn't affect the click listener
Setting barDataSet.highLightAlpha = 0 removes the highlight tint in bars. But two taps would be needed to trigger OnChartValueSelectedListener the second time.
Adding @sahruday answer solves this issue perfectly
I have removed highlight entries from the chart
Use below line
binding.chart1.getLegend().setEnabled(false);
I'm trying to disable highlighting while clicking on a portion of the bar/pie chart but I want the onChartValueSelectedListener to fire at the same time. Basically, I don't want the bar/pie to change color/grow on value selected but I want to fire up a listener when this interaction occurs.
I've tried pieChart.setHighlightPerTapEnabled(false) but that doesn't fire the listener at all, how do I get around this?
Thanks in advance