Highlight specific datapoint by its x-axis value

54 views
Skip to first unread message

Olivier BERMOND

unread,
Feb 12, 2015, 3:52:05 AM2/12/15
to flot-...@googlegroups.com
Hi,
i have a classic chart with line and points. I have to highlight one specific point according to the current product price (which is the x-axis data).
So i have the scenario but no idea to make it ...

I'm able to retrieve my "current price" variable as : $currentPrice and then to retrieve it in JQuery with : currentPrice = <?php echo $currentPrice; ?>;
It gives me for example 180. Correct me if i'm wrong, i need to :

- Get this current price : ok 
- Get the graph datas (x-axis) : how ?
- Compare current price with each value in the x-axis : with a loop, for or each ? In Php or directly in the jQuery with some flot method perhaps ?
- If currentPrice = current x-axis point in the loop : get y axis value of this point
- Hilight !

I didn't found similar question, could you help me ?
Thanks,
Olivier B

Ced

unread,
Feb 13, 2015, 4:26:08 AM2/13/15
to flot-...@googlegroups.com
Here's an example.  You may need to modify it to properly handle prices instead of integers.

http://jsfiddle.net/v1xL3gqd/
Reply all
Reply to author
Forward
0 new messages