text 在LinqPad中快速简单地帮助渲染字符
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 在LinqPad中快速简单地帮助渲染字符相关的知识,希望对你有一定的参考价值。
<Query Kind="Program">
<Reference><RuntimeDirectory>\System.Windows.Forms.DataVisualization.dll</Reference>
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference>
<Namespace>System.Windows.Forms.DataVisualization.Charting</Namespace>
<Namespace>System.Drawing</Namespace>
<Namespace>System.Windows.Forms</Namespace>
</Query>
void Main()
{
new LpChart(series: GetSeries(), chartType: SeriesChartType.Column, width: 1250).Dump();
new LpChart(series: GetSeries(), chartType: SeriesChartType.Line, width: 1250).Dump();
new LpChart(series: GetSeries(), chartType: SeriesChartType.Bar, width: 500).Dump();
}
private ChartSeries GetSeries()
{
var items = Enumerable.Range(1, 25).Select(x => string.Format("item-{0}", x));
var rand = new Random(100);
var prices = items.Select(x => rand.NextDouble());
return new ChartSeries { XSeries = items.ToList(), YSeries = prices.ToList() };
}
public class ChartSeries
{
public IList<string> XSeries { get; set; }
public IList<double> YSeries { get; set; }
}
public class LpChart
{
public Chart Chart { get; private set; }
public ChartArea ChartArea { get; private set; }
public Series Series { get; private set; }
public Bitmap Bitmap { get; private set; }
public LpChart(ChartSeries series, SeriesChartType chartType = SeriesChartType.Column, int width = 1200)
{
this.Chart = new Chart();
this.ChartArea = new ChartArea();
this.Chart.ChartAreas.Add(this.ChartArea);
this.Series = new Series();
this.Series.ChartType = chartType;
this.Series.Points.DataBindXY(series.XSeries.ToArray(), series.YSeries.ToArray());
this.Chart.Series.Add(this.Series);
this.Chart.Width = width;
this.Bitmap = new Bitmap(width: this.Chart.Width, height: this.Chart.Height);
}
public void Dump()
{
this.Chart.DrawToBitmap(this.Bitmap, this.Chart.Bounds);
this.Bitmap.Dump();
}
}
以上是关于text 在LinqPad中快速简单地帮助渲染字符的主要内容,如果未能解决你的问题,请参考以下文章
有没有人使用 LINQPad 连接到 Tridion 核心服务?
LINQPad,使用多个datacontexts
ASP.NET EF 使用LinqPad 快速学习Linq
在LINQPad中使用FreeSql查询数据库
使用内置 Linq to SQL 驱动程序在 LinqPad 中运行 Entity Framework Core 查询的更简单方法?
React Native:你能根据字符串的存在有条件地渲染 JSX 吗?