chartjs / chartjs/Chart.js

Tick rotation/autoSkip calculations assume full space is used

Open
#9,614 3 comments 3 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

## Expected Behavior
Tick/Label size and space calculations should take into account where the labels start/stop, and use that information to calculate a more approximate measure of label space.

## Current Behavior
Tick calculations assume they start and stop at the full size of the axis, which is not always the case.

This is most obvious in small usecases - both small sizes and small number of labels - as these are the cases where the disparity between "real" and calculated tick space, sizes and distances is greatest.
A good example is time scales using "week" as the unit, where the days may not match the points where the weeks start exactly, so a relatively large empty (tickless) space can exist st the edges of the chart.

## Possible Solution
The scale's `getPixelForValue` will likely need to be used in the `calculateLabelRotation`/`autoSkip` functions, but I didn't do enough research yet to determine all possible implications of this.

## Steps to Reproduce
Live example: https://codepen.io/tiagoroldao/pen/mdwEMoG

![Screenshot 2021-09-03 at 10 24 47](https://user-images.githubusercontent.com/1634026/131977692-fdbefee8-ebb7-41f8-82ff-3baee8cbc8a7.png)

## Context
This was detected while using chartJS to create small widgets on a dashboard. These are often small charts with time data (i.e. "last 30 days") where this is a common

## Environment
* Chart.js version: 3.5.1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.