2011-03-09 49 views
1

我有一個ASP圖表(v4),它顯示我需要的完美數據。我希望它在數據點的頂部顯示標籤,並且遇到一些問題。ASP圖表標籤顯示在多個系列上的數據點ASP.NET 4

這裏是我的代碼,對於這兩種系列作品,但不顯示標籤:現在

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() 

所以我的問題是,請你能幫我在每個系列的標籤更新代碼中顯示兩個系列?謝謝!

回答

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> 
相關問題