[英]Devexpress webchartcontrol how to get unlimited colors collection and store in list array
目前我有 204 個項目在 webchartcontrol 中顯示為圖例,我當前的代碼只能支持大約 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 和更高版本中可用),該功能允許從一組預定義的鍵或數據源值定義系列顏色模式。 您應該能夠使用內置功能而不是手動初始化系列顏色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.