How to plot XY graph in C#? - c#

I am developing an application in C# which deals with specific genetic algorithm problem. The execution of the algorithm provides output parameters that are required to draw a chart.The graphic chart consists of 2 independent axis, lets say X is number of generation and Y represents corresponding maximum value of fitness function. To be more specific, I've uploaded picture from Excel so here it is :
http://img97.imageshack.us/img97/2046/graphnb.png
My priority is to make this application fully-functional by allowing user (who sets random execution factors such as mutation percentage, population and generation number, number of elite individuals, etc.) to see generated X-Y graph inside the generated "Form" in C#. I've found site that partially solves my problem, but that's not the whole point (http://csharp.net-informations.com/excel/csharp-excel-chart-picturebox.htm). So I'm asking if there is a way to implement mentioned graph by not using any other applications, but maybe only C# libraries and functions for plotting or something like that? Hope I made myself clear. Best regards.

Free and native answer is http://zedgraph.org/wiki/index.php?title=Main_Page
Does not involve WPF
Does not cost
Only C# libraries
Works inside a .NET WinForm

personally I like XtraChart of DeveloperExpress, but there are also many many other cheaper or more expensive alternatives, also other questions similar to yours here in SO: WPF chart controls
I like to use libraries whenever I can so I can focus on my real business case instead of trying to re-invent the wheel everytime, also because usually it's not trivial to reach the same level of results of people working hard to deliver specific components.

As all have said you have to work on WPF (different platform then WinForms) with 3rd party charting library that are much easier to integrate with your application.
If you want to know further about charting library then you should see this page
Click here

If you can use it, try WPF. It's much better for developing graphically rich user interfaces than standard Windows Forms -- especially if you don't want to use third-party libraries.

Related

Generating an Organogram in MVC and Displaying in View

I imagine this question will not bear anything, but this is a last ditch attempt before I have to tell my PM I simply can't do it.
My colleague (usefully before leaving the project) was a yes man to everything our PM asked for, regardless of what it was, and I seem to have been volunteered to create some functionality that will generate an Organogram / Organisational Chart and present it in the view.
I have dug around and asked around, no one really seems to know how I would go about doing this. Can anyone offer any advice on anything that can help? Even if it's the most basic tutorial or obscure API ever, it will be helpful.
To put a point on it, my question is: Is it possible to generate a chart in an ASP.NET MVC C# Application, and display it on a View? (Even a yes or no would help)
Yes, everything is possible. It's just a matter of how much time you can spend on it. Not everything has a good return on investment though, but that's for your PM to decide. As long as your team can make an estimation of the complexity.
But for ASP.NET, Microsoft has a Charting library that allows you to build charts. There are also commercial libraries (the first google hit) out there that are more feature rich.
And if they don't work, you can Always build images manually using the System.Drawing namespace of .NET (that will of course take considerably more time than plotting a chart using one of the available libraries). Generated images can be sent through an ashx handler, or you can embed the image in the same page using base64 encoding.
It's not bad to say yes to your PM, but I rather say: "Yes, we will stick this feature on the feature list / back log, and make a estimate of the complexity. Once we know the complexity you can choose to select it for a future iteration." But perhaps I'm talking too Agile now ;-)
You can hand off the chart drawing to an external library, for example, Google Visualization: Organizational Chart
Have a look at this question for other suggested librairies:
What's the best library to draw organization chart using JavaScript?
This sounds like it's in a commercial scenario, so it's really worth looking at the commercially available solutions. Steven already mentioned one, but as far as I can see that one is for Windows Forms and the other one is for charts as in bar charts and provides no organigram features.
A Javascript diagramming library with the capabilities of displaying organizational charts is yFiles for HTML. It has a nice online example of an organization chart that might be exactly what you are looking for:
There is also a Video that shows the demo in action.
The library is a pure Javascript implementation that does not depend on server libraries or servers at all. Integrating it in an ASP.net environment should be easy though, as long as you know Javascript. Being a library it offers full customization capabilities. You can determine the look and the feel of all aspects of the chart. Under the hood the library is a generic graph drawing and editing tool and the organizational chart is just one possible use-case.
Full disclosure: I work for the company that created the library, but on SO I do not represent my employer. My comments, thoughts, etc. are my own.

Visualize bipartite graph

Can someone recommend a library or code to visualize bipartite graphs in C#?
Graph# seems not to support this kind of graph directly (but has
some support to disentangle vertices).
I want to create some graphic like this bipartite graph with some text in the nodes. Nodes being same width and height would be ideal.
A WPF control would be perfect, as it exists for graph#.
Perhaps even a XAML definition exists?
As an alternativ: a report window can also be very good.
Probably someone with more experience in Graph# can provide hints on how to do this
utilizing Graph#.
Tried around a bit with NodeXL but that seems not to be the perfect solution,
as the nodes seems not be that much modifiable. Perhaps someone can provide
a better solution. Have played with the NetworkView provided by Soroush.
At the moment this comes closest to what I want.
-update-
Tried out NetworkView shared by Soroush Falahati. This seems to be a good base,
but is not yet that flexible as I need it. I have problems to believe that there
is no library out there that can do those things out of the box.
(NetworkView has the excellent feature to set connections / edges in the control
which gives it an extra boost over the NodeXL). Perhaps Graph# can do even more,
but at the moment I just have tried those two.
You can approximate your bipartite graph visualization in NodeXL, and even improve on it by removing edge crossings. I took your sample bipartite graph, and in the image below I colored the nodes by their side (u or v). They are laid out using the Sugiyama algorithm that minimizes edge crossings. I did this in the interactive NodeXL template for Excel 2007--2013, but all these features should be available as the standalone NodeXL C# and WPF class libraries. The current libraries as of this post are available to download here.
I also tried NodeXL's group-in-a-box layout to separate the groups and display them each individually in a grid, with marginal results.
Disclaimer: I'm an advisor for the NodeXL project.
Actually if you could use client side jquery .. iwoul strongly recommend jqPlumbs..
http://www.jsplumb.org/jquery/demo.html
Ok, As you want,
Here is an example/library that let you create graphs and flowcharts easily,
http://www.codeproject.com/Articles/182683/NetworkView-A-WPF-custom-control-for-visualizing-a
It has actually very good features.
yFiles WPF is an extensive .NET class library for Windows Presentation Foundation (WPF) applications.
Its first-class UI controls for viewing and editing diagrams allow you to automatically arrange complex graphs, diagrams, and networks with the click of a button.
Our diagramming library crafted for Windows Forms-based applications is yFiles.NET
Graph# is a graph layout framework.
It contains some layout algorithms and a GraphLayout control for WPF applications.
Using WPF to Visualize a Graph with Circular Dependencies
If you can do it in Windows Forms, you can use NShape. Since the source is available, you could probably port it to WPF if you needed to. It might beat writing it from scratch. Or perhaps you could host a WinForms control to get the functionality you need. Not as nice as a pure WPF solution, though.
D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation
D3 allows you to bind arbitrary data to a Document Object Model (DOM), and then apply data-driven transformations to the document. For example, you can use D3 to generate an HTML table from an array of numbers. Or, use the same data to create an interactive SVG bar chart with smooth transitions and interaction.
D3 is not a monolithic framework that seeks to provide every conceivable feature. Instead, D3 solves the crux of the problem: efficient manipulation of documents based on data. This avoids proprietary representation and affords extraordinary flexibility, exposing the full capabilities of web standards such as CSS3, HTML5 and SVG. With minimal overhead, D3 is extremely fast, supporting large datasets and dynamic behaviors for interaction and animation. D3’s functional style allows code reuse through a diverse collection of components and plugins.
http://d3js.org/
http://mbostock.github.com/d3/talk/20111116/force-collapsible.html

A route from vector drawing -> c# windows application

I have a requirement to present in my c# windows application a "map" of a building, with different rooms coloured in various ways to indicate various things. This needs to be renderable at different sizes and from different perspectives, and needs not to be a one off exercise, but a repeatable process for different establishments.
I am thinking of it in terms of an old school level editor (think old ID stuff), the product of which can be rendered top down; it sounds like an awful lot of work to get into designing my own editing tool, so am looking for a way to hook an existing tool into c#.
I have got the .NET drawing code down (if need be), and I have got the Adobe Illustrator design down (again, if need be) - what I am looking for is a way to link the two, or (if appropriate) a suggestion to use something different in those two roles entirely. Any and all suggestions very gratefully received, thank you!
I'd look at Microsoft Visio - it seems more appropriate for architectural/schematic diagrams than Illustrator and there should be already .NET libraries to use Visio-generated drawings.

Comparison between MS Charts and ZedGraph?

Question: Anybody has experience with ZedGraph / MS-Chart controls ?
I am thinking about which to use ?
Basically, I have a tendency to ZedGraph,
because I need .NET framework 2.0 while MS-Chart is 3.5 (and I don't know how well a 3.5 assembly works on 2.0)
and because I could use it privately, too (I use Linux privately).
But I don't know if MS-Charts offers more.
Does ZedGraph for example offer reasonable quality 3d piecharts ?
And reasonable color design, like gradient colors ?
And if it does, is it as simple (or nearly as simple) as MS-Chart controls ?
And does ZedGraph offer databinding, e.g. a datatable from a database ?
I've tried some examples in my free time.
With a bit of minor tweaking, ZedGraph's quality is just as good as MS/Dundas Chart controls.
Here's an example of a 3d piechart:
http://www.codeproject.com/KB/web-image/3dpiechart.aspx
Zedgraph is a bit more user-unfriendy than MS/Dundas chart controls.
However, Zedgraph is also more powerful and faster, while the rendering quality is the same.
Plus Zedgraph is cross-platform, while MS-Chart controls is limited to windows (by license, not by technique).
So the way to go is definitely Zedgraph.
A deeper reason can be found here:
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/1271d98f-f52e-424d-a0dc-8bc831a5f4b8
I have used MSCharts since they went RTM and have been pleased with them for many different kinds of charts; however, I find them deficient when I want to generate a plot or a graph. For these, ZedGraph seems to offer a more appealing solution.
The MSChart Samples environment can give you a good idea of the capabilities of that library. You can compare the samples environment to the demos from the ZedGraph wiki to see they have a lot of overlapping capability. I've just found that this kind of chart is pretty difficult to create with MSChart.
I have used them to create complex dashboards, and they are very stable, well written pieces of code. However, you have to consider the fact that whichever you would be betting on, would actually be there for a long time.
Additionally, if you're using MSCharts, you would be able to use the same knowledge to build charts for web applications as well (on ASP.net)
However, if you are using them in a server ASP.net based environment, the only issue with MSCharts is that they are not dynamic charts i.e. they are rendered as images and returned from the server. They use image maps to support HyperLinks / Tooltips, and work pretty well.
I haven't used MSChart, but from my experience with ZedGraph, you can't make 3-d charts. ZedGraph also requires a bit of tweaking to make really sharp looking graphs (if you notice, most of their examples don't qualify for this title).

Charting Components

im looking for a charting class library like Nevron or DevExpress that can handle with very big datasets (2 Millions points per second for example) are there better or more powerful Components? I need a few components to compare it among each other.
thanks
Did you checked the MS build in Charting Solution?
http://weblogs.asp.net/scottgu/archive/2010/02/07/built-in-charting-controls-vs-2010-and-net-4-series.aspx
It is for Winforms and ASP.net and as far as I remember there are plans to implement WPF support (<- but not sure)...
Download here: http://www.microsoft.com/downloads/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&DisplayLang=en
Documentation here: http://www.microsoft.com/downloads/details.aspx?FamilyId=EE8F6F35-B087-4324-9DBA-6DD5E844FD9F
You cannot physically show more than 300-1200 pixels/inch on a printer and a lot less on a display.
Take those 2 million points and summarise every group of 1000-odd points (via mean, median, mode, maximum or minimum...), so that you end up with 2000 'summarised' points (this would be quick and easy to code). Charting 2000 summarised points makes much more sense for on-screen charting. Use a summary range of 100-500 points, if it will be printed (depending on printer DPI capability and chart size).
Internally, this is what most charting components will have to do, in any case.
Unfortunately it is not that simple - when you "summarize" the points using average for example you'll loose spikes in the data. It also depends on the series being plotted - it is one thing to summarize in a line chart with ascending x values and completely different thing when you summarize a xy scatter point chart. It also depends whether the user has zoomed the chart etc. so a professional charting library will have to take the level of detail (zoom factor), data spikes and series type into account.
In addition some charting libraries will use a direct interface to the video board (like OpenGL or DirectX) which is must faster than when you draw using GDI+ for example. I think you 're going in the right direction as the above two libraries are some of the best out there.

Categories