1
votes

I am using the ASP.NET Chart Control that Microsoft provides. I have a simple 2D chart with two series in it, one is positive and the other is negative. Here is what it looks like currently: Picture of my chart

I am guessing, because of my data range that the Y Axis at zero does not display by default. But if I add this line it does (as you can see in the above image):

AxisY.Crossing = 0;

AxisY is a reference to the Y Axis object. Is there a way to now label the axis without having to manually label all the major grid lines? If I do this it will label the Axis, but all the other dollar labels disappear:

Chart.ChartAreas[0].AxisY.CustomLabels.Add(new CustomLabel(0, 1, "0", 0, LabelMarkStyle.SideMark));

Here is my ASP.NET code:

 <asp:Chart ID="chartStudyResults" runat="server" AntiAliasing="All" 
        Height="650px" Width="690px">
        <Series>
        </Series>
        <ChartAreas>
            <asp:ChartArea Name="main" IsSameFontSizeForAllAxes="true">
                <AxisX Interval="1" IntervalAutoMode="VariableCount">                    
                    <MajorGrid Enabled="false" />                                
                </AxisX>                        
                <AxisY>
                    <MajorGrid Enabled="true" />
                </AxisY>
            </asp:ChartArea>
        </ChartAreas>
    </asp:Chart> 

I am adding the series data in code. Thanks in advance.

1

1 Answers

0
votes

Are you setting the AxisY intervals manually? If so you will need to adjust so zero is one of the major tickmarks or don't set the AxisY interval.