获取图表系列的颜色
Get color of a chart series
我需要获取由智能标签设置的系列的颜色,我想使 DGV 中的单元格具有相同的颜色。
Dim chtColor(50) As Color
For Each Cur In MCurves
PTang = EstCurve(Cur, BladeAngle, HRfan)
Me.ChtCurves.Series.Add(Cur.ToString)
Me.ChtCurves.Series(Cur.ToString).ChartType = DataVisualization.Charting.SeriesChartType.Spline
Me.ChtCurves.ChartAreas(0).AxisX.LabelStyle.Format = "#.###"
chtColor(i) = Me.ChtCurves.Series(Cur.ToString).Color
函数 Me.ChtCurves.Series(Cur.ToString).Color
返回颜色列表而不是系列颜色。
如果您没有明确设置系列颜色并且想要检索默认分配的颜色,则必须调用 Chart.ApplyPaletteColors()
。
修改代码以在将系列添加到图表的系列集合后调用此方法
Me.ChtCurves.Series.Add(Cur.ToString)
Me.ChtCurves.Series(Cur.ToString).ChartType = DataVisualization.Charting.SeriesChartType.Spline
Me.ChtCurves.ChartAreas(0).AxisX.LabelStyle.Format = "#.###"
Me.ChtCurves.ApplyPaletteColors() ' this will allow you to retrieve the default color
chtColor(i) = Me.ChtCurves.Series(Cur.ToString).Color
我需要获取由智能标签设置的系列的颜色,我想使 DGV 中的单元格具有相同的颜色。
Dim chtColor(50) As Color
For Each Cur In MCurves
PTang = EstCurve(Cur, BladeAngle, HRfan)
Me.ChtCurves.Series.Add(Cur.ToString)
Me.ChtCurves.Series(Cur.ToString).ChartType = DataVisualization.Charting.SeriesChartType.Spline
Me.ChtCurves.ChartAreas(0).AxisX.LabelStyle.Format = "#.###"
chtColor(i) = Me.ChtCurves.Series(Cur.ToString).Color
函数 Me.ChtCurves.Series(Cur.ToString).Color
返回颜色列表而不是系列颜色。
如果您没有明确设置系列颜色并且想要检索默认分配的颜色,则必须调用 Chart.ApplyPaletteColors()
。
修改代码以在将系列添加到图表的系列集合后调用此方法
Me.ChtCurves.Series.Add(Cur.ToString)
Me.ChtCurves.Series(Cur.ToString).ChartType = DataVisualization.Charting.SeriesChartType.Spline
Me.ChtCurves.ChartAreas(0).AxisX.LabelStyle.Format = "#.###"
Me.ChtCurves.ApplyPaletteColors() ' this will allow you to retrieve the default color
chtColor(i) = Me.ChtCurves.Series(Cur.ToString).Color