Loading C3.js into an HTML file
Asked Answered
C

1

8

I am having alot of trouble getting c3 to work in my web page. My code for the graphing is right, it just wont load anything and I am guessing this is due to me not having the right script src. Does anyone have a starter file for using c3, or the code I would need to load it in. Or is there a CDN I could reference?

Compulsive answered 13/7, 2015 at 15:29 Comment(0)
P
15

Here is a quick starter file

<!DOCTYPE html>
<html lang="en">
<head>
    <title>C3</title>
    <meta charset="utf-8" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js"></script>
</head>
<body>
    <div id="chart"></div>
    <script>
        var chart = c3.generate({
            data: {
                columns: [
                    ['data1', 30, 200, 100, 400, 150, 250],
                    ['data2', 50, 20, 10, 40, 15, 25]
                ]
            }
        });
    </script>
</body>
</html>

But I would recommend, getting stable versions from the respective sites or GitHub projects.

Pyoid answered 14/7, 2015 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.