2017-06-19 68 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