1
こんにちは私はレンダリングされているチャートを持っており、キーは列のタイトルと同様に表示されています。JSONのAMchartsデータの集まり
私の問題は、私が渡している値から生成する実際のバーを取得できないということです。
私のPHPコードは問題なく、データを返すときに関数json_encodeを使用しています。
function supportsSVG() {
return !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;
}
var token = $('#_token').val();
$.ajax({
url: 'getShares',
type: 'post',
// dataType:'json',
data: {
_token: token,
},
success: function (data, textStatus, jQxhr) {
var DBData = jQuery.parseJSON(data);
UserGroupsBar = new AmCharts.AmSerialChart();
// var Data = [{}];
UserGroupsBar.dataProvider = DBData;
UserGroupsBar.startDuration = 1;
UserGroupsBar.categoryField = "gid";
$.each(DBData, function (i, item) {
// alert(item['Users']);
if (item['Users'] > 0) {
// Data[0][item['gid'] = item['Users']];
var UserGroupGraph = new AmCharts.AmGraph();
UserGroupGraph.id = item['gid'];
UserGroupGraph.valueField = item['Users'];
UserGroupGraph.title = item['gid'];
UserGroupGraph.type = "column";
UserGroupGraph.lineAlpha = 0;
UserGroupGraph.fillAlphas = 1;
UserGroupGraph.balloonText = "[[title]]: [[value]]";
UserGroupsBar.addGraph(UserGroupGraph);
}
});
UserGroupsBar.write("BarChart");
var GroupValueAxis = new AmCharts.ValueAxis();
GroupValueAxis.axisColor = "#DADADA";
GroupValueAxis.gridAlpha = 0.1;
GroupValueAxis.integersOnly = true;
UserGroupsBar.addValueAxis(GroupValueAxis);
UserGroupsBar.outlineColor = "#FFFFFF";
UserGroupsBar.outlineAlpha = 0.2;
UserGroupsBar.outlineThickness = 2;
UserGroupsBar.startDuration = supportsSVG() ? 1 : 0;
UserGroupsBar.depth3D = supportsSVG() ? 20 : 0;
UserGroupsBar.angle = supportsSVG() ? 30 : 0;
//Root Causes Legend
GroupLegend = new AmCharts.AmLegend();
UserGroupsBar.addLegend(GroupLegend, "Legend");
GroupLegend.valueText = "";
GroupLegend.align = "center";
GroupLegend.position = "absolute";
GroupLegend.marginTop = 30;
GroupLegend.markerType = "circle";
GroupLegend.labelWidth = 180;
GroupLegend.fontSize = 10;
GroupLegend.verticalGap = 20;
// WRITE
UserGroupsBar.write("BarChart");
}
});
それは私が、私はちょうど何かが欠けする必要があります知っている今、働いて本当に近いようだ:
ここ[{"gid":"NickShare","Users":1},
{"gid":"admin","Users":2},
{"gid":"sharedTest","Users":2}]
は、チャートのための私のjQueryのコードです:ここで返されたデータは、グラフのコードに渡されています愚かですが、私はそれをずっと見つめています。どんな指導も大歓迎です。
乾杯; NE
:この中に、
:修正するには、この行を置き換えます。 –