link up css with a d3.js script

27 views
Skip to first unread message

mrtn

unread,
Aug 20, 2012, 11:01:11 PM8/20/12
to d3...@googlegroups.com

I have a HTML document with HTML5 doctype: <!DOCTYPE html>, inside which I link a dedicated CSS sheet for d3.js graphs as well as a separate .js script for drawing a graph using d3.js.

e.g. something like:

<head>
    ...
    <link type="text/css" href="./graph.css" rel="stylesheet"/>
</head>
<body>
    ...
    <div class="graph">
        <script type="text/javascript" src="./graph1.js"></script>
    </div>
    ...
</body>

Both 'graph.css' and 'graph1.js' are present in the current directory. Now, if I render the HTML file without the doctype, the graph is drawn with the styles from 'graph.css'. However, as soon as I add the doctype, it fails to look up the styles from the .css file.

I wonder what is the cause for this problem and how can I fix it without moving the styles from .css back to the d3.js code inside 'graph1.js'. Thanks!

 


Reply all
Reply to author
Forward
0 new messages