How do I set a minimum bar width for a Chart.js bar chart? When I have many bars, they become very thin in order to fit the given space. Instead, I want the bars to have a minimum width, and if necessary, there should be a scrollbar so that everything fits. There is a maxBarThickness but not a minBarThickness: https://www.chartjs.org/docs/latest/charts/bar.html#maxbarthickness.
Well the min setting is achieved with barThickness check the documentation for details.
... If this value is a number, it is applied to the width of each bar, in pixels. When this is enforced, barPercentage and categoryPercentage are ignored. ...
Related
I have a chart in vue3 with vue-chart.js
When I view in mobile size the chart is too small to view in height.
How do I assign a min-height in CSS or in chart-options?
I have set the div height to 200px but the chart will still shrink as the width gets reduced.
I can set the chart-options "responsive: false" and the hiegth but the width does not follow changing size. Maybe a responsive in width but set height is the answer but not sure how to do that.
Thanks
Is there a way in draw.io, to autosize a text container, keeping it's width fixed, and telling draw.io to only adjust the height if neccessary?
I tried out almost all options in the properties of the text box, but when I apply the autosize, it always overwrites my set width and height, by making the width larger, and the height smaller.
I am putting these texts inside a swimlane, and what I would like to achieve is, either:
when I add text to these text rectangles, the rectangle and the swimlane should expand automatically, but only vertically, ie, only the height of it should change (this would be the best for me, so that it is automatic)
if the automatic solution is not achievable, I would be happy with something like manually pressing the autosize button, and draw.io should keep my width fixed, and change the size of the height only.
Couldn't find any documentation anywhere. But I notice that the behaviour of auto wrap is different depending on the object type that you choose. For example,
The above one is a "Rectangle". it won't resize the width when auto-sizing. The bottom one is a "UML/Object". It will resize both the width and height.
I've had a real challenge getting QScrollArea to take the minimum space possible up to a maximum height.
My GUI model is as follows: A QScrollArea contains a vertical layout which is populated with a widget of class TableRow. I want this class TableRow to take up the minimum height possible. It has a widget at the top which is always visible, and a QScrollArea below which has a label inside it whose visibility can be toggled. The label is for notes which may be 0 characters or may be infinite in length (hardware limitations aside).
I've found that for a label in class TableRow setting the vertical sizePolicy to Fixed will actually take up exactly how much it needs to fit all the contents (see: Qt Layout, resize to minimum after widget size changes). However this doesn't appear to work with QScrollArea. In fact every sizePolicy I've tried keeps the QScrollArea at a fixed height; except for Ignore, but then the QScrollArea goes to a height of 0, regardless of its contents.
I've created a git branch producing a simplified version of this problem.
Here is the result of applying a fixed vertical sizePolicy:
What I'm expecting from this test case:
The first widget's height should be almost 30px (the height of the upper widget) only showing the borders for the QLabel and QScrollArea
The second widget's height should be shorter than 130px (the maximum height of the QScrollArea being 100px) but large enough to show the label without scrolling
The third widget's height should be 130px, and the scrollbar should appear (this part is correct in every case I've tried except for when the vertical sizePolicy is set to Ignored )
I understand I may need to override some things to make this work, as by itself it's not obvious why a QScrollArea's height might be dependent on its child widgets (which is probably why it was not designed to make this easy, or at least it seems like it wasn't).
However, I think the case I'm trying to make is common enough, and my current approach is justifiable. If there's another/better way to make an individual widget scroll after it reaches a maximum height I'm open to that as an answer, provided it meets the three conditions I'm expecting.
This feels more like a hack than a solution, but it does work for me, at least in the short term. Because the text for lblNotes does not change runtime, I was able to add the following code in the constructor of my TableRow widget:
// Hack to resize QScrollAreas
ui->lblNotes->adjustSize(); // Otherwise lblNotes will think its height is still ~0px
int height = ui->lblNotes->height() + 12; // Borders and margins add up to 12px
if (height > 100) { height = 100; } // Cap the height at desired maximum value
ui->scrollArea->setFixedHeight(height);
Should I have to deal with the case of dynamically set text, I could wrap this in a function to be called anytime the text of lblNotes is set.
I'm still open to solutions that involve using the layout features Qt has natively as I believe that would be preferred if a solution exists. Some QScrollArea contents may not be as straight-forward to determine the height from in the future.
I would like the horizontal scroll bar to appear whenever there is text eliding. Such that the user won't have to resize the whole GUI. How would I do this?
This is what I have coded:
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
ui->tableWidget->resizeColumnsToContents();
I also tried enabling scrollbar to appear always, but scrolling to the very right doesn't do anything.
If I set textElideMode to ElideNone , the text from the 2nd column is partially hidden and no scrollbar appears.
QHeaderView::Stretch will stretch the column width to the available space. Use QHeaderView::ResizeToContents to make the column wide enough to display the content, resulting in a horizontal scroll bar if necessary.
This will have a couple of side effects of which I'm not sure you want them.
There will probably be no more ellipsis in the elided text.
If all of the values in your Hash column are very small, then that column will be very thin, so there might be 'empty' space next to that column.
I have a list control and disable the scroll bar using the following code.
InitializeFlatSB(this->m_hWnd);
FlatSB_EnableScrollBar(this->m_hWnd, SB_BOTH, ESB_DISABLE_BOTH);
The scroll bars don't disappear, they just become white, which is what I need because I want to redraw my own scroll bars on their original rectangle region. In that way, my own scroll bars won't cover the list content and I can add functionality so that the mouse wheel function will be enabled.
But now how can I get the rectangle region of the scroll bars?
As suggested in the comments, can you try to deduce the rectangle from GetWindowRect and GetClientRect? It seems to be a easy calculation to do subtractions and get a Non Client rectangle for the Vertical scroll bar and another for the Horizontal.