Open kornpow opened 10 years ago
The output of d3.max, unlike in jsFiddle, is not the max? Any ideas of a cause of this madness?
You can't just copy over the JavaScript directly from JSFiddle. You need to create an actual structured html document, include d3.js as a scripting source, and then put all of your actual JavaScript inside of a custom script like this:
<script type='text/javascript'>
<!-- your js code here -->
</script>
I am aware of this, everything is in a nice structured document, with script and style tags and whatnot. The code just is not working as it should. Look at the picture above, it is saying the max is 8936 instead of 22527.
Its in an external js file, but that is included in the main html doc.
If its unkosher to have these images, let me know please. I think the real challenge shouldnt be putting it into a file like this, so I am guessing I have screwed something up somewhere.
I hardly know anything about JS/HTML/CSS so I can't help debug your issue, but the following structure worked for me when moving from JSFiddle to a single .html file.
<!DOCTYPE html>
<html>
<head>
//Scripting source?
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
//The following line was in the html box of my JSFiddle
<svg class="chart"></svg>
<style>
//My CSS code
</style>
<script>
//My Javascript code
</script>
</html>
I got it to work using the CDN pointed to by this weeks tutorial, as suggested,
. I'd recommend not using external js or css because that is what gave me these issues. Oh well there's like 3-4 hours down the drain.@sako0938
Sounds like you are sorting the values as strings instead of numbers.
Try d3.max(data, function(d) { return +d.population })
instead, the + sign converts any string to a number.
Anyone else having a lot of issues doing the very first checkpoint? My code worked for week one, but an exact copy of it does not work for the HTML document. After some modifications I got it to display, but incorrectly. I do not know where to go from here besides continuing to mess with the code until I can find out whats wrong.