2017-05-03 3 views
1

各ステップを個別に色分けすることは可能ですか?今Googleのステップエリアチャートを彩色していますか?

...あなたが作業スニペット以下を参照してください'style'column role

を使用することができます

<div id="chart_div" style="width: 100%; height: 200px;"></div> 
     google.charts.load('current', {'packages':['corechart']}); 
     google.charts.setOnLoadCallback(drawChart); 

     function drawChart() { 
     var data = google.visualization.arrayToDataTable([ 
      ['Step', 'Equity'], 
      ['1', -40], 
      ['2', -40], 
      ['3', -40], 
      ['4', -40], 
      ['5',  -30], 
      ['6',  -30], 
      ['7',  10], 
      ['8',  10], 
      ['9',  10], 
      ['10',  50] 
     ]); 

     var options = { 
     legend: 'none', 
       vAxis: { ticks: [{v:-50, f:'0%'}, {v:0, f:'50%'}, {v:50, f:'100%'}] }, 
     enableInteractivity: false, 
     hAxis: { textPosition: 'none' }, 
     chartArea:{top:10,left:40,bottom:10,right:5, width:"100%",height:"100%"}, 
     }; 

     var chart = new google.visualization.SteppedAreaChart(document.getElementById('chart_div')); 

     chart.draw(data, options); 
     } 

答えて

1

...、二黄、赤三、すべてのステップは青ですが、私は最初のステップは、青いたい

google.charts.load('current', { 
 
    callback: function() { 
 

 
    var data = google.visualization.arrayToDataTable([ 
 
     ['Step', 'Equity', {role: 'style'}], // <-- define style column 
 
     ['1', -40, 'blue'], 
 
     ['2', -40, 'yellow'], 
 
     ['3', -40, 'red'], 
 
     ['4', -40, 'green'], 
 
     ['5', -30, 'purple'], 
 
     ['6', -30, 'orange'], 
 
     ['7', 10, 'cyan'], 
 
     ['8', 10, 'indigo'], 
 
     ['9', 10, 'magenta'], 
 
     ['10',50, 'lime'] 
 
    ]); 
 

 
    var options = { 
 
     legend: 'none', 
 
     vAxis: { ticks: [{v:-50, f:'0%'}, {v:0, f:'50%'}, {v:50, f:'100%'}] }, 
 
     enableInteractivity: false, 
 
     hAxis: { textPosition: 'none' }, 
 
     chartArea:{top:10,left:40,bottom:10,right:5, width:"100%",height:"100%"}, 
 
    }; 
 

 
    var chart = new google.visualization.SteppedAreaChart(document.getElementById('chart_div')); 
 

 
    chart.draw(data, options); 
 
    }, 
 
    packages:['corechart'] 
 
});
<script src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div id="chart_div"></div>

関連する問題