admin管理员组

文章数量:1323342

I am trying to get the actual value of the x axis into a string but I can't work out the syntax.

I have just started to develop a demonstration version of the HighCharts, so the example below is what I am altering:

(press options to see the code behind this)

I am trying to change the following line of code

maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) +':<br/> '+ this.y +' visits',

This is because my data x axis value is a Month name. Therefore I want to say something like:

maincontentText: this.x.value +': '+ this.y +' visits',

It's probably very simple, does anyone know why every permutation I try has failed?

Thanks :-)

I am trying to get the actual value of the x axis into a string but I can't work out the syntax.

I have just started to develop a demonstration version of the HighCharts, so the example below is what I am altering:

http://www.highcharts./demo/line-ajax/grid

(press options to see the code behind this)

I am trying to change the following line of code

maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) +':<br/> '+ this.y +' visits',

This is because my data x axis value is a Month name. Therefore I want to say something like:

maincontentText: this.x.value +': '+ this.y +' visits',

It's probably very simple, does anyone know why every permutation I try has failed?

Thanks :-)

Share Improve this question asked Aug 24, 2011 at 16:16 HadleighHadleigh 4982 gold badges6 silver badges15 bronze badges 3
  • Do you give a try to this.x instead of this.x.value? Tell if works for you. – Diosney Commented Aug 24, 2011 at 16:58
  • Yep, I've tried every bination I can think of. I get a mixture of undefined or Object object as responses. – Hadleigh Commented Aug 25, 2011 at 7:54
  • this.x gives me the array key value, 0, 1, 2 etc. this.x.value is undefined, as is this.x.name. this.data[x].value gives Object object – Hadleigh Commented Aug 25, 2011 at 7:56
Add a ment  | 

1 Answer 1

Reset to default 5

The example you started with has a numeric x-axis, a timeline, this.x will be a number (milliseconds from jan 1, 1970) suitable for Highcharts.dateFormat.

If you have changed the example to use a categorical x-axis, then you instead find the category in this.category so I think this will work:

maincontentText: this.category +': '+ this.y +' visits',

Example: here

本文标签: javascriptGetting the X Axis value in HighChartsStack Overflow