您绝对应该学习使用 WPF,但是可以使用 winforms 标准控件实现迷你图。如果我错了,请纠正我,但迷你图是一个简单的折线图。
查看图表控件的文档。您应该设置ChartType
为SeriesChartType.Spline
绘制迷你图。
示例:实现与链接的博文中类似的外观
var series = new Series("First")
{
ChartType = SeriesChartType.Spline, //line chart
ChartArea = "chartArea",
Color = Color.White
};
//generating data
var random = new Random();
for (int i = 0; i < 50; i++)
{
//random values
series.Points.AddXY(i, random.Next(100));
}
//creating display area
var chartArea = new ChartArea("chartArea")
{
//hiding grid lines
AxisX =
{
LineWidth = 0,
IntervalType = DateTimeIntervalType.NotSet,
LabelStyle = {Enabled = false},
MajorGrid = {LineWidth = 0},
MajorTickMark = {LineWidth = 0}
},
AxisY =
{
LineWidth = 0,
LabelStyle = {Enabled = false},
MajorGrid = {LineWidth = 0},
MajorTickMark = {LineWidth = 0}
},
BackColor = Color.Black
};
//creating chart control
var chart = new Chart {Dock = DockStyle.Fill, BackColor = Color.Black};
chart.ChartAreas.Add(chartArea);
chart.Series.Add(series);
//add chart control to form
Controls.Add(chart);
结果是: