JavaScript How to have data labels on top of the graph?

I have here-under a simple example of spline chart with data label enabled :

dataLabels: {enabled: true}

http://jsfiddle.net/gc8144kv/

I would like to have the data labels on top of the graph instead of on the line. See example here (i just moved the data label with a Paint editor :) ) : Data labels on top of the graph

How can I do this ? knowing that the data labels should be responsive when we resize the window

Thanks.

Answer:1

I think that good idea is to move your dataLabels in load and redraw events functions, because you may have your dataLabels in the right positions even on chart resize then.

Here you can see the code that may help you:

  var positionLabels = function(chart) {
    var series = chart.series[0],
      dataLabelsGroup = series.dataLabelsGroup,
      xVal;
    Highcharts.each(dataLabelsGroup.element.children, function(d) {
      xVal = (d.attributes.transform.value).substring((d.attributes.transform.value).indexOf('(') + 1, (d.attributes.transform.value).indexOf(','));
      $(d).attr('transform', 'translate(' + xVal + ',-20)')
    })
  };

And here you can find live example how it can work: http://jsfiddle.net/gc8144kv/7/

Answer:2

I have a kendo grid with custom popup edit window to imitate popup edit, but with batch edit. Everything works fine, but I am experiencing a small issue. Whenever value is changed, the grid cell does ...

I have a kendo grid with custom popup edit window to imitate popup edit, but with batch edit. Everything works fine, but I am experiencing a small issue. Whenever value is changed, the grid cell does ...

I am setting up foundations for a websocket app using node.js, express and socket.io. I decided it would be elegant to place the code that sets up socket.io in a separate module, so my server.js file ...

I am setting up foundations for a websocket app using node.js, express and socket.io. I decided it would be elegant to place the code that sets up socket.io in a separate module, so my server.js file ...

When I refresh page timer is reset. I would like to set localStorage on this timer, how do it set in localStorage HTML 00 : <span id="timer">02 : 00</span> JavaScript :- window.onload ...

When I refresh page timer is reset. I would like to set localStorage on this timer, how do it set in localStorage HTML 00 : <span id="timer">02 : 00</span> JavaScript :- window.onload ...

I have a page with a background image and six tiles that are links, All of those are contained in a <div id = "main">. I also have a side navbar that pushes the content to the right when clicked ...

I have a page with a background image and six tiles that are links, All of those are contained in a <div id = "main">. I also have a side navbar that pushes the content to the right when clicked ...