Click here to Skip to main content
15,608,738 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two arrays. One of them contains DateTime and the other contains double. Is there a way to make a graph displayed from those data on an x and y axis?

Preferably the scale is automatic and the data is easy to visualize.

Thanks all!

What I have tried:

I have the two arrays, probably around a size of 100,000 each but I want to plot the values with the x axis being DateTime
Updated 30-Sep-21 16:43pm
Gerry Schmitz 30-Sep-21 18:49pm    
Line graphs uses a series of x and y data points; you'll have to in effect "join" your 2 arrays to come up with a series of data points when it comes to loading the chart.
PIEBALDconsult 30-Sep-21 22:13pm    
Write to a CSV file. Open in Excel. Create graph. Done.

Depends on the environment you want to run in.
For Winforms, I use the MS Chart control: Getting Started with Windows Forms Chart control | Syncfusion[^] may help.
Share this answer
Admin BTA 2-Oct-21 3:48am    
My app is a console app. Some suggested outputting to a file and then using Excel, which may be easiest. I just thought there might be an easy one or two lines that would automatically create a chart from the code, where the user could stretch, zoom, and otherwise interact with the chart. Thanks!
OriginalGriff 2-Oct-21 4:11am    
Console apps are text based, nothing else.
You want to display a chart ion a console app? Bad idea, and you are going to be looking at a reasonable amount of work that nobody really does any more - and certainly not in C#! That kind of thing died with C on early monitors that didn't support a graphics mode, and is just not a good idea for a modern app where doing it for windows is almost trivial in comparison!
Admin BTA 2-Oct-21 8:23am    
i appreciate your reply. i didnt mean building it from scratch in console. i like console apps because they are computationally efficient. is it not possible to add a using statement to use winforms in a console app?
OriginalGriff 2-Oct-21 8:30am    
Why would you bother?
They are fundamentally different: a console app is procedural, you the developer decide what is going to happen and when, and the user has little or no affect other then to type when he is told to.
Windows apps are different: the user is in control, and he decides what happens when by telling you when he is ready to do something by clicking buttons and so on - he can type in input boxes at any time.

Windows apps do that via message loops: they sit processing messages from a huge number of sources and running small bits of code as a result. Adding all that to a Console app is difficult and won't work when you start asking the user for input again!
Seriously: if you want a GUI, then use a GUI application!
Admin BTA 2-Oct-21 9:37am    
So youre staying create a winforms app not a console app, is that correct? Are there built-in classes in Visual Studio for charts? The link you sent appears to be a third party thing?
already find the solution?

For Winforms, I use the MS Chart control: Getting Started with Windows Forms Chart control | Syncfusion[^] may help.
Share this answer
Richard Deeming 4-Oct-21 6:08am    
Copying a line of text from someone else's solution and posting it as a "new" solution is called plagiarism. We do not tolerate plagiarism here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900