I did not find a way to hide some of the categories in QBarCategoryAxis
when I create a chart. If I do not specify the category for axis, by default the categories will be like from 1 to QBarSet
size. If I specify the category, how am I able to only display some of the categories in axis. For example: how to only display the first and last categories and the category in the middle in QBarCategoryAxis
?
Edit:
Currently what I get is like this:
I have one QBarSet
which has 6 elements. And I did not set the category text, so by default those category texts are from 1 to 6. what I want is to display some of the category texts, like to only display 1, 3, 6 and the rest of the text(2, 4, 5) are hidden.
Why I want to do this?
Because when the QBarSet
has more elements and when I specify the category texts by myself, usually I need to maximize the window so I can see all the category texts which are displayed in the axisX. But I just want the chart to have a fixed size, so as for the texts, I just want a part of them are being displayed.
BTW, this will be what looks like if a bar set has lots of elements, and the texts below will not be full displayed until I maximize the window.
Edit 2:
This is what I want I want the chart looks like:
As you can see, below the axis x, it only has 5 texts.
The following solution only works for the case in which you want to show dates in the X axis. The trick is to use
QDateTimeAxis
but to do this, create a fictitiousQLineSeries
that will have as values the dates and in And anything else, then it will hide.