Highcharts how to pass milliseconds to pointStart (really a javascript question)

StackOverflow https://stackoverflow.com/questions/5826464

  •  26-10-2019
  •  | 
  •  

문제

What I am trying to do is pass a variable to the pointStart option of Highcharts.

Here's part of the javascript

<script type="text/javascript">
    var dtTemp = '1303401600000';
    // dtTemp is a DateTime in milliseconds
</script>

dtTemp is only for the purpose of this question assigned as above, it actually comes from the code-behind so using a variable as opposed to entering the number directly is a functional requirement.

What I would like to do is to use the dtTemp variable as my start point for a Highcharts series. The appropriate way to do this is to assign dtTemp to pointStart. An example of pointStart in action can be seen in this JSFiddle.

series: [{
    data: [29.9, 71.5, 106.4],
    pointStart: dtTemp,    // DOES NOT WORK
    pointInterval: 3600000
}]

The code above does not work, Highcharts will not accept dtTemp as is. I am pretty new to all of this but I assume the problem is that dtTemp is a string but it wants a number (double?). However, replacing the above with the following does also not work:

pointStart: number(dtTemp),     // DOES NOT WORK EITHER

So I am just a bit at a loss now as to what the problem actually is. Any insight you may be able to provide will be greatly appreciated. Thanks in advance!

EDIT: SOLUTION as per mVChr reply:

pointStart: Number(dtTemp),     // Number with a CAPITAL N works!
도움이 되었습니까?

해결책

You're correct, but Number(dtTemp) needs to be capitalized.

See example

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top