google.charts.load('current', {
callback: drawChart,
packages:['table']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['ID', 'Carrier A', 'Carrier B', 'Carrier C', 'Amount'],
[1, 'S', 'V', 'A', 36],
[2, 'V', 'A', 'S', 15],
[3, 'A', 'V', 'T', 22],
[4, 'S', 'A', 'V', 48]
]);
var dataView = new google.visualization.DataView(data);
dataView.setColumns([0, {
calc: function (dt, row) {
return getCarrierName(dt.getValue(row, 1));
},
type: 'string',
label: data.getColumnLabel(1)
}, {
calc: function (dt, row) {
return getCarrierName(dt.getValue(row, 2));
},
type: 'string',
label: data.getColumnLabel(2)
}, {
calc: function (dt, row) {
return getCarrierName(dt.getValue(row, 3));
},
type: 'string',
label: data.getColumnLabel(3)
}, 4]);
function getCarrierName(abbr) {
var name;
switch (abbr) {
case 'A':
name = 'AT&T';
break;
case 'S':
name = 'Sprint';
break;
case 'T':
name = 'T-Mobile';
break;
case 'V':
name = 'Verizon';
break;
default:
name = '';
}
return name;
}
var chart = new google.visualization.Table(document.getElementById('chart_div'));
chart.draw(dataView);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
あなたは伝説を変えようとしましたか? –
[Googleの折れ線グラフ/ Googleの折れ線グラフの凡例を作成する方法](https://stackoverflow.com/questions/35987014/how-to-write-your-own-custom-legends- google-line-chart-go-line-chart-le) – juvian
@WhiteHatサンプルデータで質問を更新しました – user2896120