Googleマップでグラフを描画しています。チャートには3〜5本の異なる色のバーがあります。 x軸の下のスペースはそれほど大きくないので、バーの右上に凡例を追加したいと思います。伝説はどの色がどのテキストであるかを視覚的に示すべきです(私は評判= 10を持っていないのでイメージを追加できません)。あなたはannotation色付きのGoogle棒グラフに凡例(色に対してテキストを表示)を追加するにはどうすればよいですか?
注釈は、列の役割を使用して提供されている使用するように、role: 'style'
列に似
が既に使用されて聞こえる
var data = new google.visualization.arrayToDataTable([
['Year', 'ONE', { role: 'style' } ],
['2010', 10, 'color: white'],
['2020', 14, 'color: gray'],
['2030', 16, 'color: yellow'],
['2040', 22, 'color: green'],
['2050', 28, 'color: red']
]);
// Set chart options
var options = {'title':'Revenue per Year', //main title
'width':500, //pixel density
'height':500, //pixel density
bar: {groupWidth: "95%"}, //width of the vertical bars
legend: { position: "right", maxLines: 3 }, //none=dont show legends
backgroundColor: { fill:'transparent' }, //!!NOTE: this is needed for transparency and to remove white background
titleTextStyle: { color: 'red',fontSize: 24},
//options for vertical axis(Y)
vAxis: {
textStyle:{color: '#FFF',fontSize: 24},
slantedText:true, slantedTextAngle:60 // here you can even use 180
},
//options for horizontal access(X)
hAxis: {
textStyle:{color: '#FFF',fontSize: 24},
direction:-1, slantedText:true, slantedTextAngle:60 // here you can even use 180
}
};
おかげで発生したときに、背中にそれらを移動します。コードは働いた:-)。私はそれが私が取り組んでいるアプリに合うようにカスタマイズしました。 – nihal