Bar charts with "Category" x-axis are randomly spaced

I am trying to use a “Chart” type visualization for my data. The x-axis data is categorical and y-axis is “linear”. The plot looks appropriate, only the spacing between the bar is random.

Please see the example below:

I use a dashboard level filter for all the visualizations. The x-axis is “Analysis ID” for all except the “Power Draw Profile”. The spacing between bars is different within the same visualization “Vehicles in Simulation”, and the spacing is different between visualizations “Stranded EVs Count”. Any ideas why this is happening? And how can I resolve this?

I am using Redash self-hosted, on an Ubuntu EC2 instance.


Change your X-axis from a number type to a category-type. The bars aren’t evenly spaced because the Analysis IDs are not evenly spaced along a number line.

@k4s1m I am using a scale of “Category” on the x-axis as can be seen from the image below:

Further, my query with query parameters is below:

SELECT ef.analysis_id,
FROM ev_finished ef
  (SELECT analysis_id,
   FROM analysis_record
   WHERE date_trunc('seconds', sim_date_time) IN ({{ sim_date_time }})) AS ar ON ef.analysis_id = ar.analysis_id
GROUP BY ef.analysis_id,

The analysis ids in the graph are 113, 114, and 115. So even if they were treated as numbers, or on a linear axis, then they shud be equidistant.

Let me know if I am missing something.


This is what happens when I choose a “Linear” scale for x-axis

While they are equidistant in this case, they may not be when the analysis ids are not contiguous. Further, I do not like fractional numbers like 113.5 on x-axis. That is why I choose a “Category” which is how it should be.

It’s because of your grouping by timestamp (sim_date_time). It’s leaving three places on the x-axis for each Analysis ID for the three timestamps, so a red, green and blue bar per analysis ID. If you make it a stacked barchart it should be fine. Or don’t group by timestamp, but then you lose your colour bars.

1 Like

@ibmc That worked perfectly. While I was just seeing three rows in the query table, stacking produced the desired result.

1 Like