It is currently Sun Apr 30, 2017 6:33 pm Advanced search

Show tooltip for latest/last point on loaded

Technical support for the Highcharts Stock package

Show tooltip for latest/last point on loaded

Postby bomortensen » Sun Jul 08, 2012 4:47 pm

Hi all,

I'm a happy user of the highstock chart, but I'm running my head against the wall on this 'problem'. My client has asked me if it's possible to show the tooltip of the last point in the chart when it's loaded (I'm loading series with AJAX call from a webservice)

I've tinkered around with the .refresh() method, but without any luck so far :-/ I'm wondering if this is possible and if someone has got a sample of it somewhere to get me kicked in on it?

Thanks a lot in advance.

All the best,

Bo Mortensen
bomortensen
 
Posts: 9
Joined: Thu Mar 15, 2012 2:56 am

Re: Show tooltip for latest/last point on loaded

Postby bomortensen » Mon Jul 09, 2012 2:12 pm

I guess no one have made this before. I'll post/mail it as a feedback topic then :-)
bomortensen
 
Posts: 9
Joined: Thu Mar 15, 2012 2:56 am

Re: Show tooltip for latest/last point on loaded

Postby bomortensen » Mon Jul 23, 2012 1:23 am

Got a bit further with this: got hold of the last point of the graph when it's loaded, now I *just* need to be able to actually show the tooltip of the point. Anyone's got an idea of how to do this? :-)

Fiddle for reference: http://jsfiddle.net/L2TFd/9/

Thanks in advance.

- Bo
bomortensen
 
Posts: 9
Joined: Thu Mar 15, 2012 2:56 am

Re: Show tooltip for latest/last point on loaded

Postby bomortensen » Mon Jul 23, 2012 3:27 am

And another update:

I actually managed to show the last points tooltip when the graph has been loaded, but it only shows the data for the first serie when there's more than one serie in my graph.

Fiddle: http://jsfiddle.net/L2TFd/26/

Is there any way to make it show the data from the other series in the tooltip? :-)
bomortensen
 
Posts: 9
Joined: Thu Mar 15, 2012 2:56 am

Re: Show tooltip for latest/last point on loaded

Postby Fusher » Wed Jul 25, 2012 2:58 pm

As I know it may be not possible without hacking sources.
Paweł Fus
Highcharts Developer
Fusher
 
Posts: 7889
Joined: Mon Jan 30, 2012 12:16 pm

Re: Show tooltip for latest/last point on loaded

Postby trinhthanhdung » Fri Jul 27, 2012 4:22 am

Hi, please check my link
http://jsfiddle.net/L2TFd/28/
I've already shown last point on loaded for all series.
trinhthanhdung
 
Posts: 119
Joined: Fri Jul 15, 2011 9:59 am

Re: Show tooltip for latest/last point on loaded

Postby Fusher » Fri Jul 27, 2012 4:31 pm

Nice!
Paweł Fus
Highcharts Developer
Fusher
 
Posts: 7889
Joined: Mon Jan 30, 2012 12:16 pm

Re: Show tooltip for latest/last point on loaded

Postby bomortensen » Mon Jul 30, 2012 11:19 am

Thank you so much, trinhthanhdung! Greatly appreciated :-)

My final code looks like this:

Code: Select all
chart: {                       
                        height: 210,
                        renderTo: 'graph',
                        events: {
                          load: function(event) {
                            var chart = $(this);                           
                            var jsonArray = $.parseJSON(data);
                            var lastArray = $(jsonArray).last();
                           
                            // Zoom in on last data point
                            if($(lastArray).length > 0) {                           
                              var unixDate = lastArray[0][0];
                              var currentDate = new Date(unixDate);
                              chart[0].xAxis[0].setExtremes(Date.UTC(currentDate.getFullYear(), currentDate.getMonth() - 1, currentDate.getDate()), Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()));                             
                            }
                           
                            // Show tooltip for last point in all series
                            try {
                              var points=[];
                              if(chart)
                              {
                                var points = [];
                                for(var i = 0; i < chart[0].series.length; i++) {
                                  var point = chart[0].series[i].points[chart[0].series[i].points.length-1];
                                  if(point) {
                                    points.push(point);
                                  }
                                }
                                chart[0].tooltip.refresh(points);       
                              }
                            } catch(e) {}                           
                          }
                        }                       
                    }
bomortensen
 
Posts: 9
Joined: Thu Mar 15, 2012 2:56 am


Return to Highstock Usage

Who is online

Users browsing this forum: No registered users and 2 guests