Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading C3.js into an HTML file

Tags:

c3.js

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?

like image 760
William Herring Avatar asked Jul 13 '15 15:07

William Herring


People also ask

What is C3 Javascript?

This library is used to create a dynamic and interactive data visualizations. C3 is a library build on top of D3. C3 is d3 based reusable chart library and most important advantage of using c3 is that you don't have to know D3 or write those long codes!.

Is C3 JS open source?

C3. js is an open source tool with 8.45K GitHub stars and 1.41K GitHub forks.

What is C3 and D3?

js is a JavaScript library for manipulating documents based on data. c3. js is a Javascript library which makes it easy to generate D3-based charts (less code to write). highchart is a Javascript charting framework.


1 Answers

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.

like image 188
potatopeelings Avatar answered Sep 24 '22 07:09

potatopeelings