DateTimeTickUnits: The X-axis of `DateTime` mixture 24-hour and 12-hour notation.
See original GitHub issueScottPlot Version: 4.1.58.0
Operating System: Windows10
Application Type: WinForms
Question: The X-axis of DateTime mixture 24-hour and 12-hour notation.
Zoom in on a graph displaying DateTime
data on the X-axis with the mouse wheel or right-click.
In this case, the 24-hour and 12-hour displays show different times, depending on whether they zoom to the nearest second or include milliseconds.
It appears that 24-hour notation is used for zooms that display up to seconds, and 12-hour notation is used for zooms that also display milliseconds.
Is this as expected?
pattern | Actual output | comment |
---|---|---|
(A) Zooms that display up to seconds. | 1985/09/23 23:59:59 |
As expected. |
(B) Zooms that also display milliseconds. | 1985/09/23 11:59:59.5 |
The time format expects 23:59:59.5 . |
Maybe HH
is correct in (B) instead of hh
?
The reproduced code is as follows:
<div>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ExecuteRecipe(formsPlot1.Plot);
}
private void ExecuteRecipe(Plot plt)
{
// original source: https://github.com/ScottPlot/ScottPlot/blob/07ab190973cbf8697ff8bdc98b4e6475ce40ea03/src/ScottPlot4/ScottPlot.Cookbook/Recipes/Axis.cs#L208-L222
// create data sample data
var myDates = new DateTime[1000]; // Change: 100 --> 1000
for (var i = 0; i < myDates.Length; i++)
myDates[i] = new DateTime(1985, 9, 24).AddMinutes(10 * i); // Change: .AddDays(7 * i) --> .AddMinutes(10 * i)
// Convert DateTime[] to double[] before plotting
var xs = myDates.Select(x => x.ToOADate()).ToArray();
var ys = DataGen.RandomWalk(myDates.Length);
plt.AddScatter(xs, ys);
// Then tell the axis to display tick labels using a time format
plt.XAxis.DateTimeFormat(true);
}
}
</div>
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to convert 24 hour clock to 12 hour clock in dataframe ...
On the x-axis I want to just have time on the 12-hour clock (so using the graph ... import datetime as dt d...
Read more >How to convert character date time if time mixed between ...
I don't think that is necessary though. The 12-hour solution seems to be working just fine, but the 24-hour format must still be...
Read more >Time cannot be set to 24 hour format in Continuous X Axis
Yes by using text format time value, we can show them in 12h or 24h as we want. But in this case the...
Read more >Time question in 12 hour format in feature report
In my survey I have work start and work end Time questions. In my feature report, they display in a 24 hour format....
Read more >Time formatting for charts | Looker
Format Type Description Use This Expression
Time Milliseconds as a decimal number, i.e. 000 to 999 %L
Time Second as a two‑digit number, i.e. 00...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually have a better option, we can check if the configured locale uses 24 hour time and swap out
hh
forHH
. Otherwise we leave it as is. It’s a hack, but it’s not as breaking (or broken) a breaking change.Sorry for the late reply.
Yeah, you are right. I was a bit shallow in my thinking.
Thank you for creating the PR.