2014-12-05 70 views
0

我嘗試在xAxie和vAxie上使用字符串實現折線圖。 對於vAxie,我想從10eme開始,並以1er結束。是否可以切換這些值? 今日:
10eme
9eme
8eme
7eme
6eme
4eme
3eme
2eme
1er酒店
1 JOURNEE/2 JOURNEE/3 JOURNEE/...Google折線圖使用字符串定義vAx並定義位置

對象:
1er酒店
2eme
3eme
4eme
5eme
6eme
7eme
8eme
9eme
10eme
1 JOURNEE/2 JOURNEE/3 JOURNEE/...

<!DOCTYPE HTML> 
 
<html> 
 
    <head> 
 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
 
    <script type="text/javascript"> 
 
     google.load("visualization", "1", {packages:["corechart"]}); 
 
     google.setOnLoadCallback(drawChart); 
 
     function drawChart() { 
 
     var data = google.visualization.arrayToDataTable([ 
 
      ['Journee', 'Position'], 
 
      ['1 Journee', 10], 
 
      ['2 Journee', 7], 
 
      ['3 Journee', 7], 
 
      ['4 Journee', 6], 
 
      ['5 Journee', 8], 
 
      ['6 Journee', 9], 
 
      ['7 Journee', 10] 
 
\t 
 
     ]); 
 

 
     var options = { 
 
      title: 'Evolution au classement', 
 
      hAxis: {title: 'Journee', titleTextStyle: {color: '#333'}}, 
 
\t \t vAxis: {title: 'Classement'},    
 
\t \t vAxis: {minValue: 1},   
 
\t \t vAxis: {maxValue: 10}, 
 
      viewWindowMode:'explicit', \t \t 
 
\t \t vAxis: {title: 'Classement', ticks: [{v:1, f:"1er"},{v:9, f:"9eme"},{v:8, f:"8eme"},{v:7, f:"7eme"},{v:6, f:"6eme"},{v:5, f:"5eme"},{v:4, f:"4eme"},{v:3, f:"3eme"},{v:2, f:"2eme"},{v:10, f:"10eme"}]}, \t \t \t 
 
\t \t pointSize: 5, \t 
 
     }; 
 

 
\t \t 
 
     var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); 
 
     chart.draw(data, options); 
 
     } 
 
    </script> 
 
    </head> 
 
    <body> 
 
    <div id="chart_div" style="width: 900px; height: 500px;"></div> 
 
    </body> 
 
</html>

回答

0

這是好的我找到了一種方法來做到這一點與方​​向:-1在vaxis選項。 這裏的結果。 謝謝

<!DOCTYPE HTML> 
 
<html> 
 
    <head> 
 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
 
    <script type="text/javascript"> 
 
     google.load("visualization", "1", {packages:["corechart"]}); 
 
     google.setOnLoadCallback(drawChart); 
 
     function drawChart() { 
 
     var data = google.visualization.arrayToDataTable([ 
 
      ['Journee', 'EQUIPE 1', 'EQUIPE 2'], 
 
      ['1 Journee', 1, 3], 
 
      ['2 Journee', 2, 5], 
 
      ['3 Journee', 5, 4], 
 
      ['4 Journee', 5, 3], 
 
      ['5 Journee', 6, 5], 
 
      ['6 Journee', 4, 6], 
 
      ['7 Journee', 2, 7] 
 
\t 
 
     ]); 
 

 
     var options = { 
 
      title: 'Evolution au classement', 
 
\t \t curveType: 'function', \t \t 
 
      hAxis: {title: 'Journee', titleTextStyle: {color: '#333'}}, 
 
\t \t vAxis: 
 
\t \t \t {title: 'Classement', minValue: 0, maxValue: 11, direction: -1, ticks: [{v:0, f:""},{v:1, f:"1er"},{v:9, f:"9eme"},{v:8, f:"8eme"},{v:7, f:"7eme"},{v:6, f:"6eme"},{v:5, f:"5eme"},{v:4, f:"4eme"},{v:3, f:"3eme"},{v:2, f:"2eme"},{v:10, f:"10eme"},{v:11, f:""}]}, \t \t 
 
\t \t pointSize: 5, \t \t \t 
 
     }; \t 
 
\t 
 
     var chart = new google.visualization.LineChart(document.getElementById('chart_div')); 
 
     chart.draw(data, options); 
 
     } 
 
    </script> 
 
    </head> 
 
    <body> 
 
    <div id="chart_div" style="width: 900px; height: 500px;"></div> 
 
    </body> 
 
</html>