我一直在尝试使用d3在2d图表的基础上绘制散点图,我无法生成散点图,我有包含数据的xml文件 看看几个教程,我能够了解如何绘制x和y轴并调用xml,但无法生成散点图。请帮帮我.. script标签内的代码如下:
<script>
var margin = { top: 20, right: 20, bottom: 30, left: 40 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var color = d3.scale.category10();
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.xml("lookup.xml","application.xml", function (xml) {
});
</script>
xml数据
<Data>
<Week_Avg>
Monday (mm)
<D_date>2012-01-12</D_date>
<Number>1.1</Number>
</Week_Avg>
</Data>
<Data>
<Week_Avg>
Tuesday (mm)
<D_date>2011-04-01</D_date>
<Number>2.2</Number>
</Week_Avg>
</Data>
<Data>
<Week_Avg>
Wednesday (mm)
<D_date>2012-06-15</D_date>
<Number>3.3</Number>
</Week_Avg>
</Data>