在MSChart控件自定义X / Y网格线 [英] Custom X/Y grid line in MSChart control

查看:1251
本文介绍了在MSChart控件自定义X / Y网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#窗户,我想添加自定义的X或Y轴标记物,并绘制一个自定义的网格线(在高亮显示的颜色,点线为例)一个简单的二维线条图的形式。我已经看过了customLabels属性,但是这似乎覆盖默认的网格,这是我还是想显示。这是为了示出类似的阈值或截止。我怎样才能做到这一点与MSChart控制?

I have a C# windows form with a simple 2D line chart that I want to add custom X or Y axis markers to, and draw a custom grid line (in a highlighted color, dotted line for example). I have looked at the customLabels property, but this seems to override the default grid, which I still want to display. This is to illustrate something like a threshold or a cutoff. How can I do this with the MSChart control?

感谢

推荐答案

你能达到你想要的带状线?

Could you achieve what you want with striplines?

在MS图表样本(在这里获得 http://archive.msdn.microsoft.com/mschart 的),则使用自定义标签部分内,它们使用,它们在突出数值范围相当有效在Y轴上带状线。他们也不会影响电网...我检查,通过改变样品codea的一点,所以我可以很容易地将带状线的边界周围的(见下文)。

In the ms chart samples (get it here http://archive.msdn.microsoft.com/mschart), inside the "Using Custom Labels" section, they use striplines on the Y axis which are quite effective at highlighting ranges of values. They also do not affect the grid ... I checked that by changing the sample code a little so I could easily move the boundaries of the striplines around (see below).

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);

这篇关于在MSChart控件自定义X / Y网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆