使用什么数据可视化控件在 LINQPad 中呈现结果?

发布于 11-14 18:43 字数 126 浏览 7 评论 0原文

使用什么数据可视化控件在 LINQPad 中呈现结果?或者是否有其他方法可以在 .NET 中显示分层数据?

What data visualization control is used to present the results in LINQPad? Or is there any alternative for showing hierarchical data in .NET?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

時窥2024-11-21 18:43:03

LINQPad 使用 WebBrowser 控件来动态显示生成的 HTML 页面。您甚至可以通过右键单击结果窗口来查看其源代码。所以它基本上是 Internet Explorer 的包装。就 HTML 的生成而言,它使用自定义构建的 XhtmlFormatter 来访问对象图并基于 XDocument 发出 XHTML。

LINQPad uses a WebBrowser control to display a dynamically generated HTML page. You can even view its source code by right clicking on the results window. So it's basically a wrapper around Internet Explorer. As far as the generation of the HTML is concerned it uses a custom built XhtmlFormatter to visit the object graph and emit XHTML based on XDocument.

ぶ宁プ宁ぶ2024-11-21 18:43:03

LINQPad 还可以调用 Windows 窗体附带的所有旧 Dundas 图表控件。只需转储任何 Bitmap 对象,LINQPad 就会尽职尽责地将其显示在 HTML 中。尝试以下操作,确保您有 System.DrawingSystem.Windows.FormsSystem.Windows.Forms.DataVisualization,您的F4引用,粘贴并点击F5。它还适用于更高级别的 SHO 图表,这些图表是为 IronPython 定制的,但效果很好来自 C#。

// Almost the smallest meaningful example of Charting
void Main()
{
    // Chart must have a chart area, but it's not externally referenced later
    var chartArea1 = new ChartArea();
    var chart1 = new Chart();
    chart1.ChartAreas.Add(chartArea1);

    var series1 = new Series();

    // The following goes beyond the minimal, but just a little. You can delete these two lines.
    // Fun to set the series ChartType; default is column chart
    series1.ChartType = SeriesChartType.Pie;
    series1.CustomProperties = "LabelsRadialLineSize=1, PieDrawingStyle=Concave, LabelStyle=outside";

    var r = new Random(Guid.NewGuid().GetHashCode());
    var ys = Enumerable.Range(0, 5).Select (e => r.NextDouble()).Dump("Doubles");
    var xs = Enumerable.Range(0, 5).Select (e => GetRandomString(3).ToUpper()).Dump("Strings");
    series1.Points.DataBindXY(xs.ToArray(), ys.ToArray());
    chart1.Series.Add(series1);

    var b = new Bitmap(width: chart1.Width, height: chart1.Height);
    chart1.DrawToBitmap(b, chart1.Bounds);
    b.Dump();

    var frm = new Form();
    // Seems 300 x 300 is the default chart-area size and chart size, so set the form to hold it
    frm.ClientSize = new Size(width: 300, height: 300);
    frm.Controls.Add(chart1);

    Application.Run(frm);
}

static IEnumerable<string> CharRange(Char c, int length)
{
    return (from e in Enumerable.Range(Convert.ToInt32(c), length)
            select Char.ConvertFromUtf32(e));
}

static string GetRandomString(int length)
{
    var sb = new StringBuilder();
    do
        sb.Append(Path.GetRandomFileName().Replace(".", "").Substring(0, length < 11 ? length : 11));
    while ((length -= 11) > 0);
    return sb.ToString();
}

LINQPad can also call all the old Dundas charting controls that come with Windows Forms. Just dump any Bitmap object and LINQPad dutifully displays it in the HTML. Try out the following, making sure you have System.Drawing, System.Windows.Forms, and System.Windows.Forms.DataVisualization, in your F4 references, paste and hit F5. It also works with the higher-level SHO charts, which have been tailored for IronPython, but work great from C#.

// Almost the smallest meaningful example of Charting
void Main()
{
    // Chart must have a chart area, but it's not externally referenced later
    var chartArea1 = new ChartArea();
    var chart1 = new Chart();
    chart1.ChartAreas.Add(chartArea1);

    var series1 = new Series();

    // The following goes beyond the minimal, but just a little. You can delete these two lines.
    // Fun to set the series ChartType; default is column chart
    series1.ChartType = SeriesChartType.Pie;
    series1.CustomProperties = "LabelsRadialLineSize=1, PieDrawingStyle=Concave, LabelStyle=outside";

    var r = new Random(Guid.NewGuid().GetHashCode());
    var ys = Enumerable.Range(0, 5).Select (e => r.NextDouble()).Dump("Doubles");
    var xs = Enumerable.Range(0, 5).Select (e => GetRandomString(3).ToUpper()).Dump("Strings");
    series1.Points.DataBindXY(xs.ToArray(), ys.ToArray());
    chart1.Series.Add(series1);

    var b = new Bitmap(width: chart1.Width, height: chart1.Height);
    chart1.DrawToBitmap(b, chart1.Bounds);
    b.Dump();

    var frm = new Form();
    // Seems 300 x 300 is the default chart-area size and chart size, so set the form to hold it
    frm.ClientSize = new Size(width: 300, height: 300);
    frm.Controls.Add(chart1);

    Application.Run(frm);
}

static IEnumerable<string> CharRange(Char c, int length)
{
    return (from e in Enumerable.Range(Convert.ToInt32(c), length)
            select Char.ConvertFromUtf32(e));
}

static string GetRandomString(int length)
{
    var sb = new StringBuilder();
    do
        sb.Append(Path.GetRandomFileName().Replace(".", "").Substring(0, length < 11 ? length : 11));
    while ((length -= 11) > 0);
    return sb.ToString();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文