diff --git a/src/flamegraph.cpp b/src/flamegraph.cpp index 4ef41685..30e780e0 100644 --- a/src/flamegraph.cpp +++ b/src/flamegraph.cpp @@ -157,23 +157,24 @@ void FrameGraphicsItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* QColor::fromHsv((color.hue() + 120) % 360, color.saturation(), color.value(), color.alpha()); if (cost() > secondaryCost()) { - const auto width = rect().width() * static_cast(secondaryCost()) / (cost() + secondaryCost()); + const auto width = rect().width() * static_cast(secondaryCost()) / (cost()); auto mainRect = rect(); - mainRect.setWidth(rect().width() - width); + mainRect.setHeight(mainRect.height() / 2); painter->fillRect(mainRect, color); auto secondaryRect = rect(); secondaryRect.setWidth(width); - secondaryRect.moveRight(rect().right()); + secondaryRect.setHeight(mainRect.height()); + secondaryRect.moveBottom(rect().bottom()); painter->fillRect(secondaryRect, secondaryColor); } else { - const auto width = rect().width() * static_cast(cost()) / (secondaryCost() + cost()); + const auto width = rect().width() * static_cast(cost()) / (secondaryCost()); auto mainRect = rect(); - // mainRect.setWidth(rect().width() - width); - mainRect.moveRight(rect().right()); + mainRect.setWidth(width); + mainRect.setHeight(mainRect.height() / 2); painter->fillRect(mainRect, color); auto secondaryRect = rect(); - secondaryRect.setWidth(width); - secondaryRect.moveRight(rect().right()); + secondaryRect.setHeight(mainRect.height()); + secondaryRect.moveBottom(rect().bottom()); painter->fillRect(secondaryRect, secondaryColor); }