在多个系列 ASP.NET 4 上的数据点处显示 ASP 图表标签
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我明白了。
使用第一批代码就可以了。添加以下
IsValueShownAsLabel="True
" 显示标签:OK, I figured it out.
using the first batch of code is fine. Adding the following
IsValueShownAsLabel="True
" shows the labels: