I am new to C3.js and I am having some difficult with the design of the chart. My goal is to display the label of all the categories (A1 to A30) in the x-axis, but right now it only shows the first element (A1) as you can see here. Note: the axis are rotated.
My code is this:
var chart = c3.generate({
bindto: '#chart',
size: {
height: 400,
width: 700,
},
data: {
x: 'x',
columns:
[['x', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14', 'A15', 'A16', 'A17', 'A18', 'A19', 'A20', 'A21', 'A22', 'A23', 'A24', 'A25', 'A26', 'A27', 'A28', 'A29', 'A30'], ['A1', 56], ['A2', 52], ['A3', 37], ['A4', 34], ['A5', 34], ['A6', 33], ['A7', 32], ['A8', 30], ['A9', 29], ['A10', 29], ['A11', 28], ['A12', 13], ['A13', 11], ['A14', 10], ['A15', 10], ['A16', 9], ['A17', 8], ['A18', 8], ['A19', 8], ['A20', 8], ['A21', 7], ['A22', 6], ['A23', 5], ['A24', 4], ['A25', 4], ['A26', 3], ['A27', 2], ['A28', 1], ['A29', 1], ['A30', 1]],
type: 'bar',
},
axis: {
rotated: true,
x: {
type: 'category',
categories: ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A11', 'A12', 'A13', 'A14', 'A15', 'A16', 'A17', 'A18', 'A19', 'A20', 'A21', 'A22', 'A23', 'A24', 'A25', 'A26', 'A27', 'A28', 'A29', 'A30']
},
},
bar: {
width: {
max: 40,
radio: 0.8
}
},
tooltip: {
grouped: false
}
});
/*-- Chart --*/
.c3 svg {
font: 10px "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.c3 path, .c3 line {
fill: none;
stroke: #EEEEEE;
}
/*tooltip*/
#chart .c3-tooltip th {
font-family: "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
font-weight: bold;
color: #fff;
background-color: #000;
}
#chart .c3-tooltip td {
font-family: "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
font-weight: bold;
font-size: 12px;
color: #000;
}
/*tooltip*/
.c3 .c3-axis-x line {
stroke: transparent;
fill: none;
}
g .tick {
opacity: 0;
}
.c3 text {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
font: 12px "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
}
.c3-legend-item-tile,
.c3-xgrid-focus,
.c3-ygrid,
.c3-event-rect,
.c3-bars path {
shape-rendering: crispEdges;
}
.c3-chart-arc path {
stroke: #fff;
}
.c3-chart-arc rect {
stroke: white;
stroke-width: 1;
}
.c3-chart-arc text {
fill: #fff;
font-size: 13px;
}
/*-- Axis --*/
/*-- Grid --*/
.c3-grid line {
stroke: #aaa;
}
.c3-grid text {
fill: #aaa;
}
.c3-xgrid, .c3-ygrid {
stroke-dasharray: 3 3;
}
/*-- Text on Chart --*/
.c3-text.c3-empty {
fill: #808080;
font-size: 2em;
}
/*-- Line --*/
.c3-line {
stroke-width: 1px;
}
/*-- Point --*/
.c3-circle {
fill: transparent;
}
.c3-circle._expanded_ {
stroke-width: 3px;
stroke: white;
}
.c3-selected-circle {
fill: white;
stroke-width: 2px;
}
/*-- Bar --*/
.c3-bar {
stroke-width: 0;
}
.c3-bar._expanded_ {
fill-opacity: 1;
fill-opacity: 0.75;
}
/*-- Focus --*/
.c3-target.c3-focused {
opacity: 1;
}
.c3-target.c3-focused path.c3-line, .c3-target.c3-focused path.c3-step {
stroke-width: 2px;
}
.c3-target.c3-defocused {
opacity: 0.3 !important;
}
/*-- Region --*/
.c3-region {
fill: steelblue;
fill-opacity: 0.1;
}
.c3-region text {
fill-opacity: 1;
}
/*-- Brush --*/
.c3-brush .extent {
fill-opacity: 0.1;
}
/*-- Select - Drag --*/
/*-- Legend --*/
.c3-legend-item {
font: 14px "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
}
tspan {
font-size: 14px;
font-weight: bold;
font-family: "Gotham Rounded SSm A", "Gotham Rounded SSm B", sans-serif;
}
.c3-legend-item-hidden {
opacity: 0.15;
}
.c3-legend-background {
opacity: 0.75;
fill: #fff;
stroke: lightgray;
stroke-width: 1;
}
/*-- Title --*/
.c3-title {
font: 14px sans-serif;
}
/*-- Tooltip --*/
.c3-tooltip-container {
z-index: 10;
}
.c3-tooltip {
border-collapse: collapse;
border-spacing: 0;
background-color: #fff;
empty-cells: show;
-webkit-box-shadow: 7px 7px 12px -9px #777777;
-moz-box-shadow: 7px 7px 12px -9px #777777;
box-shadow: 7px 7px 12px -9px #777777;
opacity: 0.9;
}
.c3-tooltip tr {
border: 1px solid #CCC;
}
.c3-tooltip th {
background-color: #aaa;
font-size: 14px;
padding: 2px 5px;
text-align: left;
color: #FFF;
}
.c3-tooltip td {
font-size: 13px;
padding: 3px 6px;
background-color: #fff;
border-left: 1px dotted #999;
}
.c3-tooltip td > span {
display: inline-block;
width: 10px;
height: 10px;
margin-right: 6px;
}
.c3-tooltip .value {
text-align: right;
}
/*-- Area --*/
.c3-area {
stroke-width: 0;
opacity: 0.2;
}
/*-- Arc --*/
.c3-chart-arcs-title {
dominant-baseline: middle;
font-size: 1.3em;
}
.c3-chart-arcs .c3-chart-arcs-background {
fill: #e0e0e0;
stroke: #FFF;
}
.c3-chart-arcs .c3-chart-arcs-gauge-unit {
fill: #000;
font-size: 16px;
}
.c3-chart-arcs .c3-chart-arcs-gauge-max {
fill: #777;
}
.c3-chart-arcs .c3-chart-arcs-gauge-min {
fill: #777;
}
.c3-chart-arc .c3-gauge-value {
fill: #000;
/* font-size: 28px !important;*/
}
.c3-chart-arc.c3-target g path {
opacity: 1;
}
.c3-chart-arc.c3-target.c3-focused g path {
opacity: 1;
}
/*-- Zoom --*/
.c3-drag-zoom.enabled {
pointer-events: all !important;
visibility: visible;
}
.c3-drag-zoom.disabled {
pointer-events: none !important;
visibility: hidden;
}
.c3-drag-zoom .extent {
fill-opacity: 0.1;
}
#chart,
svg {
width: 750;
height: 515;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="chart"></div>
<!-- Load d3.js and c3.js -->
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://central-de-pesquisa-2022.s3.amazonaws.com/c3.min.js"></script>
</body>
</html>