2012-03-01 94 views

回答

1

如果你的x值都是數字,你可以給選項hAxis: {minValue:0}功能:

function drawVisualization() { 
    // Create and populate the data table. 
    var data = new google.visualization.DataTable(); 
    data.addColumn('number', 'x'); 
    data.addColumn('number', 'Cats'); 
    data.addColumn('number', 'Blanket 1'); 
    data.addColumn('number', 'Blanket 2'); 
    data.addRow([0, 1, 1, 0.5]); 
    data.addRow([1, 2, 0.5, 1]); 
    data.addRow([2, 4, 1, 0.5]); 
    data.addRow([3, 8, 0.5, 1]); 
    data.addRow([4, 7, 1, 0.5]); 
    data.addRow([5, 7, 0.5, 1]); 
    data.addRow([6, 8, 1, 0.5]); 
    data.addRow([7, 4, 0.5, 1]); 
    data.addRow([8, 2, 1, 0.5]); 
    data.addRow([9, 3.5, 0.5, 1]); 

    // Create and draw the visualization. 
    new google.visualization.LineChart(document.getElementById('visualization')). 
     draw(data, {curveType: "function", 
        width: 900, height: 400, 
        hAxis: {minValue:0}, 
        vAxis: {maxValue: 10}} 
     ); 
} 

試試這個代碼在這裏:http://code.google.com/apis/ajax/playground/?type=visualization#line_chart