ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.59k stars 6k forks source link

Drawing multiple Highlighters with equal distance on Line Chart #3055

Open rameswarprasad opened 6 years ago

rameswarprasad commented 6 years ago

I need some custom behavior w.r.t. Line Charts regarding hightlighters. What I need is to;

  1. Add a highlighter when the user double taps on the LineChart
  2. Afterwards if the user touches and drags on the chart, draw multiple highlighters in both the sides of the reference highlighter added earlier at equal distance.

I have overriden the doubleTapGestureRecognized method of BarLineChartViewBase class which was earlier used to zoom and hence achieved the 1st result.

For the 2nd I'm aware I have to take a different array but I'm unable to figure out where these calculations should happen and how I can then render it.

Another tap will dismiss all the drawn highlighters and I have figured out how to do that. @liuxuan30 Can you please help on the 2nd question.

rameswarprasad commented 6 years ago

@liuxuan30 Hope you're not annoyed by too many notifications. Can you please help or give a heads up? Thanks in advance.

liuxuan30 commented 6 years ago

eh, I just found this.. busy looking at PRs, so issues postponed. First to clarify

if the user touches and drags on the chart, draw multiple highlighters in both the sides of the reference highlighter added earlier at equal distance

what to drag? is it a pan gesture (potential conflict with scroll, if you need scrolling support)? what's the content of your "draw multiple highlighters in both the sides of the reference highlighter"?

I'm not very clear what's the requirement. But how about put func calls inside the gesture handler? e.g. you have a call like drawManyHighlights, and when calling this, it will make a flag so when UIView.draw() is called, only the highlights you need is rendered, while others remain, something like that.

rameswarprasad commented 6 years ago

Yeah it's Pan gesture. To clear things up, yeah a double tap will add a reference hightlighter, and after that a single tap will dismiss any highlighters present. If the reference highlighter is present then with gesture the equidistant highlighters at both sides should be drawn, and yeah scrolling will be disable if highlighters are present so no conflict.

The reason for this requirement is to analyse patterns of something/some events occuring through the chart. My difficulty is I'm not able to understand how to achive it if the chart is scaled to a one day data or 1 week data.

liuxuan30 commented 6 years ago

If you were able to highlight one already, just add some properties and observers to display more, it should not be impacted by scaling?