简体   繁体   中英

I can't get the correct value for the size of my stripline

I am currently working on a module to create charts to display data. I use System.Windows.Forms.DataVisualization.Charting.Chart .

I have two striplines and even though I give them the same value for the StripWidth parameter:

Here we have MaxY at 6000, average at 2300 and threshold at 2500

// We can't use a fixed size because if the y axis is too high or too small it may look too big or too small
this.chart1.ChartAreas[0].Axes[1].StripLines[0].StripWidth = maxY / 100;
this.chart1.ChartAreas[0].Axes[1].StripLines[1].StripWidth = maxY / 100;

// add the striplines 
this.chart1.ChartAreas[0].Axes[1].StripLines[0].Interval = 0;
this.chart1.ChartAreas[0].Axes[1].StripLines[1].Interval = 0;

this.chart1.ChartAreas[0].Axes[1].StripLines[0].IntervalOffset = average;
this.chart1.ChartAreas[0].Axes[1].StripLines[1].IntervalOffset = threshold;

They often end up with different size, it's subtle but I can see it and I don't understand why it's happening.

例

This is just an optical illusion : The screenshot shows two lines with the same width of 3 pixels!

The darker, green one looks a little tighter but when you count the pixels you will see they are the same:

在此处输入图片说明

To avoid the effect I suggest giving them a color with the same brightness !

Also note that due to rounding you may always get a non-perfect sub-pixel anti-aliasing effect.

Finally (and most important) : In the screenshot the gridline adds to the illusion . Once again: To avoid this make sure the gridline and the striplines have more dictinct brightness values!

Checking in photoshop: In the screenshot you have the first stripline with brightness=109 , the gridline brightness=100 , which is basically the same, so they merge, taking the width from 3 to 4 pixels. But the second stripline has a brightness=50 . This leads to a perceived extra width of 33% which is noticeable.

Note that the gridline colors can be as easily set as the stripline colors..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM