c3js / c3js/c3

x axis labels are stacking letters in tspans

Open
#2,120 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

Legend is at the right. Labels are simple JAN, FEB, MAR, ... But the x axis labels are stacked as three tspan's that each have one letter?!

![image](https://user-images.githubusercontent.com/3846466/28593813-63466bc4-7153-11e7-8e1c-53ee04d73043.png)


J
A
N

In CSS I'm changing the font size/family/color of the tick labels. But generation of tspan has to be coming from the library.

Chart config:

const categories: string[] = (this.parentNativeElement.offsetWidth < 555) ?
['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'] :
['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];

const chart = c3.generate({
bindto: this.chart.nativeElement,
data: {
columns: [
['MARKETPLACE AVERAGE', ...this.spendData.marketAverage],
['YOUR HISTORICAL DATA', ...this.spendData.historicalSpend],
['YOUR SPEND', ...this.spendData.currentSpend]
]
},
legend: {
position: 'right'
},
color: {
// gray, yellow, green
pattern: ['#EEEEEE', '#C8E586', '#ABC278']
},
axis: {
x: {
type: 'category',
categories: categories,
tick: {
fit: true,
outer: false
}
},
y: {
tick: {
format: (d) => {
return parseInt(d, 10) + '%';
},
outer: false
}
}
},
grid: {
y: {
show: true
}
}
});

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.