簡體   English   中英

MSChart 控件中的自定義 X/Y 網格線

[英]Custom X/Y grid line in MSChart control

我有一個 C# windows 表格,帶有一個簡單的 2D 折線圖,我想在其中添加自定義 X 或 Y 軸標記,並繪制自定義網格線(以突出顯示的顏色,例如虛線)。 我查看了 customLabels 屬性,但這似乎覆蓋了我仍想顯示的默認網格。 這是為了說明閾值或截止值之類的東西。 如何使用 MSChart 控件執行此操作?

非常感謝

你能用帶狀線實現你想要的嗎?

在 ms 圖表示例中(在此處獲取http://archive.msdn.microsoft.com/mschart ),在“使用自定義標簽”部分中,它們在 Y 軸上使用帶狀線,這在突出顯示值范圍方面非常有效。 它們也不會影響網格...我通過稍微更改示例代碼檢查了這一點,這樣我就可以輕松地移動帶狀線的邊界(見下文)。

double low_med = 17; // was 30
double med_hi = 92;  // was 70

// Set Y axis custom labels
axisY.CustomLabels.Add(0, low_med, "Low");
axisY.CustomLabels.Add(low_med, med_hi, "Medium");
axisY.CustomLabels.Add(med_hi, 100, "High");

StripLine stripLow = new StripLine();
stripLow.IntervalOffset = 0;
stripLow.StripWidth = low_med;
stripLow.BackColor = Color.FromArgb(64, Color.Green);

StripLine stripMed = new StripLine();
stripMed.IntervalOffset = low_med;
stripMed.StripWidth = med_hi - low_med;
stripMed.BackColor = Color.FromArgb(64, Color.Orange);

StripLine stripHigh = new StripLine();
stripHigh.IntervalOffset = med_hi;
stripHigh.StripWidth = 100 - med_hi;
stripHigh.BackColor = Color.FromArgb(64, Color.Red);

axisY.StripLines.Add(stripLow);
axisY.StripLines.Add(stripMed);
axisY.StripLines.Add(stripHigh);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM