[SCOTTPLOT/WINFORM] BarPlot 클래스 : ValueFormatter 속성을 사용해 커스텀 값 표시하기
ScottPlot/WinForm 2022. 2. 2. 00:46728x90
728x170
▶ MainForm.cs
using System;
using System.Windows.Forms;
using ScottPlot;
using ScottPlot.Plottable;
namespace TestProject
{
/// <summary>
/// 메인 폼
/// </summary>
public partial class MainForm : Form
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainForm()
/// <summary>
/// 생성자
/// </summary>
public MainForm()
{
InitializeComponent();
Plot plot = new Plot(800, 600);
Func<double, string> formatValueFunction = y => $"Y={y:N2}";
double[] valueArray = { 27.3, 23.1, 21.2, 16.1, 6.4, 19.2, 18.7, 17.3, 20.3, 13.1 };
BarPlot barPlot = plot.AddBar(valueArray);
barPlot.ShowValuesAboveBars = true;
barPlot.ValueFormatter = formatValueFunction;
plot.SetAxisLimits(yMin : 0);
this.formsPlot.Reset(plot);
this.formsPlot.Refresh();
}
#endregion
}
}
728x90
그리드형(광고전용)