Uncaught SyntaxError: Unexpected token =
I just switched from using a local copy of the minified version of d3.v3 to the development version. It worked fine when using the minified version, but using my local copy of http://d3js.org/d3.v3.js gives me the error in the title, referencing this line:
var € = Math.PI, µ = 1e-6, d3_radians = € / 180, d3_degrees = 180 / €;
When I include the hosted file, it works fine.
The problem is that you are serving D3 with the ISO-8859-1 character encoding (often the browser default), whereas D3 must be served with UTF-8 encoding. Typically this happens because you are missing a meta tag at the top of the loading HTML page:
<!DOCTYPE html>
<meta charset="utf-8">
The meta-specified charset is required because d3js.org is served by GitHub Pages and does not specify a charset in the Content-Type response header. The charset is therefore inferred from the loading HTML document.
If you prefer, you can specify a charset attribute on the script tag. Make sure you clear your browser cache before testing, as the cached copy will retain the character encoding from when it was originally accessed:
<script src="http://d3js.org/d3.v3.js" charset="utf-8"></script>
The error does not occur with the minified version because the variable names are replaced with ASCII equivalents. (I don't recall offhand if UTF-8 characters in format strings are likewise replaced with escape sequences, but I still recommend serving D3 as UTF-8 in all cases.)
Encoding problems can also happen if you downloaded D3 by viewing the source in your browser and then using copy-paste, which is why I recommend downloading d3.v3.zip.
it is definitely an encoding issue, try to focus on that.
Opening with Chrome the link you posted (http://d3js.org/d3.v3.js) i see that double-byte characters too:
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
if you barely save the file with "save page as..." and you open it with an editor like Sublime Text (http://www.sublimetext.com/) it works fine and it shows:
var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
i tried to use this downloaded file with a projects of mine and it's all right.
链接地址: http://www.djcxy.com/p/46038.html