Skip to content

Commit

Permalink
Show correct time unit in the plot tooltip (#10107)
Browse files Browse the repository at this point in the history
Fixes #9950
Update the legend when unit prefix is enabled/disabled
Use correct exponent value
  • Loading branch information
adeas31 committed Jan 26, 2023
1 parent fbc4a47 commit e469b0c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions OMPlot/OMPlot/OMPlotGUI/Plot.cpp
Expand Up @@ -300,6 +300,8 @@ void Plot::replot()
mpParentPlotWindow->setCanUseYPrefixUnits(canUseYPrefixUnits);
mpYScaleDraw->invalidateCache();

QwtPlot::replot();

// Now we need to again loop through curves to set the color and title.
for (int i = 0 ; i < mPlotCurvesList.length() ; i++) {
// if user has set the custom color for the curve then dont get automatic color for it
Expand Down Expand Up @@ -335,8 +337,6 @@ void Plot::replot()
} else {
setAxisTitle(QwtPlot::yLeft, mpParentPlotWindow->getYCustomLabel());
}

QwtPlot::replot();
}

} // namespace OMPlot
2 changes: 1 addition & 1 deletion OMPlot/OMPlot/OMPlotGUI/PlotPicker.cpp
Expand Up @@ -173,7 +173,7 @@ QwtText PlotPicker::trackerText(const QPoint &pos) const
if (mpPlot->getParentPlotWindow()->getPlotType() != PlotWindow::PLOTPARAMETRIC
&& mpPlot->getParentPlotWindow()->getPlotType() != PlotWindow::PLOTARRAYPARAMETRIC
&& !mpPlot->getParentPlotWindow()->getTimeUnit().isEmpty()) {
timeUnit = QString("%1").arg(mpPlot->getParentPlotWindow()->getTimeUnit());
timeUnit = QString("%1%2").arg(mpPlot->getXScaleDraw()->getUnitPrefix(), mpPlot->getParentPlotWindow()->getTimeUnit());
}
QString toolTip;
for (int i = 0 ; i < plotCurves.size() ; i++) {
Expand Down
1 change: 0 additions & 1 deletion OMPlot/OMPlot/OMPlotGUI/PlotWindow.cpp
Expand Up @@ -2291,7 +2291,6 @@ void SetupDialog::applySetup()
mpPlotWindow->setYRange(mpYMinimumTextBox->text().toDouble(), mpYMaximumTextBox->text().toDouble());
}
// replot
mpPlotWindow->getPlot()->updateLayout();
mpPlotWindow->getPlot()->replot();
if (requiresFitInView) {
mpPlotWindow->fitInView();
Expand Down
2 changes: 2 additions & 0 deletions OMPlot/OMPlot/OMPlotGUI/ScaleDraw.cpp
Expand Up @@ -114,6 +114,8 @@ QwtText ScaleDraw::label(double value) const
}
}
value = value / qPow(10, mExponent);
} else {
mExponent = 0;
}
}
return QLocale().toString(value, 'g', 4);
Expand Down

0 comments on commit e469b0c

Please sign in to comment.