| 1061 | } |
| 1062 | |
| 1063 | void BarPlotPrivate::updateValues() { |
| 1064 | m_valuesPath = QPainterPath(); |
| 1065 | m_valuesPoints.clear(); |
| 1066 | m_valuesStrings.clear(); |
| 1067 | |
| 1068 | if (value->type() == Value::NoValues) { |
| 1069 | recalcShapeAndBoundingRect(); |
| 1070 | return; |
| 1071 | } |
| 1072 | |
| 1073 | // formatting and drawing of the value strings is independent of the data columns, |
| 1074 | // put all value points for the different data columns together here to process in the same way below |
| 1075 | QVector<QPointF> valuesPointsLogical; |
| 1076 | for (const auto& points : m_valuesPointsLogical) |
| 1077 | valuesPointsLogical << points; |
| 1078 | |
| 1079 | // determine the value string for all points that are currently visible in the plot |
| 1080 | auto visiblePoints = std::vector<bool>(valuesPointsLogical.count(), false); |
| 1081 | Points pointsScene; |
| 1082 | q->cSystem->mapLogicalToScene(valuesPointsLogical, pointsScene, visiblePoints); |
| 1083 | const auto& prefix = value->prefix(); |
| 1084 | const auto& suffix = value->suffix(); |
| 1085 | const auto numberLocale = QLocale(); |
| 1086 | if (value->type() == Value::BinEntries) { |
| 1087 | for (int i = 0; i < valuesPointsLogical.count(); ++i) { |
| 1088 | if (!visiblePoints[i]) |
| 1089 | continue; |
| 1090 | |
| 1091 | auto& point = valuesPointsLogical.at(i); |
| 1092 | if (orientation == BarPlot::Orientation::Vertical) { |
| 1093 | if (type == BarPlot::Type::Stacked_100_Percent) |
| 1094 | m_valuesStrings << prefix + numberToString(point.y(), numberLocale, value->numericFormat(), 1) + QLatin1String("%") + suffix; |
| 1095 | else |
| 1096 | m_valuesStrings << prefix + numberToString(point.y(), numberLocale) + suffix; |
| 1097 | } else { |
| 1098 | if (type == BarPlot::Type::Stacked_100_Percent) |
| 1099 | m_valuesStrings << prefix + numberToString(point.x(), numberLocale, value->numericFormat(), 1) + QLatin1String("%") + suffix; |
| 1100 | else |
| 1101 | m_valuesStrings << prefix + numberToString(point.x(), numberLocale) + suffix; |
| 1102 | } |
| 1103 | } |
| 1104 | } else if (value->type() == Value::CustomColumn) { |
| 1105 | const auto* valuesColumn = value->column(); |
| 1106 | if (!valuesColumn) { |
| 1107 | recalcShapeAndBoundingRect(); |
| 1108 | return; |
| 1109 | } |
| 1110 | |
| 1111 | const int endRow = std::min(valuesPointsLogical.size(), static_cast<qsizetype>(valuesColumn->rowCount())); |
| 1112 | const auto xColMode = valuesColumn->columnMode(); |
| 1113 | for (int i = 0; i < endRow; ++i) { |
| 1114 | if (!valuesColumn->isValid(i) || valuesColumn->isMasked(i)) |
| 1115 | continue; |
| 1116 | |
| 1117 | switch (xColMode) { |
| 1118 | case AbstractColumn::ColumnMode::Double: |
| 1119 | if (type == BarPlot::Type::Stacked_100_Percent) |
| 1120 | m_valuesStrings << prefix + numberToString(valuesColumn->valueAt(i), numberLocale, value->numericFormat(), 1) + QString::fromStdString("%"); |
no test coverage detected