2017-06-19 4 views
1

が渡されていない場合vAxisラインは、私が持っている途中でコードされて現れて、Googleの折れ線グラフは - データがここ

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

関連する問題