我不太确定我做错了什么。当我运行所有这些代码时,图例有点偏斜并偏离中心。我希望每个图例项都在相应的行旁边。有没有办法对齐图例,使其恰好位于相应的线旁边?我提供了以下代码。我试图通过使用不同的选项解决传奇问题。但他们似乎无法工作。
google.charts.load('current', {packages: ['corechart', 'line']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'Bowser');
data.addColumn('number', 'Captain Falcon');
data.addColumn('number', 'Donkey Kong');
data.addColumn('number', 'Dr. Mario');
data.addColumn('number', 'Falco');
data.addColumn('number', 'Fox');
data.addColumn('number', 'Ganondorf');
data.addColumn('number', 'Ice Climbers');
data.addColumn('number', 'Jigglypuff');
data.addColumn('number', 'Kirby');
data.addColumn('number', 'Link');
data.addColumn('number', 'Luigi');
data.addColumn('number', 'Mario');
data.addColumn('number', 'Marth');
data.addColumn('number', 'Mewtwo');
data.addColumn('number', 'Mr. Game & Watch');
data.addColumn('number', 'Ness');
data.addColumn('number', 'Peach');
data.addColumn('number', 'Pichu');
data.addColumn('number', 'Pikachu');
data.addColumn('number', 'Roy');
data.addColumn('number', 'Samus');
data.addColumn('number', 'Sheik');
data.addColumn('number', 'Yoshi');
data.addColumn('number', 'Young Link');
data.addColumn('number', 'Zelda');
data.addRows([
[1, 24, 15, 19, 10, 2, 2, 11, 11, 17, 22, 13, 6, 5, 4, 26, 23, 17, 9, 24, 13, 21, 6, 1, 19, 15, 6],
[2, 22, 12, 20, 7, 3, 2, 10, 12, 10, 22, 14, 9, 6, 5, 25, 22, 14, 4, 26, 17, 20, 8, 1, 18, 18, 14],
[3, 26, 11, 21, 7, 3, 2, 12, 13, 10, 23, 18, 8, 6, 4, 24, 22, 15, 5, 25, 16, 17, 9, 1, 14, 19, 20],
[4, 26, 11, 21, 8, 5, 2, 10, 15, 9, 23, 18, 12, 7, 3, 24, 22, 17, 4, 25, 13, 20, 6, 1, 14, 19, 16],
[5, 26, 7, 22, 10, 5, 3, 8, 18, 11, 21, 14, 12, 9, 2, 23, 24, 20, 4, 25, 16, 15, 6, 1, 13, 17, 19],
[6, 25, 6, 21, 11, 4, 2, 9, 15, 8, 22, 13, 12, 10, 3, 24, 23, 20, 5, 26, 14, 16, 7, 1, 19, 18, 17],
[7, 24, 6, 16, 9, 5, 2, 10, 12, 8, 22, 14, 13, 11, 3, 25, 23, 19, 4, 26, 17, 15, 7, 1, 21, 20, 18],
[8, 23, 6, 15, 9, 2, 1, 12, 7, 10, 24, 13, 14, 11, 4, 26, 21, 22, 5, 25, 18, 16, 8, 3, 19, 17, 20],
[9, 23, 6, 13, 10, 4, 1, 11, 8, 6, 25, 15, 12, 14, 2, 24, 20, 21, 5, 26, 16, 18, 9, 3, 22, 17, 19],
[10, 24, 7, 15, 9, 2, 1, 10, 8, 3, 25, 16, 14, 13, 5, 20, 22, 23, 6, 25, 12, 19, 11, 4, 21, 17, 18],
[11, 24, 7, 17, 9, 2, 1, 12, 8, 5, 26, 16, 13, 14, 4, 21, 22, 23, 6, 25, 10, 20, 11, 3, 18, 15, 19],
[12, 25, 8, 17, 11, 2, 1, 14, 7, 5, 26, 18, 13, 15, 3, 21, 19, 23, 6, 24, 9, 20, 10, 4, 12, 16, 22],
]);
var options = {
title: 'Character Tiers Over Time',
theme: 'material',
hAxis: {
title: 'Tier List',
gridlines: {
count: 12
}
},
vAxis: {
title: 'Placing',
gridlines: {
count: 27
},
viewWindow: {
max: 26,
min: 1
}
},
legend: {
position: 'labeled'
},
height: 1000
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
http://i.imgur.com/F59AZq9.png
这是指向图表图像的链接。