![](/img/trans.png)
[英]StructureMap to create a Configuration object in c# winforms
[英]C# WinForms Charts configuration
我正在嘗試在C#WinForms條形圖中繪制文件的字節數。 這樣,X軸的值將為0-255(如果大於零),而Y軸將根據文件的長度和字節分布而變化。 代碼如下:
for (int i = 0; i < byteDistribution.Count; i++)
{
if (byteDistribution[i] > 0)
{
Series series = new Series(i.ToString());
series.Points.AddXY(i, byteDistribution[i]);
// PointWidth has no affect?
series.SetCustomProperty("PointWidth", "1");
this.crtBytes.Series.Add(series);
}
問題:
為了消除差距:
series["PointWidth"] = "1";
要刪除網格線:
chartArea.AxisX.MajorGrid = new FChart.Grid {Enabled = false};
chartArea.AxisY.MajorGrid = new FChart.Grid { Enabled = false };
更新:
我認為您的問題是您為每個數據點創建了一個新系列。 這樣您還可以獲得“色彩效果”。 只需創建一個系列,將其添加到圖表區域,然后將所有數據點添加到該系列。
Series series = new Series();
this.crtBytes.Series.Add(series);
series.SetCustomProperty("PointWidth", "1");
for (int i = 0; i < byteDistribution.Count; i++)
{
if (byteDistribution[i] > 0)
{
series.Points.AddXY(i, byteDistribution[i]);
// PointWidth has no affect?
}
}
PointWidth
屬性是一個相對值,請嘗試類似series["PointWidth"] = 1.25
。
黑線稱為MajorGrid,使用chartArea.MajorGrid.Enabled = False
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.