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.

[Bug] Multiple x axes don't display as intended with series encoding and datasets

See original GitHub issue

Version

5.4.1 and 5.4.0

Link to Minimal Reproduction

No response

Steps to Reproduce

Create a simple chart using a dataset and dimension definition, with two x-axes (for a category and sub-category).

echarts options to show this minimal reproduceable example:

{
  "dataset": {
    "dimensions": ["Category1","Category2","Val"],
    "source": [
      {
        "Category1": "a",
        "Category2": "x",
        "Val": 22
      },
      {
        "Category1": "a",
        "Category2": "y",
        "Val": 24
      },
      {
        "Category1": "a",
        "Category2": "z",
        "Val": 16
      },
            {
        "Category1": "b",
        "Category2": "x",
        "Val": 22
      },
      {
        "Category1": "b",
        "Category2": "y",
        "Val": 24
      },
      {
        "Category1": "b",
        "Category2": "z",
        "Val": 16
      }
    ]
  },
  "title": {
    "text": "Multiple x-Axis bug example"
  },
  "xAxis": [
    {
      "show": "true",
      "type": "category"
    },
    {
      "show": "true",
      "type": "category"
    }
    ],
  "yAxis": [
    {
      "type": "value",
      "name": "value",
      "min": 0,
      "max": 30
    }
  ],
  "series": [
    {
      "type": "line",
      "encode": {
        "x":[0,1],
        "y":2
      }
    }
  ]
}

Note: I can get the x-Axes stacked by using the data option of the x-Axis but the encoding still doesn’t work. I can also map the data directly to the series, but then I can’t use encoding to modify the tooltip.

Current Behavior

The values series is mapped to both x axes [0,1] but they are along-side each other, resulting in values being stacked to xAxis 0 only.

image

Expected Behavior

The xAxes should be stacked on top of each other, resulting in category and subcategory x-axis: image

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
JoeJordan1commented, Dec 15, 2022

Thank you. I have a sort of work-around at the moment, specifying the data for two x-axis, one offset, and then have to specify the data on the series, which gets me what I need using the two axes but it doesn’t use datasets, so also can’t encode to the tooltip correctly that way.

I appreciate you taking the time to create the demo showing how I can format the two columns being merged so that it displays correctly on the single x-axis. That is very useful, and I can see how that would also be useful for formatting the tooltip this way.

0reactions
helgasoftcommented, Dec 15, 2022

Dual X-axis is usually for discrete series and I do not see how it will work in your case. Your data is indeed one serie with repeating categories(SP) for each date. The only idea I can offer is to play with xAxis labels: image Demo Code

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] Multiple x axes don't display as intended with series ...
Note: I can get the x-Axes stacked by using the data option of the x-Axis but the encoding still doesn't work.
Read more >
x-limits when domain specified · Issue #316 · altair-viz/altair
In this notebook I tried out Altair with a couple datasets and had some questions. All of these are labeled as "BUG or...
Read more >
Display Data with Multiple Scales and Axes Limits - MathWorks
Learn about techniques for visualizing data with multiple x- and y-axes, multiple colorbars, or with an x-axis that is broken into intervals.
Read more >
Label encoding across multiple columns in scikit-learn
As the dataframe has many (50+) columns, I want to avoid creating a LabelEncoder object for each column; I'd rather just have one...
Read more >
15 Questions All R Users Have About Plots - DataCamp
To practice creating plots in R, try this course on data visualization in R. The 15 Questions. How to Draw an Empty R...
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