Devexpress网络图表控制如何获得无限的颜色集合并存储在列表数组中



目前我有 204 个项目要在网络图表控件中显示为图例, 我当前的代码只能支持大约 150 个项目的颜色。如果更多 比这,然后错误"索引超出范围。必须为非负数 并且小于集合的大小。参数名称:索引"。 如何获得无限的颜色存储在列表数组中?请 指导我。

我的代码

Dim colors As List(Of String) = New List(Of String)()
Dim colorNames As String() = System.Enum.GetNames(GetType(KnownColor))
Dim whiteBrightness As Single = Color.FromKnownColor(KnownColor.NavajoWhite).GetBrightness()
For Each colorName As String In colorNames
Dim KnownColor As KnownColor = CType(System.Enum.Parse(GetType(KnownColor), colorName), KnownColor)
Dim knownColorBrightness As Single = Color.FromKnownColor(KnownColor).GetBrightness()
If (KnownColor > KnownColor.Transparent AndAlso knownColorBrightness < whiteBrightness AndAlso colorName.IndexOf("Gray") = -1) Then
colors.Add(colorName)
End If
Next
Dim lColor As Dictionary(Of String, String) = New Dictionary(Of String, String)

Dim colorTracker As Integer = 0
'''''''''''''''''''''''''
lColor.Add("Remaining", "DarkGray")

For Each dr In dt.Rows
Dim series1 As New Series(dr("tool").ToString(), ViewType.StackedBar)
series1.ValueScaleType = ScaleType.Numerical
series1.Points.Add(New SeriesPoint(dr("ID").ToString(), dr("Process")))

' series1.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.True
'series1.ToolTipHintDataMember = dr("tooldata").ToString()
series1.ToolTipPointPattern = "<span style='font-size:13px'>EQPID: {A} <br/> Recipe: {S} <br/> " + dr("tooldata").ToString() + "</span>"
chart.Series.Add(series1)
Dim myview1 As StackedBarSeriesView = CType(series1.View, StackedBarSeriesView)
myview1.BarWidth = 0.5
myview1.FillStyle.FillMode = FillMode.Solid

'CHECK if same item, assigned same color, else assigned other color
If lColor.ContainsKey(dr("tool").ToString()) Then
series1.View.Color = Color.FromName(lColor(dr("tool").ToString()))
Else
\error happens here in line series1.View.Color, there 
are 204 tool items, but the length returned for colors from  
knowncolor is 174, that is why the index 
error occurs.My problem is there any other properties that
contain unlimited color?
series1.View.Color = Color.FromName(colors(colorTracker))
lColor.Add(dr("tool").ToString(), colors(colorTracker))
colorTracker = colorTracker + 1
End If
''''''''''
Next

ChartControl和 WebChartControl 支持系列着色器功能(在 v18.1 及更高版本中可用(,该功能允许从一组预定义的键或数据源值定义系列颜色架构。您应该能够使用内置功能,而不是手动初始化系列颜色。

相关内容

  • 没有找到相关文章

最新更新