您好我正在尝试显示D3饼图,但我只获得图例符号...有人可以帮我显示动态数据显示的d3饼图。它不会显示任何错误只有图例符号显示饼图是没有显示。
这是我正在使用的html
<script src="angularjs-nvd3-directives-master/examples/js/angular.js"></script>
<script src="angularjs-nvd3-directives-master/examples/js/d3.js"></script>
<script src="angularjs-nvd3-directives-master/examples/js/nv.d3.js"></script>
<script src="angularjs-nvd3-directives-master/dist/angularjs-nvd3-directives.js"></script>
<link href="angularjs-nvd3-directives-master/examples/stylesheets/nv.d3.css" rel="stylesheet" />
<style>
#chart svg {
height: 295px;
width:300px;
}
</style>
<div id="chart">
<svg></svg>
</div>
and the javascript code i am using is...I want to display pie chart for dynamic data.
$.ajax({
type: "POST",
url: "Assets.asmx/Statereport",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess
});
function OnSuccess(data, status) {
var myObject = JSON.parse(data.d);
var source = {
datatype: "json",
datafields: [
{ name: 'totsch' },
{ name: 'districtname' },
{ name: 'statename' }
],
localdata: myObject
};
var dataAdapter = new $.jqx.dataAdapter(source);
var ObjectIDs = [];
for (var i = 0; i < myObject.length; i++) {
ObjectIDs.push(myObject[i].statename);
}
var gridquerystr = ObjectIDs[0].toString();
nv.addGraph(function () {
var chart = nv.models.pieChart()
.x(function (d) { return d.label })
.y(function (d) { return d.value })
.showLabels(false);
d3.select("#chart svg")
.datum(myObject)
.transition().duration(1200)
.call(chart);
return chart;
});
please help me as soon as posssible..... or suggest me any opensource charts for displaying dynamic data using ajax json data . I am new to coding so please help
[![d3 pie chart][1]][1]
[1]: http://i.stack.imgur.com/ppqZf.jpg