Important: Please read the Qt Code of Conduct -

Creating a mekko or mosaic chart

  • A mekko or mosaic chart is a form of stacked bar chart with variable width bars. The width of the bar indicates the relative sizes of each of the items on the x-axis; the individual pieces of the bar represent the breakdown within that segment, adding up to 100% (see example below).

    Is it possible to create variable width columns in Qt Charts? Would you inherit from stacked bar chart? Any suggestions appreciated.



  • Lifetime Qt Champion

    It sounds to me that all bars are same width
    But there might exists some method to set it that i dont know of.

    Do you need zooming and selection and that stuff ?
    Otherwise just drawing it yourself would not be huge tasks.

  • From what I could tell looking at the docs, there is no way to have a separate width for each bar. Yes, I can create the whole thing from scratch, but I would like to take advantage of the work that others have already done and have a reproducible structure instead of a one off.

  • Lifetime Qt Champion

    Agree, if you are using other Charts it would be better to reuse as much as possible.

    One thing i saw in docs.
    "Sets the width of the bars of the series. "

    So i wondered if one can have multiple series in one chart as that would mean
    each series can have own width. so if one bar pr series maybe that way
    one can have varying widths.

    Looking at QStackedBarSeries / QAbstractBarSeries im not sure its possible to subclass and override
    so barWidth can return different values.

Log in to reply