Kozea / Kozea/pygal

X_labels_major displays corrupted values with rotation of 0

Open
#397 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
419
PR merge metrics
No merged PRs in 30d

Description

With the code below, the major axis labels display perfectly when x_label_rotation > 0. When set to zero (or the arg is removed entirely), the major x labels truncate with a symbol, even though there is loads of whitespace.

The workaround is to use `truncate_label = 6`, but I gather from the images in the pygal docs that the truncate should take effect by showing '...' rather than the symbols in the screenshot and additionally that they should only be truncated when they are 'long labels'.

I'm very limited in my python and/or programming knowledge, so apologies if it's something I'm doing wrong and it's not a bug. I'm using pygal 2.4.0 installed through pip3 and python3.6.2.

```
#!/usr/local/bin/python3
import pygal

graph = pygal.Line(x_labels_major_every=5, show_minor_x_labels=False, x_label_rotation=0)
graph.x_labels = [201510, 201511, 201512, 201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, 201610, 201611, 201612, 201701, 201702, 201703, 201704, 201705, 201706, 201707]
graph.x_labels_major = [201510, 201511, 201512, 201601, 201602, 201603, 201604, 201605, 201606, 201607, 201608, 201609, 201610, 201611, 201612, 201701, 201702, 201703, 201704, 201705, 201706, 201707]
graph.add('Data', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22])
graph.render_in_browser()
```
With rotation = 0:
![image](https://user-images.githubusercontent.com/17675453/29612302-b5f93fa2-87f8-11e7-9061-ff79d6e1632f.png)
Rotation = 1
![image](https://user-images.githubusercontent.com/17675453/29612326-c2e25de8-87f8-11e7-8693-b480b6cf828b.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the supplied Python script using pygal 2.4.0, comparing x_label_rotation=0 with rotation=1 and truncate_label=6. Trace the x-axis label rendering and truncation behavior; done means zero-rotation labels display without corrupted symbols and long-label truncation matches the documented ellipsis behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.