plotly / plotly/plotly.js

change auto conversion of text to number on x axis (current is misleading)

Open
#7,031 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I found this somewhat related issue (it's about dates).

When I pass the following data with 5 rows. I get a visualization with 2 bars.

{
  "data": [
    {
      "alignmentgroup": "True",
      "hovertemplate": "Line Code=%{x}<br>Score=%{y}<extra></extra>",
      "legendgroup": "",
      "marker": {
        "color": "#eb7a2e",
        "pattern": {
          "shape": ""
        }
      },
      "name": "",
      "offsetgroup": "",
      "orientation": "v",
      "showlegend": false,
      "textposition": "auto",
      "x": [
        "1710",
        "700",
        "N1700",
        "N1710",
        "N700"
      ],
      "xaxis": "x",
      "y": [
        -77.308,
        8.893,
        -24.069,
        -60.96,
        -9.385
      ],
      "yaxis": "y",
      "type": "bar"
    }
  ],
  "layout": {
    "barmode": "relative",
    "legend": {
      "tracegroupgap": 0
    },
    "title": {
      "text": "Scores per Line"
    },
    "xaxis": {
      "anchor": "y",
      "domain": [
        0,
        1
      ],
      "title": {
        "text": "Line Code"
      }
    },
    "yaxis": {
      "anchor": "x",
      "domain": [
        0,
        1
      ],
      "rangemode": "tozero",
      "title": {
        "text": "Score"
      }
    },
    "template": {
      "layout": {
        "colorway": [
          "#eb7a2e",
          "#f7b62a",
          "#1fa5de",
          "#57bebe",
          "#7f7977",
          "#b1a898",
          "#5e4a86",
          "#8e80b9",
          "#4a4c51",
          "#8a8b94"
        ],
        "font": {
          "color": "#212121",
          "family": "Inter, sans-serif",
          "size": 12
        },
        "hovermode": "closest",
        "margin": {
          "b": 70,
          "l": 70,
          "r": 70,
          "t": 80
        },
        "paper_bgcolor": "#FFFFFF",
        "plot_bgcolor": "#FFFFFF",
        "title": {
          "font": {
            "size": 18
          },
          "x": 0.02,
          "xanchor": "left",
          "y": 0.93
        },
        "xaxis": {
          "automargin": true,
          "gridcolor": "#f2f2f2",
          "linecolor": "#d9d9d9",
          "showgrid": false,
          "zeroline": true,
          "zerolinecolor": "#d9d9d9"
        },
        "yaxis": {
          "automargin": true,
          "gridcolor": "#f2f2f2",
          "linecolor": "#d9d9d9",
          "showgrid": true,
          "zeroline": true,
          "zerolinecolor": "#d9d9d9"
        },
        "yaxis2": {
          "showgrid": false
        }
      }
    }
  }
}

grafik

I understand that I can pass an option for the category, but I would rather:

  • have it fail, because it can't display all data
  • not do the conversion by default

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 reproducing the supplied bar-chart example and inspect how the x-axis type is inferred when numeric-looking and nonnumeric strings are mixed. Done should mean the five distinct x values are not silently collapsed by automatic text-to-number conversion, either by failing clearly or preserving the data without requiring an explicit category option.

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.