0

New to javascript here - using Flot/Jquery: I am looking to store additional information to be displayed for hovering over points in the data array. i.e. data[i] = [x, y, 'additional info'] or [[x, y], 'additional info'] -

The Flot documentation only has this to say: The raw data format is an array of points: [ [x1, y1], [x2, y2], ... ]

How is it possible to specify which columns to use for X and Y as in y = data[i][1], x = data[i][0] ?

user3467349
  • 3,043
  • 4
  • 34
  • 61
  • This might be helpful http://stackoverflow.com/questions/21430371/how-to-create-new-property-and-value-for-a-function – Navin Rauniyar Mar 27 '14 at 06:43
  • I'm manipulating the data in python and then writing it to file as Json data for Javascript to handle, I'd prefer not to make an array of objects. – user3467349 Mar 27 '14 at 06:49

1 Answers1

1

You could create another array with the additional information you want to display and use the item index for displaying it in the tool tip.

showTooltip(item.pageX, item.pageY, x + " "+ info[item.dataIndex]);

example - http://jsfiddle.net/Rnusy/65/

Blake
  • 1,067
  • 14
  • 25
  • I thought of this - but it seems like a very Hackish solution. It means you have to write your data to two separate files or as two separate dict entries, and then your hover-over indexes both of them to find where the matching addinfo is (if the number of items do not match). – user3467349 Apr 01 '14 at 17:02