Skip to content

Commit

Permalink
temp fix for time formatted mouse position text
Browse files Browse the repository at this point in the history
  • Loading branch information
epezent committed Jul 8, 2022
1 parent 8c53333 commit 1fed5c2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions implot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,9 +1563,21 @@ static inline double RoundAxisValue(const ImPlotAxis& axis, double value) {
}

void LabelAxisValue(const ImPlotAxis& axis, double value, char* buff, int size, bool round) {
if (round)
value = RoundAxisValue(axis, value);
axis.Formatter(value, buff, size, axis.FormatterData);
ImPlotContext& gp = *GImPlot;
// TODO: We shouldn't explicitly check that the axis is Time here. Ideally,
// Formatter_Time would handle the formatting for us, but the code below
// needs additional arguments which are not currently available in ImPlotFormatter
if (axis.Locator == Locator_Time) {
ImPlotTimeUnit unit = axis.Vertical
? GetUnitForRange(axis.Range.Size() / (gp.CurrentPlot->PlotRect.GetHeight() / 100)) // TODO: magic value!
: GetUnitForRange(axis.Range.Size() / (gp.CurrentPlot->PlotRect.GetWidth() / 100)); // TODO: magic value!
FormatDateTime(ImPlotTime::FromDouble(value), buff, size, GetDateTimeFmt(TimeFormatMouseCursor, unit));
}
else {
if (round)
value = RoundAxisValue(axis, value);
axis.Formatter(value, buff, size, axis.FormatterData);
}
}

void UpdateAxisColors(ImPlotAxis& axis) {
Expand Down

0 comments on commit 1fed5c2

Please sign in to comment.