[英]How to show the marker points in line graph using c#
我在我的应用程序中使用Line graph
并且工作正常。 我试图在折线图中绘制标记点,但标记点没有显示。 在折线图标记属性中,我选择了markerSize
为5, markerStyle
为Circle, MarkerColor
为blue。请在下面输入我的代码。
series1.Name = "Series1";
series1.IsVisibleInLegend = false;
series1.IsXValueIndexed = true;
series1.XValueType = ChartValueType.Time;
series1.YAxisType = AxisType.Primary;
series1.ChartType = SeriesChartType.Line;
this.chart1.Series.Add(series1);
我没有看到Markers
如何从您的代码中显示出来。
您需要设置非默认的 MarkerStyle
:
series1.MarkerStyle = MarkerStyle.Circle;
如果在该行上使用调试器 ,则可以看到默认值为None
!
当然,您将希望使用所有其他标记关联系列属性 ,这些属性都继承自DataPointCustomProperties
您正在使用ChartType.Line
,这很好。 请注意, FastLine
不显示标记!
如果您只想显示一些标记,只需为每个点设置样式:
S1.Points[8].MarkerStyle = MarkerStyle.Triangle;
S1.Points[8].MarkerSize = 22;
S1.Points[8].MarkerColor = Color.Red;
我建议你获得每个点,循环遍历它们并添加每个点。 我注意到你想设置一个名字,所以我只是创建了一个计数器,然后将一个整数值附加到'ser'的末尾,命名如何。
Dim counter as int = 0;
foreach (Series ser in chart.Series)
{
ser.Name = "ser" & counter + 1;
ser.IsVisibleInLegend = false;
ser.IsXValueIndexed = true;
ser.XValueType = ChartValueType.Time;
ser.YAxisType = AxisType.Primary;
ser.ChartType = SeriesChartType.Line;
this.chart1.Series.Add(ser);
counter += 1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.