2015-10-15 75 views
1

我畫代表在美國的殺人率條形圖 我試圖通過在> 0設置基準截斷此表,但代碼:在谷歌圖表設置條形圖的基線和範圍

var options = { 
     chart: { 
     title: 'Intentional homicide rate per 100,000 population, by country/territory (2000-2013) in the US', 
     subtitle: 'Intentional homicide is defined as unlawful death purposefully inflicted on a person by another person', 
     hAxis: {title: 'Year'}, 
     vAxis: { 
       title: 'Rate per 100,000', 
       viewWindow:{ 
       max:20, 
       min:2 
       }, 
     // ticks: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] 
     }, 
     } 
    }; 

沒有完成它的工作,並顯示出與我的目標相反的整個範圍。

This是圖表的完整代碼。 我誤了什麼? (Pluckr example)...怎麼回事?

回答

1

您的代碼不正確,正如其他答案中所述。

使用材料圖表時,您需要使用功能google.charts.Bar.convertOptionsSource(向下滾動一下,或者ctrl + f查看convertOptions)。

您目前正在繪製圖表與

chart.draw(data, options); 

而正確的方法是

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

Working plunker

(這也是爲什麼它的工作與面積圖..這不是一張材料圖)。

+0

它的工作原理,謝謝! –