Skip to content

Commit ce1e7a8

Browse files
authored
Fix long column names overlay (#45)
1 parent 296ff7d commit ce1e7a8

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
0.4.1 (2022-01-06)
2+
==================
3+
4+
Fixed
5+
-------
6+
- Long column names don't overlap any more (#28)
7+
8+
19
0.4.0 (2022-01-06)
210
==================
311

itables/datatables_template.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
text-overflow: ellipsis;
55
overflow: hidden;
66
} </style>
7+
<style> table th {
8+
text-overflow: ellipsis;
9+
overflow: hidden;
10+
} </style>
711
<script type="module">
812
// Load the eval_functions_js function if required
913
// eval_functions_js

itables/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""ITables' version number"""
22

3-
__version__ = "0.4.0"
3+
__version__ = "0.4.1"

tests/test_long_column_names.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
jupyter:
3+
jupytext:
4+
text_representation:
5+
extension: .md
6+
format_name: markdown
7+
format_version: '1.3'
8+
jupytext_version: 1.13.5
9+
kernelspec:
10+
display_name: itables
11+
language: python
12+
name: itables
13+
---
14+
15+
In this notebook we display a dataframe with very long column names.
16+
17+
```python
18+
import pandas as pd
19+
df = pd.DataFrame({"short name": [0] * 5,
20+
"very " * 5 + "long name": [0] * 5,
21+
"very " * 10 + "long name": [1] * 5,
22+
"very " * 20 + "long name": [2] * 5,
23+
"nospacein" + "very" * 50 + "longname": [3] * 5,
24+
"nospacein" + "very" * 100 + "longname": [3] * 5})
25+
```
26+
27+
In Pandas the long names result in a very wide HTML table, however the columns don't overlap.
28+
29+
```python
30+
df
31+
```
32+
33+
With `datatables.net` the column width are fixed and because of this the columns did overlap when the style of `table th` was not set (issue #28). Note that, with the default `display` class, long columns names made of multiple words are wrapped onto multiple lines.
34+
35+
```python
36+
from itables import init_notebook_mode, show
37+
init_notebook_mode()
38+
show(df)
39+
```

0 commit comments

Comments
 (0)