You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using LocalDates for the X-Axis, the dates plotted are incorrect. The error is in the DateArraySeriesModel class.
The method: private static double[] toXSeriesArray(LocalDate[] dates, ZoneOffset zoneOffset) returns wrong dates as the conversion from LocalDate[]->Date[]-> double[] incorrectly uses the LocalDates conversion.
Here is the corrected code with commented-out printlns to show the correction.
/**
*
* @param dates
* @param zoneOffset
* @return double[] of dates
*/
private static double[] toXSeriesArray(LocalDate[] dates, ZoneOffset zoneOffset) {
double[] xSeries = new double[dates.length];
for(int i = 0; i < xSeries.length; i++) {
/*
System.out.println("DateArraySeriesModel- date (original data) = " + dates[i]);
// original code
xSeries[i] = dates[i].atStartOfDay().toEpochSecond(zoneOffset);
System.out.println("DateArraySeriesModel- LocalDate (wrong) = " +
new Date((long) (xSeries[i])).toString());
*/
// corrected code
// Date date = Date.from(dates[i].atStartOfDay(ZoneId.systemDefault()).toInstant());
Date date = Date.from(dates[i].atStartOfDay(zoneOffset).toInstant());
xSeries[i] = (double)(date.getTime());
/*
System.out.println("DateArraySeriesModel- LocalDate (corrected) = " +
new Date((long) (xSeries[i])).toString());
*/
}
return xSeries;
}
The text was updated successfully, but these errors were encountered:
Dear Mr. Wenig,
I’ve been trying to get git to work on my computer but continue to get error messages. I was hoping that someone who is working on swtChart can incorporate my fix as part of other work that is ongoing.
Thank you for creating swtChart.
Glen Zoerner
Spicewood Texas
From: Philip Wenig ***@***.***>
Sent: Tuesday, February 11, 2025 12:57 AM
To: eclipse/swtchart ***@***.***>
Cc: gzoerner ***@***.***>; Author ***@***.***>
Subject: Re: [eclipse/swtchart] X-Axis LocalDate labels have wrong dates (Issue #445)
Nice catch. Could you please create a Pull Request?
—
Reply to this email directly, view it on GitHub <#445 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AOKLUAE36IHYVMAVKJDUHAL2PGNLLAVCNFSM6AAAAABW27GOAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBZHE3DOMJYGU> .
You are receiving this because you authored the thread.Message ID: ***@***.***>
When using LocalDates for the X-Axis, the dates plotted are incorrect. The error is in the DateArraySeriesModel class.
The method: private static double[] toXSeriesArray(LocalDate[] dates, ZoneOffset zoneOffset) returns wrong dates as the conversion from LocalDate[]->Date[]-> double[] incorrectly uses the LocalDates conversion.
Here is the corrected code with commented-out printlns to show the correction.
The text was updated successfully, but these errors were encountered: