MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

Change Highlight indicator on Line charts

Open knseir opened this issue 11 years ago • 9 comments

Hi Phil, I've looked in the documentation, and couldn't find anything to change the highlight indicator on line charts. I'm looking at changing the color, width, and removing the horizontal line. I've only found a way to change the width so far (chart.setHighlightLineWidth() ) Thank you

knseir avatar Jun 27 '15 18:06 knseir

@knseir Have you already tried setHighLightColor(int color) of the BarLineScatterCandleDataSet to change the color? Your implementation might look something like this to change the color of your highlight indicator:

LineDataSet set = new LineDataSet(mYVals, label);
...
set.setHighLightColor(ctx.getResources().getColor(R.color.color_highlight_indicator));

Not sure what you meant with

removing the horizontal line

though. Did you mean you only want to remove the horizontal line but want the vertical line to be shown?

fountaingeyser avatar Jul 01 '15 09:07 fountaingeyser

'Did you mean you only want to remove the horizontal line but want the vertical line to be shown?' Yes, that's it. The intersection of the highlight indicator and the line chart is marked by a vertical and a horizontal line. I need to show only the vertical line.

Also, if possible, replace that line by a custom drawable

knseir avatar Jul 04 '15 14:07 knseir

@knseir Sorry, but I'm not aware of a possibility to do something like that. Maybe @PhilJay or @danielgindi can help you there.

fountaingeyser avatar Jul 05 '15 11:07 fountaingeyser

@fountaingeyser Thanks for answering. I'll look into making some changes to the library then

knseir avatar Jul 10 '15 22:07 knseir

Hi, while drawing the vertical highlight line in a line chart, i need to show only the line upto the point in the graph. How can we implement that

sankar07 avatar Jul 01 '19 12:07 sankar07

@knseir Have you already tried setHighLightColor(int color) of the BarLineScatterCandleDataSet to change the color? Your implementation might look something like this to change the color of your highlight indicator:

LineDataSet set = new LineDataSet(mYVals, label); ... set.setHighLightColor(ctx.getResources().getColor(R.color.color_highlight_indicator)); Not sure what you meant with

removing the horizontal line

though. Did you mean you only want to remove the horizontal line but want the vertical line to be shown?

Set property drawHorizontalHighlightIndicatorEnabled = false on the set you want to remove horizontal line

muhammadWaqasCheetayPk avatar Jul 30 '20 11:07 muhammadWaqasCheetayPk

Hi, while drawing the vertical highlight line in a line chart, i need to show only the line upto the point in the graph. How can we implement that

UP!!! there's a way to extends the Highlighter and draw only from the bottom to the value and not above?

enricomoko avatar Jun 04 '21 13:06 enricomoko

Hi, while drawing the vertical highlight line in a line chart, i need to show only the line upto the point in the graph. How can we implement that

is there a way? @PhilJay

juleimisf avatar Sep 28 '22 22:09 juleimisf

Hi, while drawing the vertical highlight line in a line chart, i need to show only the line upto the point in the graph. How can we implement that

is there a way? @PhilJay

@juleimisf The way to implement this is to override the drawHighlightLines() method in a custom LineChartRenderer subclass. There you can change the drawing function to end at the provided y value.

Hope this helps!

spencerhowell avatar Oct 31 '22 16:10 spencerhowell