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

Get valiues back from a chart #295

Open
git-vcs opened this issue Dec 11, 2024 · 2 comments
Open

Get valiues back from a chart #295

git-vcs opened this issue Dec 11, 2024 · 2 comments
Labels

Comments

@git-vcs
Copy link

git-vcs commented Dec 11, 2024

Hello great library.

I see that this library is a wrapper around javascript, this makes me wonder. Is there some exposed variables like current dataset, current viewable data set or current marker that I can get back to my Android(kotlin) code?

I can not see any mention of JavascriptInterface or listeners in the api documentation.

@git-vcs
Copy link
Author

git-vcs commented Dec 12, 2024

after some more reading i see that HIFunction is probably the correct way to do this. But is there a list somewhere that lists all available .getProperty("names")?

@MikolajMichalczak
Copy link
Contributor

Hi @git-vcs!

Yes, you can use events in combination with HIFunction for this purpose. Here is a general explanation of how to use HIFunction in the Highcharts Android wrapper.

For example, you can utilize the drilldown event as follows:

val event = HIEvents()  
event.drilldown = HIFunction(HIConsumer { f: HIChartContext ->  
    val category = f.getProperty("category")  
    val seriesOptions = f.getProperty("seriesOptions")  
    val pointX = f.getProperty("point.x")  
    val pointY = f.getProperty("point.y")  
    val pointDrilldown = f.getProperty("point.drilldown")  
    val drilldown = f.getProperty("drilldown")  
}, arrayOf("category", "seriesOptions", "point.x", "point.y", "point.drilldown", "drilldown"))  
chart.events = event  

The parameters you pass in the array to HIFunction will be accessible later in your code.

To understand what parameters are available for specific events, you can refer to the event documentation. For example, the drilldown event is documented here: Chart events.
From this documentation, you can see the event arguments for Highcharts.DrilldownCallbackFunction. By navigating deeper into the documentation, you’ll find the detailed list of properties available on the event object: Highcharts.DrilldownEventObject.

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

No branches or pull requests

2 participants