I'm attempting to create a stacked gauge chart using c3.js similar to the image below but cannot find any examples of this in the documentation. Is this even possible?
Asked
Active
Viewed 2,666 times
2
-
Nothing yet. I've posted here and on the official support forum but no luck. – hereswhatidid Mar 09 '15 at 01:03
1 Answers
1
The C3.js library does not seem to allow this atm, although if you try to put 2 data arrays with different ids they seem to render one on top of another - I guess it would not be hard to refactor to support that - ask author or do it yourself (source is available on github)?
I managed to achieve it with a terrible hack - but might be worth it until the library supports it.
Create 2 gauge charts, making one of the div elements move to overlap the other. At the same time, make sure the second gauge chart is slightly smaller. Then you have to decide which of the 2 labels to hide..
Here is an html snippet:
<div id="chart1"></div>
<div id="chart2" style="position: relative; top: -140px;"></div>
Here is corresponding javascript:
var chart = c3.generate({
bindto: $("#chart1")[0],
data: {
columns: [
['data', 91],
['data', 90]
],
type: 'gauge',
},
gauge: {
width: 10
},
size: {
height: 160
}
});
var chart = c3.generate({
bindto: $("#chart2")[0],
data: {
columns: [
['data', 11],
['data', 20]
],
type: 'gauge',
},
gauge: {
width: 20
},
size: {
height: 140
}
});

seb
- 808
- 1
- 9
- 17
-
Good solution. Do you know how to remove the middle percent values, they are overlapping? – andrewoodleyjr May 27 '16 at 22:59