現在、JSONを使用してGoogleグラフにデータを入力していますが、ツールチップもカスタマイズする必要があります。現在、私のJSONは次のようになっています。
{
"cols": [
{"id": "", "label": "date", "type": "string"},
{"id": "", "label": "price", "type": "number"}
],
"rows": [
{"c":[{"v": "Apr 24th","f":null}, {"v": 56000,"f":"56000"}]},
{"c":[{"v": "May 3rd","f":null}, {"v": 68000,"f":"68000"}]},
{"c":[{"v": "May 13th","f":null}, {"v": 50400,"f":"50400"}]}
]
}
しかし、JSONでツールチップを次のように指定すると、次のようになります。
{
"cols": [
{"id": "", "label": "Date", "type": "string"},
{"id": "", "label": "price", "type": "number"},
{"id": "", "role": "tooltip", "type": "string"}
],
"rows": [
{"c":[{"v": "Apr 24th","f":"null"}, {"v": 56000,"f":"56000"}, {"v": "24 April, Price - 56000, Seller-abcd"}]},
{"c":[{"v": "May 3rd","f":"null"}, {"v": 68000,"f":"68000"}, {"v": "3 May, Price - 68000, Seller-abcd"}]},
{"c":[{"v": "May 13th","f":"null"}, {"v": 50400,"f":"50400"}, {"v": "23 May, Price - 50000, Seller-abcd"}]}
]
}
直列のすべての値が同じデータ型である必要があるというエラーが表示されます。
私のクライアント側のコードは次のようになります。
var jsonData = $.ajax({
url: '../phps/testPhp.php',
dataType:"json",
async: false
}).responseText;
var dataTable = new google.visualization.DataTable(jsonData);
var minVal = 50000;
var maxVal = 70000;
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
var options = {
width: 375, height: 240,
legend: 'none',
pointSize: 5,
backgroundColor: 'transparent',
vAxis: { minValue: 45000, maxValue: 70000 }
};
chart.draw(dataTable, options);
誰かが解決策を知っているかどうか私に知らせてください。