From 49c7b4a9cdcad20fc35d2a76d9c40a8c0eb94424 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Tue, 5 Nov 2024 04:49:24 -0700 Subject: [PATCH 1/6] Work on SAM issue 289 - update time series plot axis to ignore leap years --- src/plot/plaxis.cpp | 53 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index 9a2ea3f2..a1eac6e6 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -669,6 +669,32 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { //We need to figure out whether we are looking at hours, days, or months, and label the graph appropriately. wxDateTime timeKeeper(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones + // leap year for min and max values + // both are tracked as hours since Jan 1, 1971 + int m_min_days_to_add = 0, m_max_days_to_add = 0; + int m_min_num_years = m_min / 8760; + int m_max_num_years = m_max / 8760; + + wxDateTime m_min_dt = timeKeeper; + for (size_t i = 0; i < m_min_num_years; i++) { + //wxDateTime dt = timeKeeper.Add() later than Feb 28 +// auto ndays = timeKeeper.GetNumberOfDays(i); + if (m_min_dt.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt)) + m_min_days_to_add++; +// m_min_dt.Add(wxTimeSpan::Days(ndays+1)); + } + // can start with m_min_days_to_add + wxDateTime m_max_dt = timeKeeper; + for (size_t i = 0; i < m_max_num_years; i++) { + //wxDateTime dt = timeKeeper.Add() later than Feb 28 + auto ndays = timeKeeper.GetNumberOfDays(i); + if (m_max_dt.IsLeapYear())// && m_min_dt.IsLaterThan(dt)) + m_max_days_to_add++; + m_max_dt.Add(wxTimeSpan::Days(ndays +1)); + } + + + double world_len = m_max - m_min; double time = m_min; timeKeeper.Add(wxTimeSpan::Minutes(60 * time)); @@ -677,6 +703,9 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { if (timeKeeper.IsDST()) timeKeeper.Subtract(wxTimeSpan::Hour()); + timeKeeper.Add(wxTimeSpan::Days(m_min_days_to_add)); + + if (world_len <= 72) { if (floor(time) != time) { timeKeeper.Add(wxTimeSpan::Minutes(60 * (floor(time) + 2 - time))); @@ -701,10 +730,21 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { timeKeeper2.Add(wxTimeSpan::Hour()); } + if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) + timeKeeper.Add(wxTimeSpan::Hours(24)); + if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) + timeKeeper2.Add(wxTimeSpan::Hours(24)); + + //if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29) + // && !(timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) { + // auto x = timeKeeper.GetMonth(); + // auto y = timeKeeper.GetDay(); + // auto z = x + y; if (timeKeeper.GetDay() == timeKeeper2.GetDay()) m_timeLabel = timeKeeper.Format("%b %d"); else m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%d"); + //} do { m_tickList.push_back(TickData(time, timeKeeper.Format("%H"), TickData::LARGE)); @@ -741,11 +781,14 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { } do { - m_tickList.push_back(TickData(time, timeKeeper.Format("%b %d"), TickData::NONE)); - time += 12; - if (time < m_max) - m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight - time += 12; + if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) { + auto str = timeKeeper.Format("%b %d"); + m_tickList.push_back(TickData(time, str, TickData::NONE)); + time += 12; + if (time < m_max) + m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight + time += 12; + } timeKeeper.Add(wxTimeSpan::Hours(24)); } while (time < m_max); } else { From ed70db23f8eabcc282eeda68769a9c1d340b18e2 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Tue, 5 Nov 2024 05:28:40 -0700 Subject: [PATCH 2/6] SAM issue 289 - not yet working --- src/plot/plaxis.cpp | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index a1eac6e6..3c57931a 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -668,30 +668,21 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { //We need to figure out whether we are looking at hours, days, or months, and label the graph appropriately. wxDateTime timeKeeper(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones + wxDateTime timeKeeperRef(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones // leap year for min and max values // both are tracked as hours since Jan 1, 1971 - int m_min_days_to_add = 0, m_max_days_to_add = 0; + int m_min_days_to_add = 0; int m_min_num_years = m_min / 8760; int m_max_num_years = m_max / 8760; - wxDateTime m_min_dt = timeKeeper; for (size_t i = 0; i < m_min_num_years; i++) { //wxDateTime dt = timeKeeper.Add() later than Feb 28 // auto ndays = timeKeeper.GetNumberOfDays(i); - if (m_min_dt.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt)) + if (timeKeeperRef.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt)) m_min_days_to_add++; // m_min_dt.Add(wxTimeSpan::Days(ndays+1)); } - // can start with m_min_days_to_add - wxDateTime m_max_dt = timeKeeper; - for (size_t i = 0; i < m_max_num_years; i++) { - //wxDateTime dt = timeKeeper.Add() later than Feb 28 - auto ndays = timeKeeper.GetNumberOfDays(i); - if (m_max_dt.IsLeapYear())// && m_min_dt.IsLaterThan(dt)) - m_max_days_to_add++; - m_max_dt.Add(wxTimeSpan::Days(ndays +1)); - } @@ -730,9 +721,12 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { timeKeeper2.Add(wxTimeSpan::Hour()); } - if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) + // TODO condition needs to be if leap year and day of year > 2/28 then add a day... + if ((timeKeeper.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min/8760))) +// if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) timeKeeper.Add(wxTimeSpan::Hours(24)); - if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) +// if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) + if ((timeKeeper2.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min / 8760))) timeKeeper2.Add(wxTimeSpan::Hours(24)); //if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29) @@ -781,14 +775,14 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { } do { - if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) { - auto str = timeKeeper.Format("%b %d"); - m_tickList.push_back(TickData(time, str, TickData::NONE)); - time += 12; - if (time < m_max) - m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight - time += 12; - } + if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) + timeKeeper.Add(wxTimeSpan::Hours(24)); + auto str = timeKeeper.Format("%b %d"); + m_tickList.push_back(TickData(time, str, TickData::NONE)); + time += 12; + if (time < m_max) + m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight + time += 12; timeKeeper.Add(wxTimeSpan::Hours(24)); } while (time < m_max); } else { From 7e24cc2f4676ae897493e8589c8a68df0239fe69 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Wed, 6 Nov 2024 04:15:56 -0700 Subject: [PATCH 3/6] Rewrite void wxPLTimeAxis::RecalculateTicksAndLabel() to use non-leapyear --- src/plot/plaxis.cpp | 90 ++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 51 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index 3c57931a..c922c59e 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -668,34 +668,26 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { //We need to figure out whether we are looking at hours, days, or months, and label the graph appropriately. wxDateTime timeKeeper(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones - wxDateTime timeKeeperRef(1, wxDateTime::Jan, 1971, 0, 0, 0); // works all time zones - - // leap year for min and max values - // both are tracked as hours since Jan 1, 1971 - int m_min_days_to_add = 0; - int m_min_num_years = m_min / 8760; - int m_max_num_years = m_max / 8760; - - for (size_t i = 0; i < m_min_num_years; i++) { - //wxDateTime dt = timeKeeper.Add() later than Feb 28 -// auto ndays = timeKeeper.GetNumberOfDays(i); - if (timeKeeperRef.IsLeapYear(i))// && m_min_dt.IsLaterThan(dt)) - m_min_days_to_add++; -// m_min_dt.Add(wxTimeSpan::Days(ndays+1)); - } - double world_len = m_max - m_min; double time = m_min; + + // to skip leap years (SAM issue 289) - scale to first year + int m_min_offset = m_min / 8760; + double m_min_scaled = (double)((int)m_min % 8760); // m_min and m_max always based on 8760 (365 days with no leap years) + int m_max_offset = m_max / 8760; + double m_max_scaled = (double)((int)m_max % 8760); // m_min and m_max always based on 8760 (365 days with no leap years) + if (m_max_scaled <= m_min_scaled) m_max_scaled += 8760; // handle year end points + + time = m_min_scaled; + timeKeeper.Add(wxTimeSpan::Minutes(60 * time)); // Handle DST. if (timeKeeper.IsDST()) timeKeeper.Subtract(wxTimeSpan::Hour()); - timeKeeper.Add(wxTimeSpan::Days(m_min_days_to_add)); - if (world_len <= 72) { if (floor(time) != time) { @@ -714,31 +706,18 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { // Less than 2 days. Need to label time. wxDateTime timeKeeper2(timeKeeper.GetTicks()); - timeKeeper2.Add(wxTimeSpan::Minutes(60 * world_len)); + timeKeeper2.Add(wxTimeSpan::Minutes(60 * world_len)); // TODO 289 - check scaling timeKeeper2.Subtract(wxTimeSpan::Minute()); //If it is 0:00 the next day, its really the same day. if (timeKeeper.IsDST() && !timeKeeper2.IsDST()) { timeKeeper.Add(wxTimeSpan::Hour()); timeKeeper2.Add(wxTimeSpan::Hour()); } - - // TODO condition needs to be if leap year and day of year > 2/28 then add a day... - if ((timeKeeper.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min/8760))) -// if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) - timeKeeper.Add(wxTimeSpan::Hours(24)); -// if ((timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) - if ((timeKeeper2.GetDayOfYear() > (31 + 27)) && (timeKeeperRef.IsLeapYear(m_min / 8760))) - timeKeeper2.Add(wxTimeSpan::Hours(24)); - - //if (!(timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29) - // && !(timeKeeper2.GetMonth() == wxDateTime::Feb && timeKeeper2.GetDay() == 29)) { - // auto x = timeKeeper.GetMonth(); - // auto y = timeKeeper.GetDay(); - // auto z = x + y; if (timeKeeper.GetDay() == timeKeeper2.GetDay()) m_timeLabel = timeKeeper.Format("%b %d"); + else if (timeKeeper.GetMonth() == timeKeeper2.GetMonth()) + m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%d"); // TODO fix year 2 Feb 28-01 (always been the case) else - m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%d"); - //} + m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%b %d"); do { m_tickList.push_back(TickData(time, timeKeeper.Format("%H"), TickData::LARGE)); @@ -775,16 +754,18 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { } do { - if ((timeKeeper.GetMonth() == wxDateTime::Feb && timeKeeper.GetDay() == 29)) - timeKeeper.Add(wxTimeSpan::Hours(24)); auto str = timeKeeper.Format("%b %d"); - m_tickList.push_back(TickData(time, str, TickData::NONE)); +// m_tickList.push_back(TickData(time, str, TickData::NONE)); + m_tickList.push_back(TickData(time + m_min_offset*8760, str, TickData::NONE)); time += 12; - if (time < m_max) - m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight +// if (time < m_max) + if (time < m_max_scaled) + m_tickList.push_back(TickData(time + m_min_offset * 8760, wxEmptyString, TickData::LARGE)); // midnight +// m_tickList.push_back(TickData(time, wxEmptyString, TickData::LARGE)); // midnight time += 12; timeKeeper.Add(wxTimeSpan::Hours(24)); - } while (time < m_max); + } while (time < m_max_scaled); +// } while (time < m_max); } else { //Assume day endpoints. //Only Label Months @@ -800,13 +781,16 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { timeKeeper2.Add(wxTimeSpan::Day()); } - m_tickList.push_back(TickData(time + daysVisibleInMonth * 24.0f, wxEmptyString, TickData::LARGE)); +// m_tickList.push_back(TickData(time + daysVisibleInMonth * 24.0f, wxEmptyString, TickData::LARGE)); + m_tickList.push_back(TickData(time + daysVisibleInMonth * 24.0f + m_min_offset * 8760, wxEmptyString, TickData::LARGE)); int endMonthHours = time + daysVisibleInMonth * 24.0f; //00:00 on first of next month. if (daysVisibleInMonth >= 7) { //Label the month if it has more than seven days visible. +// m_tickList.push_back( +// TickData(time + (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); m_tickList.push_back( - TickData(time + (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); + TickData(time + (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b first"), TickData::NONE)); } timeKeeper2.SetDay(wxDateTime::GetNumberOfDays(timeKeeper2.GetMonth()) / 2); //Middle of the second month. @@ -816,24 +800,27 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { //Loop, labeling months //While end of month is visible. do { - m_tickList.push_back(TickData(time, timeKeeper2.Format("%b"), TickData::NONE)); +// m_tickList.push_back(TickData(time, timeKeeper2.Format("%b"), TickData::NONE)); + m_tickList.push_back(TickData(time + m_min_offset * 8760, timeKeeper2.Format("%b second"), TickData::NONE)); timeKeeper.Set(timeKeeper2.GetTicks()); //timeKeeper is position of last label. timeKeeper2.Add(wxDateSpan::Month()); timeKeeper2.SetDay(1); //timeKeeper2 is day 1 of next month. - m_tickList.push_back(TickData(time + timeKeeper2.Subtract(timeKeeper).GetHours(), wxEmptyString, - TickData::LARGE)); //Adds tick at this pos. (start-month) +// m_tickList.push_back(TickData(time + timeKeeper2.Subtract(timeKeeper).GetHours(), wxEmptyString, +// TickData::LARGE)); //Adds tick at this pos. (start-month) + m_tickList.push_back(TickData(time + timeKeeper2.Subtract(timeKeeper).GetHours() + m_min_offset * 8760, wxEmptyString, + TickData::LARGE)); //Adds tick at this pos. (start-month) timeKeeper2.SetDay(wxDateTime::GetNumberOfDays(timeKeeper2.GetMonth()) / 2); //timeKeeper2 mid month time += timeKeeper2.Subtract(timeKeeper).GetHours(); //hours midMonth. endMonthHours += 24 * wxDateTime::GetNumberOfDays(timeKeeper2.GetMonth()); +// } while (endMonthHours < m_max_scaled); } while (endMonthHours < m_max); //timeKeeper holds the middle of last month we actually labelled. //We still need to label the last month if it has more than 7 days showing. timeKeeper.Add(wxDateSpan::Month()); timeKeeper.SetDay(1); // First not-yet-labeled month - time = endMonthHours - - 24 * wxDateTime::GetNumberOfDays(timeKeeper.GetMonth()); //00:00 on first of not-yet-labeled month. + time = endMonthHours - 24 * wxDateTime::GetNumberOfDays(timeKeeper.GetMonth()); //00:00 on first of not-yet-labeled month. //Take care of fractional days at the max. timeKeeper2 = wxDateTime(01, wxDateTime::Jan, 1970, 00, 00, 00); @@ -844,7 +831,8 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { time += daysVisibleInMonth * 24.0f; timeKeeper2.Add(wxTimeSpan::Minutes(daysVisibleInMonth * 24.0f * 60.0f)); - while (time < m_max && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { +// while (time < m_max && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { + while (time < m_max_scaled && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { daysVisibleInMonth += 1; timeKeeper2.Add(wxTimeSpan::Day()); time += 24; @@ -852,8 +840,8 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { if (daysVisibleInMonth >= 7) { //Label the month if it has more than seven days visible. - m_tickList.push_back( - TickData(time - (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); +// m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); + m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b third"), TickData::NONE)); } } From 9dc2182aeedecfbfe1a1e2040edbdeb187c02f37 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Wed, 6 Nov 2024 04:24:28 -0700 Subject: [PATCH 4/6] Remove test labels and unused variables --- src/plot/plaxis.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index c922c59e..540c8012 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -676,7 +676,6 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { // to skip leap years (SAM issue 289) - scale to first year int m_min_offset = m_min / 8760; double m_min_scaled = (double)((int)m_min % 8760); // m_min and m_max always based on 8760 (365 days with no leap years) - int m_max_offset = m_max / 8760; double m_max_scaled = (double)((int)m_max % 8760); // m_min and m_max always based on 8760 (365 days with no leap years) if (m_max_scaled <= m_min_scaled) m_max_scaled += 8760; // handle year end points @@ -790,7 +789,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { // m_tickList.push_back( // TickData(time + (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); m_tickList.push_back( - TickData(time + (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b first"), TickData::NONE)); + TickData(time + (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b"), TickData::NONE)); } timeKeeper2.SetDay(wxDateTime::GetNumberOfDays(timeKeeper2.GetMonth()) / 2); //Middle of the second month. @@ -801,7 +800,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { //While end of month is visible. do { // m_tickList.push_back(TickData(time, timeKeeper2.Format("%b"), TickData::NONE)); - m_tickList.push_back(TickData(time + m_min_offset * 8760, timeKeeper2.Format("%b second"), TickData::NONE)); + m_tickList.push_back(TickData(time + m_min_offset * 8760, timeKeeper2.Format("%b"), TickData::NONE)); timeKeeper.Set(timeKeeper2.GetTicks()); //timeKeeper is position of last label. timeKeeper2.Add(wxDateSpan::Month()); timeKeeper2.SetDay(1); //timeKeeper2 is day 1 of next month. @@ -841,7 +840,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { if (daysVisibleInMonth >= 7) { //Label the month if it has more than seven days visible. // m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); - m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b third"), TickData::NONE)); + m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b"), TickData::NONE)); } } From 72e162f829fa8447042fb66a7b6ba303b7ce34b4 Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Thu, 7 Nov 2024 04:04:54 -0700 Subject: [PATCH 5/6] Address feedback for #179 --- src/plot/plaxis.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index 540c8012..1f57ad1b 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -782,7 +782,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { // m_tickList.push_back(TickData(time + daysVisibleInMonth * 24.0f, wxEmptyString, TickData::LARGE)); m_tickList.push_back(TickData(time + daysVisibleInMonth * 24.0f + m_min_offset * 8760, wxEmptyString, TickData::LARGE)); - int endMonthHours = time + daysVisibleInMonth * 24.0f; //00:00 on first of next month. + int endMonthHours = time + m_min_offset * 8760 + daysVisibleInMonth * 24.0f; //00:00 on first of next month. if (daysVisibleInMonth >= 7) { //Label the month if it has more than seven days visible. @@ -830,8 +830,8 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { time += daysVisibleInMonth * 24.0f; timeKeeper2.Add(wxTimeSpan::Minutes(daysVisibleInMonth * 24.0f * 60.0f)); -// while (time < m_max && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { - while (time < m_max_scaled && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { + while (time < m_max && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { +// while (time < m_max_scaled && timeKeeper2.GetMonth() == timeKeeper.GetMonth()) { daysVisibleInMonth += 1; timeKeeper2.Add(wxTimeSpan::Day()); time += 24; @@ -839,8 +839,8 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { if (daysVisibleInMonth >= 7) { //Label the month if it has more than seven days visible. -// m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); - m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b"), TickData::NONE)); + m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f), timeKeeper.Format("%b"), TickData::NONE)); +// m_tickList.push_back(TickData(time - (daysVisibleInMonth * 24.0f / 2.0f) + m_min_offset * 8760, timeKeeper.Format("%b third"), TickData::NONE)); } } From 9f31b487cd0f51e1de6726f362e596e503eb157c Mon Sep 17 00:00:00 2001 From: Steven Janzou Date: Fri, 8 Nov 2024 00:35:33 -0700 Subject: [PATCH 6/6] Remove TODO comments that are completed per request in #179 --- src/plot/plaxis.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plot/plaxis.cpp b/src/plot/plaxis.cpp index 1f57ad1b..47021d33 100644 --- a/src/plot/plaxis.cpp +++ b/src/plot/plaxis.cpp @@ -705,7 +705,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { // Less than 2 days. Need to label time. wxDateTime timeKeeper2(timeKeeper.GetTicks()); - timeKeeper2.Add(wxTimeSpan::Minutes(60 * world_len)); // TODO 289 - check scaling + timeKeeper2.Add(wxTimeSpan::Minutes(60 * world_len)); timeKeeper2.Subtract(wxTimeSpan::Minute()); //If it is 0:00 the next day, its really the same day. if (timeKeeper.IsDST() && !timeKeeper2.IsDST()) { timeKeeper.Add(wxTimeSpan::Hour()); @@ -714,7 +714,7 @@ void wxPLTimeAxis::RecalculateTicksAndLabel() { if (timeKeeper.GetDay() == timeKeeper2.GetDay()) m_timeLabel = timeKeeper.Format("%b %d"); else if (timeKeeper.GetMonth() == timeKeeper2.GetMonth()) - m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%d"); // TODO fix year 2 Feb 28-01 (always been the case) + m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%d"); else m_timeLabel = timeKeeper.Format("%b %d") + "-" + timeKeeper2.Format("%b %d");