Making Vega-Lite bar marks adjacent - vega-lite

I'm working on a bar plot in Vega-Lite (generated using Altair). Using the Vega-View API, I've written some code where users can select bars, which changes those bars' colors (along with doing some other stuff elsewhere in the application; the details aren't super important for this question).
My problem is this. Using the default continuousBandSize of 5, when zoomed out the bars seem to "overlap" each other horizontally.
Here's a screenshot of this problem.
This problem is resolvable by setting continuousBandSize to 1, but the problem then is that -- when you zoom in to the chart -- the bars become very thin and hard for users to select. (Furthermore, since I'm coloring the bars gray by default, they become hard to distinguish from the grid behind the visualization; and I'd prefer to keep the grid if I can.) Here's a screenshot of this problem.
Is it possible to make the bar marks in Vega-Lite adjacent at any zoom level? Or is this not feasible?
Prior research on this problem
The problem of bars being too thin is mentioned in an issue on Vega-Lite's GitHub page here, but that issue seems to address a different problem (of the bars going outside of the visualization).
I've looked into using padding, paddingInner, and paddingOuter (as mentioned in the Vega-Lite documentation and in the answer to this question), with no success. The problem of increasing sizes causing bars to overlap is also brought up in an (unanswered) comment on this answer.
Example Vega-Lite Specification
An example specification showing a subset of the plot I'm working on (with continuousBandSize set to 1 to show the "thin-bar" problem) is available in the Vega Editor here (apologies for the long URL). As mentioned above, if you zoom in too far with continuousBandSize set to 1, the gray bars become very thin and hard to see. And if you set continuousBandSize to something like 2 or above and zoom out too far, the bars start to overlap each other (this is demonstrated by the blue bar starting to get slightly "covered" by the gray bar to its right -- this isn't super visible here since this is only a subset of the full plot, but the problem is a lot clearer when there are ~500 bars).
Thanks!

In your chart you are setting the x scale type to quantitative, which leads to very thin bars:
If you set the x scale to ordinal instead, the bars fill the space:
In general, bar charts perform better with non-continuous data.

I ran into the same issue. FWIW, the documentation does specify this behavior, although it took me a while to find it: effect of datatype on xaxis scales

Related

Border behaviour when drawing a rectangle in Pygame

I'm following a Pygame tutorial on YouTube published by Clear Code. So far it's gone well but I've run into an inconsistency between the demo on the video and the behaviour of my code, I'm pretty sure I'm doing exactly what the tutorial instructs, but my results are different.
I'm attempting to draw a border around a rectangle, the rectangle was created from a surface that contains some text as follows.
test_font = pygame.font.Font('font\Pixeltype.ttf',50)
score_surf = test_font.render('My Game', False, 'Black')
score_rect = score_surf.get_rect(center = (400,50))
#Later in the main loop
pygame.draw.rect(screen,'Pink',score_rect)
pygame.draw.rect(screen,'Pink',score_rect, 6)
My understanding is that the first pygame.draw.rect should colour in the area of the score_rect, and the second should create a border that goes slightly outside the area of the score_rect. This should leave a bit of pink visible all the way around the text. In the video I can see this happening, but when I run the code on my system the second pygame.draw.rect that specifies a border width doesn't seem to have any effect.
I've experimented a bit by removing the first pygame.draw.rect, this works mostly as expected I get a pink rectangular border around my text, but this border is strictly insisde the score_rect.
According to the Pygame documentation specifying the width argument should cause the border to go slightly outside the score_rect. However I'm not seeing this behaviour.
Link to Pygame documentation I'm reading
https://www.pygame.org/docs/ref/draw.html#pygame.draw.rect
Link to Youtube video I'm following, and location in video
https://youtu.be/AY9MnQ4x3zk?t=4879
Edit: Sorry I forgot to note my software versions
Pygame: 2.1.2
Python: 3.10.2
OS Windows 10
Any help would be appreciated.
I've come across people asking this exact question on other sites (not in a way that's very searchable, don't worry), so I'm mainly copy pasting my last answer.
In a recent version of pygame, draw.rect was changed to give "actual rectangles." This has an advantage of looking cleaner in many situations, and the algorithm for them is now significantly faster, helping performance.
I actually talked to someone with your exact same issue (like coming from the same tutorial) on discord, and we decided to use a rect.inflate() call to grow the rectangle out before drawing it behind the text.
For example, you could do something like
pygame.draw.rect(screen, 'Pink', score_rect.inflate(10,10))
Instead of both Clear's rect calls.
Or if you want to preserve the slight corner rounding you could do
pygame.draw.rect(screen, 'Pink', score_rect.inflate(10,10), border_radius=3)
So this just uses the return value of a Rect.inflate call instead of the original Rect itself. Inflate takes an x margin and a y margin, and returns a Rect larger/smaller by those amounts, but still centered in the same location.

What's a good way (using CSS) to extend part of an element on click?

I've attached two images showing the effect I'm trying to achieve, and what's wrong with the way I'm currently doing it. The first is displayed on page load, the second when you click on the down arrow.
The second partially obscures the first, currently using a negative margin. My current version has an invisible element underneath the leftmost box containing the icon, which has the same class as it that handles indentation. But At certain screen widths you get the effect below, where you can see the expanded section's border running halfway up the original element.
I've tried a few things to get rid of the glitch, but it's feeling a lot like pressing down bubbles - either they create worse problems, or the same problem at different widths.
I have the strong suspicion that I'm doing this all wrong, but I haven't thought of a better way to generate the same effects - border around the whole thing, text from the expanded element getting pulled up to approx where the original summary text was.
I can afford to use fairly modern CSS for this - our audience tends to be pretty high tech. In case relevant, I'm using a transition animation for the height increase, so it needs to be something consistent with that.
Before:
After:
The simplest fix for your problem is to make the left icon area overlap the rest (using z-index and position:relative) and extending it by 1px (so it covers the border in all cases).
Update your question with a code example and I'll update my answer with the fix, if the principle outlined above is not enough.
The alternative is to empirically determine the widths at which the border is misplaced and adjust the width of your dropdown, using #media queries.
Another rather important aspect which you don't seem to have determined is if the bug is specific to any particular browsers/devices.
As a side-note, I find quite a few questions similar to yours have one (rather silly) common cause: the developer has unknowingly changed the zoom level of their browser, pressing either Ctrl++ or Ctrl+-, viewing the page at 90% or 110%. Make sure you're developing at a zoom level of 100%, by pressing Ctrl+0.
I'd also like to suggest you take a look at How to ask to get tips on improving your question(s), to increase your chances of getting better answers.

SciChart: How do I control whether rollover axis labels are displayed

I have a chart with multiple modifiers that provide different behaviors on rollover. The chart used to have a vertical line that would show up on rollover. I was asked to get rid of it, which was easy:
<sci:RolloverModifier
DrawVerticalLine="False"
but I noticed that the label that shows up under the X axis is still there. I've tried to remove it, I didn't figure out how to do it.
I've examined some other graphs in the application, and found a similar one, which has the labels showing on both the X and the Y axis
[edit: image removed to prevent potential client IP issues]
I tried comparing the charts, and they do have different sets of modifiers, but I didn't find out what causes one graph to only have the graph on the X axis, and the other one on both.
The property you want is RolloverModifier.ShowAxisLabels.
However, the screenshot you've posted looks like the CursorModifier. If you find out that the CursorModifier is adding the labels then you can either remove this modifier, or you can try a workaround like this one on the SciChart Forums (which is 4 years old so may be out of date!)

Issue with alignment of horizontal labels in a bar chart

Having an issue with an app that has huge dependencies on Highcharts+Highstocks. The issue is that the labels for simple bar charts aren't tucked neatly under the bars but instead are skewed to the left way too much. I have too many theories as to why it happens to even mention but if you look at the image I attached you'll see right away (also it's noted in the image).
I've done quite a bit of research and experimentation on this and --- I saw some promise on the API side of things - to really muscle those labels around looks like it might be embedded in the Highcharts js codebase, to which access & forcing overrides is a little bit tricky in the way we implemented Highcharts + Highstocks.
Has anyone encountered this before? If so would you mind a comment or two as to how you managed to get those labels to align under the bars themselves? In a perfect world I'd have those MMM-YY labels centered right beneath the centerline of the bars.
Thank you in advance for your time and for reading this! Any ideas are appreciated and welcomed!
This is the issue I'm referring to:
According to documentation:
HTML labels that can be positioned anywhere in the chart area.
Use CSS to position those labels, either:
text-align: center;
or
margin: 0 auto;
Depending on how the code is structured. If you post your code I can give a more specific fix.

SSRS Horizontal Range Chart Causes Double Pages to be Rendered

I'm implementing a Gantt Chart in SSRS via the Horizontal Range Chart and notes I found here (http://pnarayanaswamy.blogspot.com/2010/09/range-bar-chart-gantt-chart-using-ssrs.html). I've successfully implemented the Gantt Chart plus some additions so it can span multiple pages (DynamicHeight based on # of rows). My problem is that no matter what I do, I end up with double blank pages at the end of the report. I.e. if my Gantt chart is 10 pages, I'll have 10 blank pages at the end.
Any ideas? It's most definitely not a margin issue, as I've removed everything from the report except the Gantt Chart and then made it 1" wide and still get the double-pages issue. It is always exactly double the # of pages it should be. I've turned on all borders to see if there are any dynamically expanding boxes that might cause this but nothing is showing up. I'm open to ideas from anyone who has experienced anything similar. This is probably rare, though, as charts don't typically span multiple pages.
Thanks for your help.
Rocky
Even though you've explored a lot of the options, this still sound like a width issue. certainly a width issue: have you checked the width of the "Body" (That's the name that will show in the Properties pane.) You can find this by clicking on a blank part of the report, the background, and then use the properties pane to alter the width (The Body Properties dialog doesn't have options to change this.) Another way of changing these is by dragging the border of the page around in the designer.
Make sure that the width of the Body is less than your page width minus margins. Those, as it sounds like you know, are set in Report menu -> Report Properties.