Created
July 5, 2019 19:52
-
-
Save ppKrauss/8c9cfe4141b1f019d73e51d47da0d010 to your computer and use it in GitHub Desktop.
Simple chart with C3 - in 5 minutes! // source https://jsbin.com/seriyih
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="showing C3js bug"> | |
<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: 600 }, | |
data: { | |
type: 'bar', | |
x: 'x', | |
columns: [ | |
["x","2019-02-01","2018-10-01","2018-02-01","2018-08-01","2018-09-01","2018-01-01","2017-11-01","2018-12-01","2018-05-01","2018-03-01","2018-06-01","2018-07-01","2018-11-01","2017-12-01","2018-04-01","2017-10-01","2019-06-01","2019-04-01","2019-05-01","2019-01-01","2019-03-01"], | |
["Ok",98.87,99.35,65.50,96.65,99.96,62.56,63.81,99.94,75.87,71.66,82.17,84.10,97.46,64.44,75.06,63.96,99.99,99.41,99.53,99.94,99.12], | |
["Dup",1.12,0.64,34.49,3.34,0.03,37.43,36.18,0.05,24.12,28.33,17.82,15.89,2.53,35.55,24.93,36.03,0.00,0.58,0.46,0.05,0.87], | |
["avg2017",null,null,null,null,null,null,36,null,null,null,null,null,null,36,null,36,null,null,null,null,null], | |
["avg2018",null,16,16,16,16,16,null,16,16,16,16,16,16,null,16,null,null,null,null,null,null], | |
["avg2019",1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,1,1] | |
], | |
colors: { | |
sample1: '#01B8AA', | |
sample2: '#FF9955', | |
}, | |
groups: [ ['Ok', 'Dup'] ], | |
types: { | |
avg2017: 'line', | |
avg2018: 'line', | |
avg2019: 'line' | |
}, | |
colors: { | |
volMes: '#01B8AA', | |
avg2017: '#446655', | |
avg2018: '#66990E', | |
avg2019: '#558866' | |
}, | |
labels: { | |
format: (v, id)=> ( (String(id).substring(0,3)=='avg')? d3.format(".3")(v): null ) | |
} | |
}, // \data | |
bar: { width: { ratio: 0.6 } }, | |
axis: { | |
x: { | |
label: 'Month', | |
position: 'outer-center', | |
type: 'timeseries', | |
tick: { | |
format: '%b/%y', // %Y-%m-%d | |
rotate: 32 | |
} | |
}, | |
y: { | |
label: '% of Duplicated Records', | |
position: 'outer-top', | |
tick: { format: d=> (parseInt(d*10)/10)+"%" } | |
} | |
} // \axis | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="showing C3js bug"> | |
<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: 600 }, | |
data: { | |
type: 'bar', | |
x: 'x', | |
columns: [ | |
["x","2019-02-01","2018-10-01","2018-02-01","2018-08-01","2018-09-01","2018-01-01","2017-11-01","2018-12-01","2018-05-01","2018-03-01","2018-06-01","2018-07-01","2018-11-01","2017-12-01","2018-04-01","2017-10-01","2019-06-01","2019-04-01","2019-05-01","2019-01-01","2019-03-01"], | |
["Ok",98.87,99.35,65.50,96.65,99.96,62.56,63.81,99.94,75.87,71.66,82.17,84.10,97.46,64.44,75.06,63.96,99.99,99.41,99.53,99.94,99.12], | |
["Dup",1.12,0.64,34.49,3.34,0.03,37.43,36.18,0.05,24.12,28.33,17.82,15.89,2.53,35.55,24.93,36.03,0.00,0.58,0.46,0.05,0.87], | |
["avg2017",null,null,null,null,null,null,36,null,null,null,null,null,null,36,null,36,null,null,null,null,null], | |
["avg2018",null,16,16,16,16,16,null,16,16,16,16,16,16,null,16,null,null,null,null,null,null], | |
["avg2019",1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,1,1] | |
], | |
colors: { | |
sample1: '#01B8AA', | |
sample2: '#FF9955', | |
}, | |
groups: [ ['Ok', 'Dup'] ], | |
types: { | |
avg2017: 'line', | |
avg2018: 'line', | |
avg2019: 'line' | |
}, | |
colors: { | |
volMes: '#01B8AA', | |
avg2017: '#446655', | |
avg2018: '#66990E', | |
avg2019: '#558866' | |
}, | |
labels: { | |
format: (v, id)=> ( (String(id).substring(0,3)=='avg')? d3.format(".3")(v): null ) | |
} | |
}, // \data | |
bar: { width: { ratio: 0.6 } }, | |
axis: { | |
x: { | |
label: 'Month', | |
position: 'outer-center', | |
type: 'timeseries', | |
tick: { | |
format: '%b/%y', // %Y-%m-%d | |
rotate: 32 | |
} | |
}, | |
y: { | |
label: '% of Duplicated Records', | |
position: 'outer-top', | |
tick: { format: d=> (parseInt(d*10)/10)+"%" } | |
} | |
} // \axis | |
}); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chart = c3.generate({ | |
size: { height: 240, width: 600 }, | |
data: { | |
type: 'bar', | |
x: 'x', | |
columns: [ | |
["x","2019-02-01","2018-10-01","2018-02-01","2018-08-01","2018-09-01","2018-01-01","2017-11-01","2018-12-01","2018-05-01","2018-03-01","2018-06-01","2018-07-01","2018-11-01","2017-12-01","2018-04-01","2017-10-01","2019-06-01","2019-04-01","2019-05-01","2019-01-01","2019-03-01"], | |
["Ok",98.87,99.35,65.50,96.65,99.96,62.56,63.81,99.94,75.87,71.66,82.17,84.10,97.46,64.44,75.06,63.96,99.99,99.41,99.53,99.94,99.12], | |
["Dup",1.12,0.64,34.49,3.34,0.03,37.43,36.18,0.05,24.12,28.33,17.82,15.89,2.53,35.55,24.93,36.03,0.00,0.58,0.46,0.05,0.87], | |
["avg2017",null,null,null,null,null,null,36,null,null,null,null,null,null,36,null,36,null,null,null,null,null], | |
["avg2018",null,16,16,16,16,16,null,16,16,16,16,16,16,null,16,null,null,null,null,null,null], | |
["avg2019",1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,1,1,1,1] | |
], | |
colors: { | |
sample1: '#01B8AA', | |
sample2: '#FF9955', | |
}, | |
groups: [ ['Ok', 'Dup'] ], | |
types: { | |
avg2017: 'line', | |
avg2018: 'line', | |
avg2019: 'line' | |
}, | |
colors: { | |
volMes: '#01B8AA', | |
avg2017: '#446655', | |
avg2018: '#66990E', | |
avg2019: '#558866' | |
}, | |
labels: { | |
format: (v, id)=> ( (String(id).substring(0,3)=='avg')? d3.format(".3")(v): null ) | |
} | |
}, // \data | |
bar: { width: { ratio: 0.6 } }, | |
axis: { | |
x: { | |
label: 'Month', | |
position: 'outer-center', | |
type: 'timeseries', | |
tick: { | |
format: '%b/%y', // %Y-%m-%d | |
rotate: 32 | |
} | |
}, | |
y: { | |
label: '% of Duplicated Records', | |
position: 'outer-top', | |
tick: { format: d=> (parseInt(d*10)/10)+"%" } | |
} | |
} // \axis | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment