Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
73
rated 0 times [  74] [ 1]  / answers: 1 / hits: 16073  / 12 Years ago, sat, december 29, 2012, 12:00:00

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.


More From » d3.js

 Answers
14

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.


[#81176] Thursday, December 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
patienceannel

Total Points: 674
Total Questions: 101
Total Answers: 101

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
patienceannel questions
Fri, Mar 11, 22, 00:00, 2 Years ago
Tue, Oct 20, 20, 00:00, 4 Years ago
Wed, Jul 24, 19, 00:00, 5 Years ago
;