0

こんにちは、h 軸のすべての値を 12 から開始して 20 で終了するように表示しようとしています。12、13、14、15、16、17、18、19、20 のように表示されます。

ティックを次のように使用してみました

hAxis: {
    ticks: dataTable.getDistinctValues(0);
} 

上記のコード行は機能しません。

以下は私の現在のコードです

<html><head><script type="text/javascript" src="https://www.google.com/jsapi"></script>        <script type="text/javascript"> 
 google.load("visualization", "1.1", {packages:["corechart"]});
 google.setOnLoadCallback(drawChart);
 function drawChart() {
 var data = new google.visualization.DataTable();
 data.addColumn('datetime', 'Dates'); 
 data.addColumn('number','Glucose');     data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});  
 data.addColumn('number','Glucose');     data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});  
 data.addColumn('number','Glucose');    data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}}); 
 data.addColumn('number','Glucose');    data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});  
 data.addColumn('number','Glucose');    data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}});  
 data.addColumn('number','Glucose');    data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}}); 
 data.addColumn('number','Glucose');    data.addColumn({type: 'string', role: 'tooltip', 'p': {'html': true}}); 

 data.addRows([                            
 [new Date(2014,1,7,11,25,0,0), 110.00, '02 feb - 11:25 | 110.00\\nSunday', null, null, null, null, null, null, null, null, null, null, null, null], 
 [new Date(2014,1,7,11,26,0,0), null, null, null, null, 150.00, '04 feb - 11:26 | 150.00\\nTue', null, null, null, null, null, null, null, null],   
 [new Date(2014,1,7,11,35,0,0), null, null, null, null, null, null, 90.00, '05 feb - 11:35 | 90.00\\nHhgg', null, null, null, null, null, null],   
 [new Date(2014,1,7,11,36,0,0), null, null, null, null, null, null, null, null, 70.00, '06 feb - 11:36 | 70.00\\nHhj', null, null, null, null],  
 [new Date(2014,1,7,11,54,0,0), null, null, null, null, 100.00, '04 feb - 11:54 | 100.00\\nCc', null, null, null, null, null, null, null, null],  
 [new Date(2014,1,7,13,27,0,0), null, null, null, null, null, null, 258.00, '05 feb - 13:27 | 258.00\\nThu', null, null, null, null, null, null], 
 [new Date(2014,1,7,15,57,0,0), null, null, null, null, 123.00, '04 feb - 15:57 | 123.00\\nGhgggf', null, null, null, null, null, null, null, null], 
 [new Date(2014,1,7,20,0,0,0), null, null, null, null, null, null, null, null, null, null, null, null, 120.00, '01 feb - 20:00 | 120.00\\nSat'],    
 [new Date(2014,1,7,20,42,0,0), null, null, 115.00, '03 feb - 20:42 | 115.00\\nMon', null, null, null, null, null, null, null, null, null, null]  
 ]);                  
 var chart = new     google.visualization.ScatterChart(document.getElementById('chart_div'));  
 chart.setAction({ id: 'sample', text: 'Ver detalles', 
action: function() 
{ 
selection = chart.getSelection(); var selectedRow = selection[0].row;  
window.location.href = "yourapp://"+selectedRow;    
}              
}); 
chart.draw(data,                                                   
 {width: 280, height: 140,                                               
 actionsMenu: {textStyle: {color: '#343434',fontName: 'verdana',fontSize:12}},   
 chartArea:{top:20,left:35,width: '85%',height: '70%'}, 
 legend: { position: 'bottom', alignment:'start'},      
 backgroundColor:'transparent',                          
 legend: {position: 'none'},                       
 titleTextStyle:{color: 'black', fontName: 'verdana', fontSize: 8}, 
 hAxis: {format: 'H', textStyle: {color: '#343434',fontName:   'verdana',fontSize:6},baselineColor:'transparent',gridlineColor:  'transparent',viewWindowMode:'explicit', viewWindow:{ min: new Date(2014,1,7,11,25,0,0), max: new Date(2014,1,7,20,42,0,0)}},     

 vAxis: {title:'Glucosa',textStyle: {color: '#343434',fontName: 'verdana',fontSize:6},baselineColor:'transparent',gridlineColor: 'transparent'},  
 fontSize: 6,                                      
 tooltip:{textStyle:{color: '#343434', fontName:'verdana',fontSize: 10},trigger: 'selection'},   

 series: {                                                  
 0:{color: '#CCCCCC', visibleInLegend:true, pointSize:6},   
 1:{color: '#ffff00', visibleInLegend:true, pointSize:6},  
 2:{color: '#ff0000', visibleInLegend:true, pointSize:6}, 
 3:{color: '#0000ff', visibleInLegend:true, pointSize:6},  
 4:{color: '#008000', visibleInLegend:true, pointSize:6},    
 5:{color: '#696969', visibleInLegend:true, pointSize:6},   
 6:{color: '#ff00ff', visibleInLegend:true, pointSize:6}   
 },});                           
 google.visualization.events.addListener(chart, 'click', function(e) 
 {                            
 var targetType = e.targetID ? e.targetID.split('#')[0] : null;     
 if (targetType && targetType !== 'point' && targetType !== 'action' && targetType !== 'tooltip')
 {                            
 chart.setSelection([]); 
 }                            
 });                            
 }

添付の画像は、上記のコードの出力を示しています。

上記コードの出力

4

1 に答える 1

0

あなたのケースで返される値のリストはdataTable.getDistinctValues(0)、必要な配列を作成するリストを返しません。これは によって返されるものですdataTable.getDistinctValues(0):

[
    new Date(2014, 1, 7, 11, 25),
    new Date(2014, 1, 7, 11, 26),
    new Date(2014, 1, 7, 11, 35),
    new Date(2014, 1, 7, 11, 36),
    new Date(2014, 1, 7, 11, 54),
    new Date(2014, 1, 7, 13, 27),
    new Date(2014, 1, 7, 15, 57),
    new Date(2014, 1, 7, 20),
    new Date(2014, 1, 7, 20, 42)
]

そして、これはあなたが望む配列がどのように見えるべきかです:

[
    new Date(2014, 1, 7, 12),
    new Date(2014, 1, 7, 13),
    new Date(2014, 1, 7, 14),
    new Date(2014, 1, 7, 15),
    new Date(2014, 1, 7, 16),
    new Date(2014, 1, 7, 17),
    new Date(2014, 1, 7, 18),
    new Date(2014, 1, 7, 19),
    new Date(2014, 1, 7, 20)
]
于 2014-02-07T17:14:43.953 に答える