Closed toddbruner closed 8 years ago
I think this might be due to your script executing before the body is rendered. Also, you'll need to set the charset to utf-8 for d3.js. The following works for me (paths modified slightly):
<html>
<head>
<meta charset="utf-8">
<link type="text/css" href="dist/d3.compose.css"rel="stylesheet" >
<script type="text/javascript" src="dist/d3.js"></script>
<script type="text/javascript" src="dist/d3.chart.js"></script>
<script type="text/javascript" src="dist/d3.compose-all.js"></script>
<script>
function main() {
var data = [
{x: 1, y: 100,},
{x: 2, y: 200,},
{x: 3, y: 150,}
];
var chart = d3.select('#chart').chart('Compose', function(data){
var charts = [
d3c.lines('results', {data: data})
];
return [
d3c.layered(charts)
];
});
chart.draw(data);
}
</script>
</head>
<body onload="main()">
<h1>Competed Count</h1>
<div id="chart"></div>
</body>
</html>
Renders:
that indeed was the case, thank you for your help!
Probably missing something simple but.
test.html
Generates the following Error: Uncaught TypeError: Cannot read property 'tagName' of nullBase.extend.initialize @ d3.compose-all.js:2106Base @ d3.compose-all.js:1151Child @ d3.compose-all.js:1303d3.selection.chart @ d3.chart.js:721(anonymous function) @ vizstats.html:20
d3.js 3.5.5 d3.chart 0.2.1 everything else pulled from links on your website.
Thanks.