2016-01-21 64 views
0

我一直在搞這個問題一段時間了,現在還不知道爲什麼當我嘗試爲數百萬的這個數據集進行格式化時,沒有任何東西會出現。任何見解請讓我知道,可能只是因爲我沒有看到一個非常簡單的部分。我瀏覽了Highcharts文檔,沒有嘗試使用格式化程序或其他工作。所以我刪除了我的編輯,並添加了下面的代碼,因爲它是在我更改它之前。如何在y軸和工具提示上顯示全部百萬價值(Highcharts)

Here is the fiddle

$(function() { 
$('#container').highcharts({ 
    chart: { 
     type: 'line' 
    }, 
    title: { 
     text: 'Industry $', 
     style: { 

       fontWeight: 'bold' 
      } 
    }, 
    subtitle: { 
     text: 'By Year', 
     style: { 

       fontWeight: 'bold' 
      } 
    }, 
    xAxis: { 
     type: 'category', 
     labels: { 
      rotation: -45, 
      style: { 
       fontSize: '13px', 
       fontFamily: 'Open Sans, sans-serif', 
       fontWeight: 'bold' 
      } 
     } 
    }, 
    yAxis: { 
     min: 0, 
     labels: { 

      format: '{value}', 
      style: { 
       color: Highcharts.getOptions().colors[0] 
      }, 

     rotation: 0, 
     style: { 

       fontWeight: 'bold' 
      } 
     }, 
     title: { 
      text: 'Total $', 
      style: { 

       fontWeight: 'bold' 
      } 
     } 

    }, 
    legend: { 
     enabled: false 
    }, 
    tooltip: { 
     pointFormat: 'Total $: <b>{point.y}</b>', 

    }, 
    series: [{ 
     name: 'Population', 
     data: [ 
      ['2005', 25,000], 
      ['2006', 50,000], 
      ['2007', 75,000], 
      ['2008', 98,000], 
      ['2009', 200,000], 
      ['2010', 600,000], 
      ['2011', 800,000], 
      ['2012', 1,000,000] 
     ], 
     dataLabels: { 
      enabled: true, 
      tooltip: { 
      valueSuffix: '' 
     }, 
      rotation: 0, 
      color: '#FFFFFF', 
      align: 'center', 
      format: '{point.y}', // one decimal 
      y: 10, // 10 pixels down from the top 
      style: { 
       fontSize: '13px', 
       fontFamily: 'Verdana, sans-serif' 
      } 

     } 
    }] 
    }); 
}); 

回答

2

採取逗號出

例如

data: [ 
     ['2005', 25,000], 
     ['2006', 50,000], 
     ['2007', 75,000], 
     ['2008', 98,000], 
     ['2009', 200,000], 
     ['2010', 600,000], 
     ['2011', 800,000], 
     ['2012', 1,000,000] 
    ], 

應該是:

data: [ 
     ['2005', 25000], 
     ['2006', 50000], 
     ['2007', 75000], 
     ['2008', 98000], 
     ['2009', 200000], 
     ['2010', 600000], 
     ['2011', 800000], 
     ['2012', 1000000] 
    ], 
+0

謝謝,還需加逗號的還可以,但我相信,我可以得到想通了。 –

相關問題