Jump to content
JChartFX Community
  • 0

Hidden value for a evt.point



Hello, all. 

This is my first post and have to say I'm impressed by jChartFX. Awesome library!

I'm building a drill-down solution and need to get an ID for each bar the user clicks. I learnt how to get the index of the bar (evt.point), what is not of much use for me, unless I make a table (session, for instance) to relate the data array (that comes from a json string). 

 So, lets say that the json will return somethig like this (here, just one record):

  • {
    • store"2114",
    • ID"2",
    • Sales196.5,
    • Cost101.44,
    • Year"2013"


The graph will show, say, X = store and Y = Sales. 

The ID 2 represents all the record and when user clicks on that bar, I want to get the ID. As I said, I know how to the the index of the bar (and also the label, in this case, 2114). 

The only thing I could thing of was to concatenate  the store and ID fields wiht a known separator in order to get the ID. Something like store: "2114|2"

However this solution is far from being elegant, not to mention that the ID would appear in the graph. 

Does anyone know a better way to handle it? The entire solution I'm buinding depends on this feature, as it will have multple levels fof drill-down.

Thanks in advance, 



Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Even though we keep a reference to the objects in the JSON array (we keep this in order to be able to show other fields in the tooltips for example) at the moment we do not offer an API to get to these objects.

Because we already keep the objects alive, you could also keep a reference to the array passed to setDataSource, when you receive the Click event, use event.point as the index to access the JSON object the user clicked on. This will allow you to query other properties (e.g ID).

In future builds we will expose a property called targetObject in the evt object so that you do not have keep a reference to the array, we are also planning to add a GetDataField method in the chart class.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...