我需要爲我的hAxis設置minValue爲09:00和maxValue 17:00(1小時增量)(即9,10,11,12, 13,14,...,17)minValue和maxValue作爲Google Chart中hAxis的時間範圍
目前我的數據被格式化爲H:米(例如:9點35分,10點20)
var formatter3 = new google.visualization.DateFormat({pattern: 'H:m'});
formatter3.format(data,0);
並在下文中我的選擇:
var options = {
curveType: "function",
title : '',
hAxis:{slantedTextAngle: 90,textStyle:{fontSize:8}},
colors : ['red','#3366CC', '#999999'],
vAxes: {
0: {logScale: false, format:'0.0000'},
1: {logScale: false}
},
hAxis: {
format: 'H:m',
minValue: new Date(null, null, null, 9, 0, 0),
maxValue: new Date(null, null, null, 17, 0, 0),
viewWindow:{min: new Date(null, null, null, 9, 0, 0),
max: new Date(null, null, null, 17, 0, 0)},
series: {
0: {targetAxisIndex:0, type: "line"},
1: {targetAxisIndex:0, type: "line"},
2: {targetAxisIndex:1, type: "bars"}
}
};
但是,它仍然無法正常工作。請指教。謝謝!
嗨,謝謝你的回答。您是否會提供一些刻度值的例子來說明如何完成?非常感謝。 –
我試過上面的解決方案,但它不起作用。你會幫助我指出正確的方向嗎?謝謝。 VAR選項= { curveType: 「功能」, hAxis:{slantedTextAngle:90,TEXTSTYLE:{fontSize的:8}}, vAxes:{ 0:{logScale:假的,格式爲: '0.0000'}, 1 :{logScale:false} }, hAxis:格式:'H:m', 記號:[[9,0,0],[10,0,0],[11,0,0], [12,0,0],[13,0,0],[14,0,0],[15,0,0],[16,0,0],[17,0,0]] } , 系列:{ 0:{targetAxisIndex:0,類型: 「行」}, 1:{targetAxisIndex:0,類型: 「行」}, 2:{targetAxisIndex:1,類型: 「棒」} } }; –
您可能還需要使用最新版本。在你的google.load()調用中,使用「1.1」而不是「1」。 – dlaliberte