简体   繁体   中英

Highchart.js X-axis labels - values are NaN

I'm trying to use Highchart to show a graph. Data is given as a data attribute of the figure. Everything renders as I want to, except aht I can't get the X-axis labels (dates) to show up. I've been debugging and within the Highchart's xAxis.labels.formatter function, but this.value is always "NaN", whereas the dates renders fine in the Tooltip.

在此处输入图片说明

Here's a JSFiddle page replicating my issue.

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>

(JS code in the JSFiddle page.. too long to post here...)

How can I get the labels to show correctly?

The issue was I had a wrong value for startOfWeek. I put 'Sunday' but it should have been a number corresponding to the day of week, so like '0'. That messed up with the tick, and tick labels.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM