question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autorotate x axis tick texts on types "category" and "timeseries"

See original GitHub issue

Description

I would like to have an option for autorotating x axis tick texts on type “category” if there isn’t enough space to fit them between 2 ticks. Main reason for autorotating x axis tick texts is saving unused space in the chart.

It should autorotate if:

  1. axis_x_tick_multiline === false
  2. axis_x_tick_autorotate === true
  3. axis_x_tick_rotate !== 0
  4. longest text width > space between 2 ticks
  5. Check 1-4 on resize/redraw

It also improves the appereance of the x axis if:

  • the texts are too long and there is less space between 2 ticks or
  • there are many elements on x axis

Examples:

  1. There is enough space so the texts aren’t rotated: 1  not rotated

  2. There is not enough space so the texts are rotated: 2  rotated

  3. There is not enough space for 1 text so all texts are rotated: 3  rotated long prefix

  4. There are many elements on x axis: 4  many elements

Would this feature be useful enough to implement it in billboard or perhaps as a plugin? If needed, this feature could be expanded and implemented for other axis types in the future.

What do you think about it?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
netilcommented, Mar 20, 2020

🎉 This issue has been resolved in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

1reaction
michkamicommented, Feb 14, 2020

I worked on this issue in the last few days. As the code changes are not minimal and autorotating could be used frequently, I implemented it in the core.

  1. X axis tick texts can now be rotated automatically if “axis_x_tick_autorotate = true”. (only for type category)
  2. If the rotation is set 0 < and < 90 there is a new function for calculating y2 axis overflow length of rotated x axis tick texts. (only for type category)

autorotate without y2 axis shown autorotateWithoutY2

autorotate with y2 axis shown autorotateWithY2

  1. Following is not the part of the issue, but it were just 3 lines of code:

resizeXAxisWithY2 It resizes the x axis height if you hide all elements in the chart, which looks better instead of displaying empty space. This change also works for all three x axis types.

Autorotating works only if:

  • axis_x_tick_multiline is set false
  • axis_x_tick_culling is set false (because some issues with calculating the y2 axis overflow when texts are hidden)
  • axis_x_type is set category

Y2 axis overflow will be calculated if:

  • axis_x_tick_multiline is set false
  • axis_x_tick_culling is set false
  • axis_x_type is set category
  • axis_x_tick_rotate is set 0 < value < 90

If you are ok with this changes, I can make a pull request for all of them. If there is something to clarify beforehand, we can do it before or within the pull request.

PS: As of some internet problems during writing this comment, I somehow closed and reopened the post, don’t ask me how 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to rotate x-axis tick labels in a pandas plot - Stack Overflow
Pass param rot=0 to rotate the xticklabels: import matplotlib matplotlib.style.use('ggplot') import matplotlib.pyplot as plt import pandas as pd df = pd.
Read more >
xAxis.labels.rotation | highcharts API Reference
The axis labels show the number or category for each tick. ... When each category width is more than this many pixels, we...
Read more >
GGPlot Axis Ticks: Set and Rotate Text Labels - Datanovia
This article describes how to easily set ggplot axis ticks for both x and y axes. We'll also explain how to rotate axis...
Read more >
Options - Documentation - UNPKG
The number of x axis ticks to show. This option hides tick lines together with tick text. If this option is used on...
Read more >
Format Category (X) Axis Dialog Box - Logi Analytics
Axis Tab; Tick Mark Tab; Font Tab; Orientation Tab; Format Tab; Range Tab; Behaviors Tab. You see these buttons in the tabs: OK....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found