zed 图 x 轴标签

发布于 2024-10-18 14:41:26 字数 831 浏览 2 评论 0原文

我正在尝试循环遍历数据表列 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彻夜缠绵 2024-10-25 14:41:26

您需要删除代码才能将标签从创建点的 For Next 循环中取出。

这意味着

    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

现在,在循环绘图点之外,您需要遍历 DataTable

请查看您收到的错误...字符串列表无法转换为字符串数组。这些对象并不等同。

一种选择是执行类似的操作(在循环绘制点之后)

Dim labels(tablegraph.Rows.Count - 1) as String

For i As Integer = 0 To tablegraph.Rows.Count - 1
     labels(i) = tablegraph.Row(i).Item("SDESCR")
Next

myPane.XAxis.Scale.TextLabels = labels         
myPane.XAxis.Type = AxisType.Text

,我在这台计算机上没有 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

    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

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)

Dim labels(tablegraph.Rows.Count - 1) as String

For i As Integer = 0 To tablegraph.Rows.Count - 1
     labels(i) = tablegraph.Row(i).Item("SDESCR")
Next

myPane.XAxis.Scale.TextLabels = labels         
myPane.XAxis.Type = AxisType.Text

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文