domster
domster

Reputation: 566

Missing values of X Axis for Asp:Chart

Hi i just completed binding the data for my asp bar chart for X and Y axis but i'm facing an odd issue..

I'm actually setting the X Axis to have Jan, Feb, Mar... Oct, Nov and Dec. But only the even numbered months appear (Feb, Apr,... Oct, Dec)

Codes i'm using,

        String username = Session["ConsumerSelected"].ToString();

        AuditNLoggingDAO al = new AuditNLoggingDAO();

        String[] month = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };

        int[] monthLogin = { al.janLogin(username), al.febLogin(username), al.marLogin(username), al.aprLogin(username), al.mayLogin(username),
        al.junLogin(username), al.julyLogin(username), al.augLogin(username), al.septLogin(username), al.octLogin(username), al.novLogin(username), al.decLogin(username) };

        int[] monthLogout = { al.janLogout(username), al.febLogout(username), al.marLogout(username), al.aprLogout(username), al.mayLogout(username),
        al.junLogout(username), al.julyLogout(username), al.augLogout(username), al.septLogout(username), al.octLogout(username), al.novLogout(username), al.decLogout(username) };

        int[] monthFailure = { al.janFailure(username), al.febFailure(username), al.marFailure(username), al.aprFailure(username), al.mayFailure(username),
        al.junFailure(username), al.julyFailure(username), al.augFailure(username), al.septFailure(username), al.octFailure(username), al.novFailure(username), al.decFailure(username) };

        int[] monthPW = { al.janPW(username), al.febPW(username), al.marPW(username), al.aprPW(username), al.mayPW(username), al.junPW(username), al.julyPW(username), al.augPW(username), al.septPW(username),
         al.octPW(username), al.novPW(username), al.decPW(username) };

        Series seriesLogin = ChartMonth.Series.Add("SeriesLogin");
        seriesLogin.Color = ColorTranslator.FromHtml("#5cb85c");
        seriesLogin.LegendText = "Number of Login Executes";
        seriesLogin.IsValueShownAsLabel = true;
        seriesLogin.Font = new Font("Microsoft Sans Serif", 11);
        seriesLogin.SmartLabelStyle.Enabled = false;

        ChartMonth.Series["SeriesLogin"].Points.DataBindXY(month, monthLogin);

        Series seriesLogout = ChartMonth.Series.Add("SeriesLogout");
        seriesLogout.Color = ColorTranslator.FromHtml("#f0ad4e");
        seriesLogout.LegendText = "Number of Logout Executes";
        seriesLogout.IsValueShownAsLabel = true;
        seriesLogout.Font = new Font("Microsoft Sans Serif", 11);
        seriesLogout.SmartLabelStyle.Enabled = false;

        ChartMonth.Series["SeriesLogout"].Points.DataBindXY(month, monthLogout);

        Series seriesFailure = ChartMonth.Series.Add("SeriesFailure");
        seriesFailure.Color = ColorTranslator.FromHtml("#d9534f");
        seriesFailure.LegendText = "Number of Login Failures";
        seriesFailure.IsValueShownAsLabel = true;
        seriesFailure.Font = new Font("Microsoft Sans Serif", 11);
        seriesFailure.SmartLabelStyle.Enabled = false;

        ChartMonth.Series["SeriesFailure"].Points.DataBindXY(month, monthFailure);

        Series seriesPW = ChartMonth.Series.Add("SeriesChangePW");
        seriesPW.Color = ColorTranslator.FromHtml("#5bc0de");
        seriesPW.LegendText = "Number of Password Changes";
        seriesPW.IsValueShownAsLabel = true;
        seriesPW.Font = new Font("Microsoft Sans Serif", 11);
        seriesPW.SmartLabelStyle.Enabled = false;

        ChartMonth.Series["SeriesChangePW"].Points.DataBindXY(month, monthPW);

Result,

Picture

Why are all the months not showing..? Appreciate any help please, Thank you!

Upvotes: 2

Views: 683

Answers (1)

domster
domster

Reputation: 566

I fixed it by adding Axis X Interval = 1 in my Axis X tag in Client Side.

                                    <asp:Chart runat="server" ID="ChartMonth" Width="1100px" Height="538px">
                                        <ChartAreas>
                                            <asp:ChartArea Name="ChartAreaMonth">
                                                <AxisX Title="Month of Year" Interval="1">
                                                    <MajorGrid Enabled="false" />
                                                </AxisX>
                                                <AxisY Title="Number of Executes">
                                                    <MajorGrid Enabled="true" />
                                                </AxisY>
                                            </asp:ChartArea>     
                                        </ChartAreas>
                                        <Legends>
                                            <asp:Legend Docking="Bottom" Name="LegendMonth"></asp:Legend>
                                        </Legends>
                                        <Titles>
                                            <asp:Title Name="TitleChart" Font="Microsoft Sans Serif, 13pt" Text="Monthly Statistics" Alignment="TopCenter"></asp:Title>
                                        </Titles>
                                    </asp:Chart>

I would actually still like to know why all my X Axis from the Series isn't showing though.. Feel free to give an answer.. Thank you

Upvotes: 2

Related Questions