[英]How to configure google chart to change from line to column
我有一個呈現在圖表的html頁面中的圖表。
圖表如下所示:
我的代碼是:
google.charts.load('current', {'packages':['corechart','bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Data', 'Valor de Compra'],
<?php echo $dados;?>
var options = {
'backgroundColor': 'transparent',
hAxis: {
format: 'y M/dd',
gridlines: {count: 15},
direction:1, slantedText:true, slantedTextAngle:90,
},
vAxis: {
gridlines: {color: 'none'},
minValue: 0
}
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
變量$ dados正在獲取以下數據:
[new Date(2018, 11, 04), 3.00],[new Date(2018, 11, 03), 3.20],[new Date(2018, 10, 29), 2.95],[new Date(2018, 10, 29), 3.50],[new Date(2018, 10, 23), 3.20],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 18), 2.95],[new Date(2018, 9, 17), 2.95],[new Date(2018, 9, 17), 2.90],[new Date(2018, 9, 12), 2.95],[new Date(2018, 9, 11), 2.95],[new Date(2018, 9, 11), 2.95],[new Date(2018, 9, 08), 2.20],[new Date(2018, 8, 13), 2.10],[new Date(2018, 8, 13), 2.10],[new Date(2018, 8, 12), 2.00],[new Date(2018, 8, 12), 2.95],[new Date(2018, 8, 08), 2.00],[new Date(2018, 8, 07), 2.10],
]);
我的目標是將這種布局更改為更具吸引力和美觀的外觀。
我一直在嘗試將其更改為柱形圖,但到目前為止,所有操作都失敗了...我確定它一定很簡單...
有沒有辦法只在新的一年開始時和新的月份開始時才有年份和月份?
先感謝您!
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Data', 'Valor de Compra'],
]);
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
然后
<div id="columnchart_material" style="width: 800px; height: 500px;"></div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.