私はhighchartsを初めて使っています。私はタイトルを表示することができますが、何らかの理由でx軸とy軸のデータが表示されません。私はPHPでデータベースからデータを取得していますが、JSONでエンコードしています。ここに私のHTMLは次のとおりです。ここでハイチャートをphpとMySqlで使用しているときに私のタイトルだけが表示されます
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: 'TCP Upload Speed Averages for Los Angeles County in 2012',
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
categories: []
},
yAxis: {
min:0,
title: {
text: 'TCP Upload Averages'
},
labels: {
overflow: 'justify'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
},
series: {
stacking:'percent'
}
},
series: []
};
$.getJSON("2012Data.php", function(json) {
options.xAxis.categories = json[0]['data'];//xAxis: {categories: []}
options.series[0] = json[1];
//chart = new Highcharts.Chart(options);
});
chart = new Highcharts.Chart(options);
});
</script>
<script src="highstock.js" ></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="width: 600px; height: 400px; margin: 0 auto"></div>
</body>
は、PHPから私のJSONデータである:
[{ "名": "プロバイダ"、 "データ":[ "& T AT"、 "Sprint"、 "T-Mobile"、 "Verizon"]}、{"名前": "平均"、 "データ":[972.03790849673,679.63696969697,992.06606060606,4520.2101851852]]
ありがとうございました!
サーバー側がなくても動作しますか? –
あなたのコメントは、ajaxコールバックでチャートを初期化する必要があります。 –