2015-11-20 44 views

回答

0

我覺得材料LineCharts還不支持蜱。在上的jsfiddle this例如

chart.draw(data, google.charts.Line.convertOptions(options)); 

像:

var options = { 
    vAxis: { 
     viewWindow: { 
       max: 5 
      }, 
    ... 

,並呼籲convertOptions:vAxis並與變化值最大嘗試 - 但你可以嘗試選擇插入。

+0

我嘗試添加蜱: [1,2,3]在上面的例子中,但我看不到任何更改呈現圖表。你能修改這個例子嗎?謝謝 – Sampat

+0

回答編輯... –

0

首先,在Material Charts仍處於測試材料圖表還不支持很多由 corecharts支持的選項。

關於明確設置ticks選項,看起來好像它是而不是支持。如果你想在材料樣式(至少在字體和顏色)與corecharts,你可以補充一點:

option: { theme: 'material' } 

google.load('visualization', '1.1', {packages: ['corechart']}); 
 
    google.setOnLoadCallback(drawChart); 
 

 
    function drawChart() { 
 

 
     var data = new google.visualization.DataTable(); 
 
     data.addColumn('number', 'Day'); 
 
     data.addColumn('number', 'Guardians of the Galaxy'); 
 

 
     data.addRows([ 
 
     [1, 7.8], 
 
     [2, 3.9], 
 
     [3, 2.4], 
 
     [4, 1.7], 
 
     [5, 1.9], 
 
     [6, 8.8], 
 
     [7, 7.6], 
 
     [8, 2.3], 
 
     [9, 6.9], 
 
     [10, 2.8], 
 
     [11, 5.3], 
 
     [12, 6.6], 
 
     [13, 4.8], 
 
     [14, 4.2] 
 
     ]); 
 

 
     var options = { 
 
     title: 'Box Office Earnings in First Two Weeks of Opening', 
 
     width: 900, 
 
     height: 500, 
 
     vAxis: { 
 
       viewWindow: { 
 
        min: 0, 
 
        max: 10 
 
       }, 
 
       ticks: [0,1,2,3,4,5,6,7,8,9,10] 
 
     }, 
 
     hAxis: { 
 
       viewWindow: { 
 
        min: 1, 
 
        max: 14 
 
       }, 
 
       ticks: [1,2,3,4,5,6,7,8,9,10,11,12,13,14] 
 
     }, 
 
     theme: 'material' 
 
     }; 
 

 
     var chart = new google.visualization.LineChart(document.getElementById('linechart_material')); 
 
     chart.draw(data, options); 
 
    }
<script type="text/javascript" src="https://www.google.com/jsapi"></script> 
 
<div id="linechart_material"></div>