2014-10-09 44 views
0

您可以在此fiddle如何在谷歌图表中显示较大值的小值?

看到在2004年我有1000个值,而在其他年份我有大的值,因此在规模图表似乎并不能够渲染,什么都可以我确实要显示这些值。我在读this。有没有办法在谷歌图表中做这样的事情?

下面是代码

<html> 
    <head> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     google.load("visualization", "1", {packages:["corechart"]}); 
google.setOnLoadCallback(drawChart); 
function drawChart() { 

    var data = google.visualization.arrayToDataTable([ 
    ['Year', 'Sales', 'Expenses'], 
    ['2004', 1000,  1000], 
    ['2005', 1170000,  460000], 
    ['2006', 660000,  1120000], 
    ['2007', 1030000,  540000] 
    ]); 

    var options = { 
    title: 'Company Performance', 
    hAxis: {title: 'Year', titleTextStyle: {color: 'red'}} 
    }; 

    var chart = new google.visualization.ColumnChart(document.getElementById('chart_div')); 

    chart.draw(data, options); 

} 
    </script> 
    </head> 
    <body> 
    <div id="chart_div" style="width: 900px; height: 500px;"></div> 
    </body> 
</html> 

图表

enter image description here

+0

有一个logScale选项,但仍然也不会转回去工作,为价值1 – juvian 2014-10-09 18:01:23

+0

@juvian我将值更改为1000,并将3个零添加到其他数字,可以评论你的想法 – 2014-10-10 12:41:12

+1

'vAxis:{title:'Year',titleTextStyle:{color:'red'},logScale:true}' – juvian 2014-10-10 15:30:48

回答

3

谷歌Chart's轴有一个选项来设置规模,对数,这更符合了最低和最高之间的巨大差异值。请注意,所有值必须为正,如果数据值为1,则不会显示对数刻度从1开始或更高。要改变它,使用:

vAxis: {title: 'Year', titleTextStyle: {color: 'red'}, logScale:true} 

您可以在配置选项部分中的文档:

Google Chart Configuration Options

相关问题