Question

Currently what I am trying to achieve is to create a graph within LINQPad from a SQL Datasource.

I believe it is possible to do, however I am not 100% sure on how exactly to do it.

Does anyone have any ideas on a method to do this? (Even if it includes using NuGet packages, I don't mind)

Was it helpful?

Solution 2

Edit: charting is now a built-in feature in LINQPad. See this answer.

Yes, you can use any NuGet charting library, or the built-in Windows Forms library in System.Windows.Forms.DataVisualization.Charting. Simply call Dump on the chart control after creating it, such as in this example.

Another option is to use the Google Chart API:

Util.Image ("http://chart.apis.google.com/chart?cht=p3&chd=s:Uf9a&chs=350x140&chl=January|February|March|April").Dump();

with this result:

enter image description here

OTHER TIPS

Linqpad 5.31 comes with internal Chart extension.

var customers = new[]
{
    new { Name = "John", TotalOrders = 100 },
    new { Name = "Mary", TotalOrders = 130 },
    new { Name = "Sara", TotalOrders = 140 },
    new { Name = "Paul", TotalOrders = 125 },
};

customers.Chart (c => c.Name, c => c.TotalOrders).Dump(); 

enter image description here

For more examples, click LINQPad's Samples tab (bottom left), LINQPad Tutorial and Reference > Scratchpad features > Charting with Chart()

The LINQPad output window is HTML based, so you could use Util.RawHTML("<div>your HTML here...</div>").Dump();, though it would be quite tedious to include a HTML graph this way.

The best place to ask this question and seek an answer would be on the LINQPad Forum.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top