x value

Hema Ramachandran 176 Reputation points

How can I hide X value label, if there is no Y value?
For example I want to hide X axis values 16 and 18


A set of technologies in the .NET Framework for building web applications and XML web services.
3,371 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 27,796 Reputation points Microsoft Vendor

    Hi @Hema Ramachandran ,
    I think you can use an if statement to determine whether y has a value,
    if y has no value and the x point is empty, you can refer to the following example:

    <asp:Chart ID="Chart1" runat="server">  
        		<asp:Series Name="Testing" YValueType="Int32">  
        				<asp:DataPoint AxisLabel="Test 1" YValues="10" />  
        				<asp:DataPoint AxisLabel="Test 2" YValues=" " />  
        				<asp:DataPoint AxisLabel="Test 3" YValues="0" />  
        				<asp:DataPoint AxisLabel="Test 4" YValues="40" />  
        		<asp:ChartArea Name="ChartArea1">  

    code behind:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
            For Each series As System.Web.UI.DataVisualization.Charting.Series In Chart1.Series  
                For Each point As System.Web.UI.DataVisualization.Charting.DataPoint In series.Points  
                    If point.YValues.Length > 0 AndAlso CDbl(point.YValues.GetValue(0)) = 0 Then  
                        point.LegendText = point.AxisLabel  
                        point.AxisLabel = String.Empty  
                        point.Label = String.Empty  
                    End If  
    End Sub  

    Best regards,
    Lan Huang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments