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.
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.
SELECT ef.analysis_id,
count(veh_id),
ar.sim_date_time
FROM ev_finished ef
JOIN
(SELECT analysis_id,
sim_date_time
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,
ar.sim_date_time;
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.
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.