Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linqpad extension to plot graphs

Tags:

linqpad

I tried to plot some graphs in Linqpad with with "Util.RawHtml()" and "Dump()" but it is not working with this example from amcharts.com. I created a string variable including all the HTML source code but the result is not working.

string html = "";
using (System.Net.WebClient client = new System.Net.WebClient ())
{
    html = client.DownloadString(@"http://pastebin.com/raw/pmMMwXhm");
}

Util.RawHtml(html).Dump();
like image 598
user2011909 Avatar asked Sep 05 '25 03:09

user2011909


1 Answers

Later versions of LinqPad 5 now support charting out of the box with Util.Chart. You can see the samples in the Samples Tab (next to My Queries) under

  • LINQPad Tutorial&Reference
    • Scratchpad Features
      • Charting with Chart

The following script is the Chart() - dual scale sample:

// Each y-series can have a different series type, and can be assigned to the secondary y-axis scale on the right.

var customers = new[]
{
    new { Name = "John", TotalOrders = 1000, PendingOrders = 50, CanceledOrders = 20 },
    new { Name = "Mary", TotalOrders = 1300, PendingOrders = 70, CanceledOrders = 25 },
    new { Name = "Sara", TotalOrders = 1400, PendingOrders = 60, CanceledOrders = 17 },
};

customers.Chart (c => c.Name)
    .AddYSeries (c => c.TotalOrders,    Util.SeriesType.Spline, "Total")
    .AddYSeries (c => c.PendingOrders,  Util.SeriesType.Column, "Pending",   useSecondaryYAxis:true)
    .AddYSeries (c => c.CanceledOrders, Util.SeriesType.Column, "Cancelled", useSecondaryYAxis:true)
    .Dump();
like image 165
mbx Avatar answered Sep 07 '25 23:09

mbx