plotly / plotly/plotly.js

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

未关闭
#7,031 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature P3
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先复现提供的 bar-chart 示例,并检查在混合看起来像数字的字符串和非数字字符串时如何推断 x-axis 类型。完成的标准是,五个不同的 x 值不会被自动的文本到数字转换悄悄合并:要么明确失败,要么保留数据,而不要求显式的 category 选项。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。