3

I'm plotting a time series chart with missing values. The generated query looks like this:

SELECT DATE_TRUNC('day', arrival_time) AS __timestamp,
       COUNT(*) AS count
FROM public.data
GROUP BY DATE_TRUNC('day', arrival_time);

When plotting a time series line chart, values are correctly positioned on the x axis according to their date value: enter image description here On the other hand, when I plot a bar chart, values are positioned by their index in the data, not by their date: enter image description here

I can solve this by using the resample function (pick 1D/asfreq), but I'm still wondering if there is a reason this works out of the box for the line chart but not for the bar chart.

Nicolas78
  • 5,124
  • 1
  • 23
  • 41

1 Answers1

0

I believe you only need to select the "Sort Bars" toggle on the customize tab. I speculate the reason why it is not sorted is that the bar chart is not time series. There is a time-series bar chart you can use instead if you don't want to toggle this button.

  • The X-values are sorted, they are just not aligned on the x axis according to their values but to their position in the ordering. – Nicolas78 Feb 07 '22 at 14:35
  • If I understand you correctly you want a gap in the chart where data doesn't exist. If so, you want to use a "time-series bar chart". Try that out and let me know if that answers your question. – Ryland Freeman Feb 08 '22 at 20:53