Linqpad扩展到绘图

时间:2017-01-03 15:04:25

标签: linqpad

我试图在Linqpad中使用" Util.RawHtml()"绘制一些图形。和"转储()"但它不能与amcharts.com的example一起使用。我创建了一个包含所有HTML源代码的字符串变量,但结果不起作用。

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

Util.RawHtml(html).Dump();

3 个答案:

答案 0 :(得分:4)

LinqPad 5的更高版本现在支持使用Util.Chart开箱即用进行图表绘制。您可以在{p>下的Samples标签(My Queries附近)中查看示例。

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

以下脚本为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();

答案 1 :(得分:0)

据我了解,这不起作用,因为html包含不会执行的脚本。

作为替代方案,您仍然可以使用旧的(并且已弃用)google chart api,例如

var link = @"http://chart.apis.google.com/chart?chxt=y&chbh=a&chs=300x225&cht=bvg&chco=A2C180,3D7930&chd=t:10,20,30,40,50,60|30,35,40,45,55,60&chtt=Sample";

Util.Image (link).Dump();

或者看 http://blog.divebomb.org/2012/11/dumping-charts-in-linqpad/

答案 2 :(得分:0)

不确定这是否是您所追求的答案,但在Linqpad中查看DisplayWebPage类的Util方法可能很有价值。这在结果窗口中正确呈现了您的图表(尽管存在脚本错误)。显然,这可能无法解决您的潜在问题。

我使用版本5.10.00来测试它。