C# dashed lines in chart series?

不羁岁月 提交于 2019-12-10 01:00:38

问题


I'm using the Chart control from .net 4.0 in my C# WinForms app. I have two series' of data displayed as line graphs.

I'm graphing basically a supply and demand as a function of time. I want the demand to be a solid line of some colour, and the supply to be a dashed line of the same colour.

I can set the colour fine, but I can't find anywhere where I can set the line style to be dashed.


回答1:


See the DataPointCustomProperties.BorderDashStyle property. For example...

_chart.Series[1].Color = Color.Blue;

_chart.Series[0].Color = Color.Blue;
_chart.Series[0].BorderWidth = 3;
_chart.Series[0].BorderDashStyle = ChartDashStyle.Dash;

...gives me:




回答2:


This changes slightly with Visual Studio 2010's version of chart control:

this.chart1.Series["Data1"].BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;



来源:https://stackoverflow.com/questions/5011421/c-sharp-dashed-lines-in-chart-series

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!