two sets of data, sumData and subData, are stacked together through groups. The original effect is:
on a record, sumData is 10, subdata is 5, but the total height of the bar chart is 15, and the demand is that the total height is 10, in other words, as shown in the figure:
so my problem is how to obtain the value of the corresponding index data2 when modifying the value of data1 in label or tooltip.
questions such as comments on label and tooltip in the code
var chart = c3.generate({
data: {
columns: [
["data1", 100, 100, 100, 100, 100, 100],
["data2", 200, 200, 200, 200, 200, 200],
],
groups: [
["data1", "data2"]
],
type: "bar",
labels: {
// format: function (v, id, i, j) { return "Default Format"; },
format: {
data2: function (value, id, index, j) {
return value+3; //data2value
},
}
}
},
tooltip:{
format: {
title: function (d) { return "Data " + d; },
value: function (value, ratio, id) {
var format = id === "data1" ? d3.format(",") : d3.format("$");
return format(value);
}//id
// value: d3.format(",") // apply this format to both y and y2
}
}
});