Anychart - Onclick Event, how to get more context information?

1
Hi, I built a bar chart using the Anychart object and I want to display extra data in a popup when clicking any bar in the chart. when clicking a bar, I receive the following string through the OnClick Event: [{"curveNumber":0,"pointNumber":0,"pointIndex":0,"x":"6","y":18,"marker.color":"#a9afb3"}] Now using this JSON, I need to query my database to retrieve the dataset corresponding to the bar I clicked. The x and y attributes will help me query the data displayed in the bar out of the data displayed in the chart. However the data displayed in the chart is already the result of a query to the database itself. How can I know what the initial filter was to retrieve the same dataset? Below an example that hopefully makes it clearer. Here is an overview of my data model. My DB contains a list of Assets on which we run multiple tests. The same tests are run on all the assets and we track the time of execution and the different results, one test can be executed multiple time against one asset, until it succeeds. In my example, the bar graph displays TestResult data for one Asset: it calculates the number of occurences of each TestId for the Asset in the TestResult table (the idea is to see, for one Asset, which tests fail the most) Now in the bar graph, when I click the bar I can get the TestId number, but how can I get the Asset name? I tried adding the Asset Entity as an input to the microflow called by the OnClick event, since I can see the Asset in the context of my page in Project Studio, however this is not allowed: Any idea?   Thank you,  Sebastien
asked
1 answers
2

I know this is an old post but someone might find this helpful:

The following works with a ‘scatter’ plot.  Other types of plots probably have the same or similar tags.

We use the “ids” array to hold a key value for the data point.  When you set your X and Y coordinates in the data JSON sent to Plotly, you can also put a key for that data point in the “ids” array.  The value can be any string useful to you, such as a database key or some string describing the query you need to do in your on-click flow.

In the event data you get back from AnyChart, you will get an “id” tag with your key value (in addition to curvenumber, x, y, etc.). 

see:    https://plotly.com/javascript/reference/scatter/

answered