zed 图 x 轴标签
我正在尝试循环遍历数据表列 sdescr 并使用列中的文本作为 x 轴的标签,但它不起作用,我收到此错误
类型值 'System.Collections.Generic.List(的 String)' 无法转换为 '一维字符串数组'。
For i As Integer = 0 To myCurve1.Points.Count - 1
Dim pt As PointPair = myCurve1.Points(i)
' Create a text label from the Y data value
Dim text As New TextObj(pt.Y.ToString("f0"), pt.X, pt.Y + 0.1, CoordType.AxisXYScale, AlignH.Left, AlignV.Center)
text.ZOrder = ZOrder.A_InFront
text.FontSpec.Angle = 90
myPane.GraphObjList.Add(text)
Dim labels As New List(Of String)
For Each row As DataRow In tablegraph.Rows
labels = row.Item("SDESCR")
Next row
myPane.XAxis.Scale.TextLabels = labels
myPane.XAxis.Type = AxisType.Text
Next
I am trying to loop through my datatable column sdescr and use the text in the columns as the labels of my x axis, but it isnt working i am getting this error
Value of type
'System.Collections.Generic.List(Of
String)' cannot be converted to
'1-dimensional array of String'.
For i As Integer = 0 To myCurve1.Points.Count - 1
Dim pt As PointPair = myCurve1.Points(i)
' Create a text label from the Y data value
Dim text As New TextObj(pt.Y.ToString("f0"), pt.X, pt.Y + 0.1, CoordType.AxisXYScale, AlignH.Left, AlignV.Center)
text.ZOrder = ZOrder.A_InFront
text.FontSpec.Angle = 90
myPane.GraphObjList.Add(text)
Dim labels As New List(Of String)
For Each row As DataRow In tablegraph.Rows
labels = row.Item("SDESCR")
Next row
myPane.XAxis.Scale.TextLabels = labels
myPane.XAxis.Type = AxisType.Text
Next
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要删除代码才能将标签从创建点的 For Next 循环中取出。
这意味着
现在,在循环绘图点之外,您需要遍历 DataTable
请查看您收到的错误...字符串列表无法转换为字符串数组。这些对象并不等同。
一种选择是执行类似的操作(在循环绘制点之后)
,我在这台计算机上没有 Zed,因此我没有在 Visual Studio 中检查这一点,但这应该会给您一个非常不错的方向。
You need to remove the code to get the labels out of your For Next loop that is creating points.
Which means this
Now, outside of the loop plotting points, you need to go through your DataTable
Please look at the error you're getting... The List of String can't be converted into a string array. Those objects aren't equivalent.
One option would be to do something like this (after your loop to plot points)
I don't have Zed here on this computer, so I haven't checked this in Visual Studio, but this should give you a very decent direction.