Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sync the scrolling of 2 charts #3063

Closed
Lavallette opened this issue Dec 1, 2017 · 8 comments
Closed

How to sync the scrolling of 2 charts #3063

Lavallette opened this issue Dec 1, 2017 · 8 comments

Comments

@Lavallette
Copy link

Lavallette commented Dec 1, 2017

Hello,

I’m new to programming and decided to try to use this wonderful library.

My question has been asked several times (as well on the Java community) but I have never been able to find an answer/solution or better an example, at least one I understand.

The question is, can 2 charts be synchronized so that "manual" scrolling/paning done on one chart is replicated on the second one?
I thought the solution was to use ChartViewDelegate and to work with chartTranslated but the method is not even called in my sample.

I create a sample application https://github.com/Lavallette/ChartSample if you want to have a look with

  • 2 charts
  • scrolling
  • zooming
  • auto updating chart

I’m certainly missing something but would love to get some help and advices.

Thank you.

PS: this is an MacOS application with xCode 9 in Swift 4

@KevinZK
Copy link

KevinZK commented Dec 7, 2017

you can try refreshWithNewMatrix: chart: invalidate:

@Lavallette
Copy link
Author

@KevinZK Thanks for helping with me trying to solve my problem.
Any chance for you to give me more information or pointing me toward more details.

@KevinZK
Copy link

KevinZK commented Dec 8, 2017

@Lavallette change this function "func chartTranslated(chartView: ChartViewBase, dX: CGFloat, dY: CGFloat)" to "func chartTranslated(_ chartView: ChartViewBase, dX: CGFloat, dY: CGFloat)" ,add a " _ " symbol
image

@thierryH91200
Copy link
Contributor

"func chartTranslated(chartView: ChartViewBase, dX: CGFloat, dY: CGFloat)" to
"func chartTranslated(chartView: ChartViewBase, dX: CGFloat, dY: CGFloat)" ,add ""
what is change ???

@KevinZK
Copy link

KevinZK commented Dec 8, 2017

@thierryH91200 I made a mistake :), have rewrited the reply

@Lavallette
Copy link
Author

Thanks @KevinZK. I did the change but the function is never called when scrolling. Can it be that it is only called on iOS and not MacOS?

@KevinZK
Copy link

KevinZK commented Dec 8, 2017

@Lavallette

func chartTranslated(_ chartView: ChartViewBase, dX: CGFloat, dY: CGFloat) {
        print("chartTranslated")
        
        if  chartView == combinedChartView {
            let currentMatrix = chartView.viewPortHandler.touchMatrix
            lineChartView.viewPortHandler.refresh(newMatrix: currentMatrix, chart: lineChartView, invalidate: true)
        }else {
            let currentMatrix = chartView.viewPortHandler.touchMatrix
            combinedChartView.viewPortHandler.refresh(newMatrix: currentMatrix, chart: combinedChartView, invalidate: true)
        }
    }

it's work !

https://github.com/KevinZK/chart.git try it

@Lavallette
Copy link
Author

@KevinZK You are right of course. Not sure what I did the first time.

Thank you very very much for your help, you are brightening my day.
Thumbs up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants