Skip to content

Instantly share code, notes, and snippets.

@ppKrauss
Created July 5, 2019 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppKrauss/4d0d018fec79c0b5ac7769ea8b62724b to your computer and use it in GitHub Desktop.
Save ppKrauss/4d0d018fec79c0b5ac7769ea8b62724b to your computer and use it in GitHub Desktop.
Simple chart with C3 - in 5 minutes! // source https://jsbin.com/seriyih
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple chart with C3 - in 5 minutes! </title>
<!-- Here are all the javascripts and css that you need, you can download them or linked them like here -->
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/d3/5.9.7/d3.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/c3/0.7.1/c3.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/c3/0.7.1/c3.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- You need an element with an id called "chart" to set a place where your chart will render-->
<div id="chart"></div>
<script id="jsbin-javascript">
var chart = c3.generate({
size: { height: 240, width: 460 },
data: {
columns: [
['sample1', 30, 200, 100, 422, 150, 250],
['sample2', 430, 300, 500, 388, 650, 250]
],
type: 'bar',
colors: {
sample1: '#01B8AA',
sample2: '#FF9955',
},
labels: { format: d3.format(".3") },
groups: [ ['sample1', 'sample2'] ]
},
axis: {
x: {
label: {
text: 'X Label',
position: 'outer-center'
}
},
y: {
label: {
text: 'Y Label',
position: 'outer-top'
}
}
}
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple chart with C3 - in 5 minutes! </title>
<\!-- Here are all the javascripts and css that you need, you can download them or linked them like here -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/d3/5.9.7/d3.min.js"><\/script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/c3/0.7.1/c3.js"><\/script>
<link href="//cdnjs.cloudflare.com/ajax/libs/c3/0.7.1/c3.css" rel="stylesheet" type="text/css">
</head>
<body>
<\!-- You need an element with an id called "chart" to set a place where your chart will render-->
<div id="chart"></div>
</body>
</html>
</script>
<script id="jsbin-source-javascript" type="text/javascript">
var chart = c3.generate({
size: { height: 240, width: 460 },
data: {
columns: [
['sample1', 30, 200, 100, 422, 150, 250],
['sample2', 430, 300, 500, 388, 650, 250]
],
type: 'bar',
colors: {
sample1: '#01B8AA',
sample2: '#FF9955',
},
labels: { format: d3.format(".3") },
groups: [ ['sample1', 'sample2'] ]
},
axis: {
x: {
label: {
text: 'X Label',
position: 'outer-center'
}
},
y: {
label: {
text: 'Y Label',
position: 'outer-top'
}
}
}
});
</script></body>
</html>
var chart = c3.generate({
size: { height: 240, width: 460 },
data: {
columns: [
['sample1', 30, 200, 100, 422, 150, 250],
['sample2', 430, 300, 500, 388, 650, 250]
],
type: 'bar',
colors: {
sample1: '#01B8AA',
sample2: '#FF9955',
},
labels: { format: d3.format(".3") },
groups: [ ['sample1', 'sample2'] ]
},
axis: {
x: {
label: {
text: 'X Label',
position: 'outer-center'
}
},
y: {
label: {
text: 'Y Label',
position: 'outer-top'
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment