2014-12-04 103 views

回答

0

谷歌的圖表有一個趨勢線的選項:從自己的文件 https://developers.google.com/chart/interactive/docs/gallery/trendlines

例子:

google.setOnLoadCallback(drawChart); 

function drawChart() { 
    var data = google.visualization.arrayToDataTable([ 
    ['Diameter', 'Age'], 
    [8, 37], [4, 19.5], [11, 52], [4, 22], [3, 16.5], [6.5, 32.8], [14, 72]]); 

    var options = { 
    title: 'Age of sugar maples vs. trunk diameter, in inches', 
    hAxis: {title: 'Diameter'}, 
    vAxis: {title: 'Age'}, 
    legend: 'none', 
    trendlines: { 0: {} } // Draw a trendline for data series 0. 
    }; 

    var chart = new google.visualization.ScatterChart(document.getElementById('chart_div')); 
    chart.draw(data, options); 
} 

我已經與他們的線型圖使用該withou沒有任何問題。