在多个系列 ASP.NET 4 上的数据点处显示 ASP 图表标签

发布于 2024-10-20 19:43:06 字数 2024 浏览 3 评论 0原文

我有一个 ASP 图表 (v4),它完美地显示了我需要的数据。我希望它在数据点顶部显示标签,但我遇到了一些困难。

这是我的代码,适用于两个系列,但不显示标签:

If MySQLReader.HasRows Then
            Chart1.DataSource = MySQLReader
            Chart1.Series("New Customers Created").XValueMember = "Salesperson"
            Chart1.Series("New Customers Created").YValueMembers = "NCC"
            Chart1.Series("Target").XValueMember = "Salesperson"
            Chart1.Series("Target").YValueMembers = "Target"
            Chart1.DataBind()

            Chart1.Height = 500
            Chart1.Width = 750
            Chart1.ChartAreas("ChartArea1").AxisX.MajorGrid.Enabled = False
            Chart1.ChartAreas("ChartArea1").AxisY.MajorGrid.Enabled = True

            LBLError.Text = ""
        Else
            Chart1.Visible = False
            LBLError.Text = "<div class='error'>Your search did not match any records in the database. Please try again</div>"
        End If
        MySQLReader.Close()
        MyConn.Close()

现在这是我更新的代码,显示标签但仅适用于一个系列。

If MySQLReader.HasRows Then

            Chart1.Series("New Customers Created").Points.DataBind(MySQLReader, "Salesperson", "NCC", "Label=NCC")
            Chart1.Series("Target").Points.DataBind(MySQLReader, "Salesperson", "Target", "Label=Target")
            Chart1.Height = 500
            Chart1.Width = 750
            Chart1.ChartAreas("ChartArea1").AxisX.MajorGrid.Enabled = False
            Chart1.ChartAreas("ChartArea1").AxisY.MajorGrid.Enabled = True

            Chart1.Series("New Customers Created")("LabelStyle") = "Bottom"
            Chart1.Series("New Customers Created").Font = New Drawing.Font("Arial", 8)
            LBLError.Text = ""
        Else
            Chart1.Visible = False
            LBLError.Text = "<div class='error'>Your search did not match any records in the database. Please try again</div>"
        End If
        MySQLReader.Close()
        MyConn.Close()

所以我的问题是,您能帮我在更新的代码中显示这两个系列,并为每个系列添加标签吗?谢谢!

I have an ASP Chart (v4) which displays the data I need perfectly. I want it to show labels at the top of the data points and I am having some difficulty with it.

Here is my code that works for both series but does not display the labels:

If MySQLReader.HasRows Then
            Chart1.DataSource = MySQLReader
            Chart1.Series("New Customers Created").XValueMember = "Salesperson"
            Chart1.Series("New Customers Created").YValueMembers = "NCC"
            Chart1.Series("Target").XValueMember = "Salesperson"
            Chart1.Series("Target").YValueMembers = "Target"
            Chart1.DataBind()

            Chart1.Height = 500
            Chart1.Width = 750
            Chart1.ChartAreas("ChartArea1").AxisX.MajorGrid.Enabled = False
            Chart1.ChartAreas("ChartArea1").AxisY.MajorGrid.Enabled = True

            LBLError.Text = ""
        Else
            Chart1.Visible = False
            LBLError.Text = "<div class='error'>Your search did not match any records in the database. Please try again</div>"
        End If
        MySQLReader.Close()
        MyConn.Close()

Now here is my updated code that displays the Labels but only for one series.

If MySQLReader.HasRows Then

            Chart1.Series("New Customers Created").Points.DataBind(MySQLReader, "Salesperson", "NCC", "Label=NCC")
            Chart1.Series("Target").Points.DataBind(MySQLReader, "Salesperson", "Target", "Label=Target")
            Chart1.Height = 500
            Chart1.Width = 750
            Chart1.ChartAreas("ChartArea1").AxisX.MajorGrid.Enabled = False
            Chart1.ChartAreas("ChartArea1").AxisY.MajorGrid.Enabled = True

            Chart1.Series("New Customers Created")("LabelStyle") = "Bottom"
            Chart1.Series("New Customers Created").Font = New Drawing.Font("Arial", 8)
            LBLError.Text = ""
        Else
            Chart1.Visible = False
            LBLError.Text = "<div class='error'>Your search did not match any records in the database. Please try again</div>"
        End If
        MySQLReader.Close()
        MyConn.Close()

So my question is, please can you help me display both series in the updated code with labels for each series? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

归途 2024-10-27 19:43:06

好吧,我明白了。

使用第一批代码就可以了。添加以下 IsValueShownAsLabel="True" 显示标签:

<asp:Series Name="New Customers Created" Legend="New Cust" IsValueShownAsLabel="True">
                    </asp:Series>
                    <asp:Series Name="Target" Legend="New Cust" IsValueShownAsLabel="True">
                    </asp:Series>

OK, I figured it out.

using the first batch of code is fine. Adding the following IsValueShownAsLabel="True" shows the labels:

<asp:Series Name="New Customers Created" Legend="New Cust" IsValueShownAsLabel="True">
                    </asp:Series>
                    <asp:Series Name="Target" Legend="New Cust" IsValueShownAsLabel="True">
                    </asp:Series>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文