2017-06-19 65 views
1

在此處出現在中間的代碼,我谷歌路線圖 - vAxis線的時候沒有數據傳遞

var data = new google.visualization.DataTable(
 
    { 
 
    cols: [{ label: 'week', type: 'number' }, 
 
    { label: 'Completion', type: 'number' }, 
 
    { type: 'string', role: 'tooltip' }], 
 
    rows: progressList 
 
    } 
 
); 
 
    
 
var options = { 
 
    width: 400, 
 
    height: 265, 
 
    hAxis: { 
 
    title: 'Week', 
 
    titleTextStyle: { fontSize: 12 }, 
 
    'margin-top': '20' 
 
    }, 
 
    chartArea: { 'width': '82%', 'height': '75%' }, 
 
    pointSize: 5, 
 
    legend: 'none', 
 
    tooltip: { showColorCode: true }, 
 
    vAxis: { 
 
    title: 'Completion %', 
 
    titleTextStyle: { fontSize: 12 }, 
 
    ticks: [0, 20, 40, 60, 80, 100] 
 
    } 
 
}; 
 

 
chart.draw(data, options);

這是我的圖表看起來如何當一個空數組[]被傳入它。

enter image description here

有沒有辦法移動Vaxis線向左?

回答

0

設置選項 - >hAxis.viewWindow.min

hAxis: { 
    viewWindow: { 
    min: 0 
    } 
}, 

看到下面的工作片段...

google.charts.load('current', { 
 
    callback: drawChart, 
 
    packages:['corechart'] 
 
}); 
 

 
function drawChart() { 
 
    var data = new google.visualization.DataTable({ 
 
    cols: [ 
 
     {label: 'week', type: 'number'}, 
 
     {label: 'Completion', type: 'number'}, 
 
     {type: 'string', role: 'tooltip'} 
 
    ], 
 
    rows: [ 
 
    ] 
 
    }); 
 

 
    var options = { 
 
    width: 400, 
 
    height: 265, 
 
    hAxis: { 
 
     title: 'Week', 
 
     titleTextStyle: { 
 
     fontSize: 12 
 
     }, 
 
     viewWindow: { 
 
     min: 0 
 
     } 
 
    }, 
 
    chartArea: { 
 
     width: '82%', 
 
     height: '75%' 
 
    }, 
 
    pointSize: 5, 
 
    legend: 'none', 
 
    tooltip: { 
 
     showColorCode: true 
 
    }, 
 
    vAxis: { 
 
     title: 'Completion %', 
 
     titleTextStyle: { 
 
     fontSize: 12 
 
     }, 
 
     ticks: [0, 20, 40, 60, 80, 100] 
 
    } 
 
    }; 
 

 
    var chart = new google.visualization.LineChart(document.getElementById('chart_div')); 
 
    chart.draw(data, options); 
 
}
<script src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div id="chart_div"></div>

+0

希望這有助於... – WhiteHat