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.

Missing X ticks for time series plot with gaps between data

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

image

Reproduction link

Edit on CodeSandbox

Steps to reproduce

See codesandbox example. Even trying the nebulous attributes tickInterval and tickCount you can’t get x axis tick marks to show up during the time of missing data. Huge gaps on the axis and it looks wrong and users would still like to interpolate data between collected data points, and need a timestamp (ie x axis tick).

What is expected?

Equally spaced tick marks between the first and last.

What is actually happening?

No tick marks when there are no data points

Environment Info
Recharts v1.8.5
React 16.8.6
System Ubuntu 18.04
Browser chrome

IF and ONLY IF you set domain={[‘dataMin’, ‘dataMax’]}, which you have to with a timeseries. If plot a non-time series you get the same issue but playing with tickInterval and tickCount you can get something OK, but that’s not useful in a reusable component.

const data = [
  { x: 5, y: 10 },
  { x: 8, y: 8 },
  { x: 10, y: 5 },
  { x: 12, y: 7 },
  { x: 15, y: 15 },
  { x: 40, y: 10 }
];
const SampleChart = props => {
  return (
    <LineChart width={500} height={400} data={data}>
      <XAxis
        dataKey="x"
        type="number"
        // tickInterval={0} tickCount={10}
        domain={["dataMin", "dataMax"]}
      />
      <YAxis />
      <Line dataKey="y" type="monotoneX" stroke="red" />
    </LineChart>
  );
};

Tried it with latest v2 beta and same issue.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

1reaction
vtarelkincommented, Sep 15, 2021

@ashin-krj @shibjo @ferrao @fstephany

the workaround here is to explicitly set ticks property like ticks={[195, 255,315,375,425]} but I want to calculate it automatically, not manually

1reaction
shibjocommented, May 10, 2021

Hi All, Did anyone found any workaround for this problem? I am also facing the same issue. The ticks render correctly if the domain is set to [‘auto’,‘auto’], otherwise not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to plot a time-series scatterplot showing missing y-axis ...
Essentially I would like to see the above scatterplot with gaps representing the periods without salinity data so that the date/time scale is ......
Read more >
Gallery: Times Series Missing Data Visualizations
There are multiple different plots for (univarate) time series missing data available in the imputeTS package. These can be grouped in the ......
Read more >
How to deal with missing data in line charts
Sometimes, missing values in a line chart will create a gap in the line. In this tutorial, you'll learn how to draw an...
Read more >
Query on time-series plot - tidyverse - RStudio Community
It did remove missing days but, the x-axis date is not appropriate. Please see below photo of a graph. I might did some...
Read more >
Missing dates in time series are not showing blanks in x-axis
I have gaps in the date, but want my chart to reflect the gap. ... How do I show the x-axis with missing...
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