plotly / plotly/plotly.js

Duplicate Keys on X-Axis with Date Format and formatTick

Open
#7,041 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

When plotting a chart using Plotly with a small dataset and specifying the x-axis type as date, along with a custom formatTick function, the x-axis displays duplicate keys. This issue creates a confusing and cluttered appearance, as shown in the example provided below.

Steps to Reproduce:

Create a chart with the x-axis type set to date.
Use a small dataset with date values.
Specify a custom formatTick function for the x-axis.
Example:

You can see the issue in the following CodePen example:
CodePen Example

Expected Behavior:

The x-axis should display unique date values without any duplicates, even for small datasets, ensuring a clean and accurate representation of the data.

Actual Behavior:

The x-axis shows duplicate date values, leading to a misleading visualization.

Environment:

Plotly.js version: plotly.js-dist-min@2.32.0
Browser: chrome
Operating System: windows

This issue significantly impacts the readability of charts, especially when dealing with smaller datasets where clear and distinct x-axis labels are crucial.

Additional information:
by specifying type as category or explicitly specilfying tickvals and ticktext doesn't suit well for large dataset.
Screenshot

Screenshot 2024-07-02 210025

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked CodePen example with Plotly.js 2.32.0 and compare the date-axis labels with and without the custom formatTick function. Trace the date-axis tick generation and formatting behavior responsible for repeated labels. Done means small date datasets render unique, readable x-axis labels without requiring category axes or explicit tickvals and ticktext.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.