1

I want to show the value of open, close, high and low for a symbol but it seems highstock only displays that value when chart type is ohlc or candlestick but not in line. My workaround for this problem is producing two chart with same data, line(making it visible) and ohlc(making it invisible) and extracting open, close, high and low from second type and displaying it in tooltip. I'm sure this is not a right way. Does anyone has any solution.

My tooltip formatter

  formatter: function() {


                var s=' ';
                $.each(this.points, function(i, series) {

                   //when the series is of type 'line', series.point.open is undefined but works great on 'ohlc' type
 n=new Date(series.point.x);

 s += 'Open: <span style="font-weight:bold">' +series.point.open + '</span> Close: <span style="font-weight:bold">' +series.point.close + '</span> High: <span style="font-weight:bold">'+ series.point.high + '</span> Low: <span style="font-weight:bold">' + series.point.low + '</span>';

                });
                return s;

            }

http://jsfiddle.net/7G9Cj/4/

1
  • 1
    You can store each candle inside an array indexed by the date in utc, then store the array with the serie. Nov 30, 2012 at 16:48

1 Answer 1

4

Solved it. Here is the solution in case someone needs it.

formatter: function() {
  var s = ' ';

  $.each(this.points, function(i, series) {
      for (i = 0; i < dataLength; i++) {
        if (ohlc[i][0] == series.point.x) //ohlc holds my main data
        {
          s += 'Open: <span style="font-weight:bold">' + ohlc[i][1] 
            + '</span> Close: <span style="font-weight:bold">' + ohlc[i][4] 
            + '</span> High: <span style="font-weight:bold">' + ohlc[i][2] 
            + '</span> Low: <span style="font-weight:bold">' + ohlc[i][3] 
            + '</span>';
          break;
        }
      }
    }
  });

  return s;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.