1

我有一个 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()

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

4

1 回答 1

1

好的,我想通了。

使用第一批代码就可以了。添加以下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>
于 2011-03-09T16:40:27.720 回答