[英]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.