你試過嗎?這是一條帶有垂直條形圖的水平線 - 與您的情況相反。但是,也許你可以從中獲得一些有用的東西出來吧:
var chart = c3.generate({
bindto: '#chartContainer',
tooltip: {
grouped: false
},
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 130, 340, 200, 500, 250, 350],
['data3', 30, 200, 100, 400, 150, 250],
['data4', 130, 340, 200, 500, 250, 350],
['data5', 130, 340, 200, 500, 250, 350],
['data6', 130, 340, 200, 500, 250, 350],
['data7', 130, 340, 200, 500, 250, 350],
['diif1', null, null, 700 ],
['diif2', null, null, 1200]
],
types:{
"data1" :"bar",
"data2" :"bar",
"data3" :"bar",
"data4" :"bar",
"data5" :"bar",
"data6" :"bar",
"data7" :"bar",
"diff1" : "line",
"diff2" : "line"
},
order:null,
groups: [
['data1', 'data2','data3', 'data4'],
['data5', 'data6','data7']
],
onclick: function (d, element) {
var name=d.name;
drilldown(name);
}
},
grid: {
y: {
lines:[{value:1400,text:1400},
{value: 1450,text: 1450}
]
}
}
});
function drilldown(name){
alert('Call for ' +name);
}
http://jsfiddle.net/9nxcfzb9/12/
我在尋找類似的給你,但不與水平條形圖的東西,但時間跨度吧,如果你有一個想法,請讓我知道: How do I change or add the vertical line on a tooltip of a c3 graph?
這正是我一直在尋找。 –