Highchart.js X轴标签 - 值为NaN

时间:2014-07-09 19:13:18

标签: javascript jquery highcharts

我正在尝试使用Highchart来显示图表。数据作为图的数据属性给出。一切都按照我想要的方式渲染,除了我不能让X轴标签(日期)显示出来。我一直在调试并在Highchart的xAxis.labels.formatter函数中,但this.value总是“NaN”,而日期在工具提示中渲染得很好。

enter image description here

这是一个复制我的问题的JSFiddle页面。

http://jsfiddle.net/xlory/nKhuA/

<figure id="seo-demand-figure" data-filename="SEODemand" 
    data-graph="[

    {&quot;name&quot;:&quot;Agents of SHIELD 
    cast&quot;,&quot;label_suffix&quot;:&quot;&quot;,&quot;data&quot;:
    [[1397286000000,0.09533],[1397890800000,0.08988],[1398495600000,0.06456],
    [1399100400000,0.06224],[1399705200000,0.0594],[1400310000000,0.05941],
    [1400914800000,0.02861],[1401519600000,0.0307],[1402124400000,0.02971],
    [1402729200000,0.0],[1403334000000,0.03265],[1403938800000,0.0],
    [1404543600000,0.0]]},

    {&quot;name&quot;:&quot;Alec 
    Baldwin&quot;,&quot;label_suffix&quot;:&quot;&quot;,&quot;data&quot;:
    [[1397286000000,0.2916],[1397890800000,0.2832],[1398495600000,0.2396],
    [1399100400000,0.2397],[1399705200000,0.2377],[1400310000000,1.099],
    [1400914800000,0.3148],[1401519600000,0.2763],[1402124400000,0.2674],
    [1402729200000,0.2286],[1403334000000,0.2612],[1403938800000,0.3079],
    [1404543600000,0.318]]},

    {&quot;name&quot;:&quot;Kim Kardashian 
    divorce&quot;,&quot;label_suffix&quot;:&quot;&quot;,&quot;data&quot;:
    [[1397286000000,0.02179],[1397890800000,0.02179],[1398495600000,0.02179],
    [1399100400000,0.02179],[1399705200000,0.02971],[1400310000000,0.02971],
    [1400914800000,0.05942],[1401519600000,0.08913],[1402124400000,0.05942],
    [1402729200000,0.03265],[1403334000000,0.03265],[1403938800000,0.03367],
    [1404543600000,0.03593]]}

    ]" 

    data-decimal-point="." data-thousandssep="," class="figure">
</figure>

(JSFiddle页面中的JS代码..这里发布的时间太长了......)

如何才能正确显示标签?

1 个答案:

答案 0 :(得分:0)

问题是我的startOfWeek值不正确。我把'星期日'但它应该是一个对应于星期几的数字,所以就像'0'。这搞砸了勾选标记。