error bars for y
| 325 | |
| 326 | // error bars for y |
| 327 | void ErrorBarPrivate::painterPathForY(QPainterPath& path, |
| 328 | const QVector<QPointF>& points, |
| 329 | const CartesianCoordinateSystem* cSystem, |
| 330 | WorksheetElement::Orientation orientation) const { |
| 331 | QVector<QLineF> elines; |
| 332 | |
| 333 | switch (yErrorType) { |
| 334 | case ErrorBar::ErrorType::NoError: |
| 335 | return; |
| 336 | case ErrorBar::ErrorType::Poisson: { |
| 337 | if (orientation == WorksheetElement::Orientation::Vertical) { |
| 338 | for (auto& point : points) { |
| 339 | const double error = sqrt(point.y()); |
| 340 | if (error != 0.) |
| 341 | elines << QLineF(point.x(), point.y() + error, point.x(), point.y() - error); |
| 342 | } |
| 343 | } else { |
| 344 | for (auto& point : points) { |
| 345 | double error = sqrt(point.x()); |
| 346 | if (error != 0.) |
| 347 | elines << QLineF(point.x() - error, point.y(), point.x() + error, point.y()); |
| 348 | } |
| 349 | } |
| 350 | break; |
| 351 | } |
| 352 | case ErrorBar::ErrorType::Symmetric: { |
| 353 | int index = 0; |
| 354 | if (orientation == WorksheetElement::Orientation::Vertical) { |
| 355 | for (auto& point : points) { |
| 356 | if (yPlusColumn && yPlusColumn->isValid(index) && !yPlusColumn->isMasked(index)) { |
| 357 | const double error = yPlusColumn->valueAt(index); |
| 358 | if (error != 0.) |
| 359 | elines << QLineF(point.x(), point.y() + error, point.x(), point.y() - error); |
| 360 | } |
| 361 | ++index; |
| 362 | } |
| 363 | } else { |
| 364 | for (auto& point : points) { |
| 365 | if (yPlusColumn && yPlusColumn->isValid(index) && !yPlusColumn->isMasked(index)) { |
| 366 | double error = yPlusColumn->valueAt(index); |
| 367 | if (error != 0.) |
| 368 | elines << QLineF(point.x() - error, point.y(), point.x() + error, point.y()); |
| 369 | } |
| 370 | ++index; |
| 371 | } |
| 372 | } |
| 373 | break; |
| 374 | } |
| 375 | case ErrorBar::ErrorType::Asymmetric: { |
| 376 | int index = 0; |
| 377 | if (orientation == WorksheetElement::Orientation::Vertical) { |
| 378 | for (auto& point : points) { |
| 379 | double errorPlus = 0.; |
| 380 | double errorMinus = 0.; |
| 381 | |
| 382 | if (yPlusColumn && yPlusColumn->isValid(index) && !yPlusColumn->isMasked(index)) |
| 383 | errorPlus = yPlusColumn->valueAt(index); |
| 384 |
no test coverage detected