2

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!

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

4 Comments

I would actually still like to know why all my X Axis from the Series isn't showing though. What isn't still showing? The chart control will set the interval to Auto if you don't set a interval. That is why it was doing every even month. Forcing the interval to 1 should make them all show up. Is the name for each interval not showing up?
Hint: when putting down indented code sections - make sure to start with 4 spaces only. There is no point in having your code being indented so far to the right that even on high resolution my browser has to put down a horizontal scroll bar ;-)
@GhostCat hello again ghost, that's the reason why not all showed up? Because of the width of the chart?
There are many questions here. To a certain degree, you are competing with all of them. It is like some web shop: people use those that are easy to digest. In other words: anything that makes a potential reader turn away reduces your "potential person giving an answer" counter by 1. So: I am not saying that this is the reason you did not hear on this question. I am just saying: in order to maximize the probability of getting feedback, you should maximize "readability". Even small things might matter. In this case - the reason is maybe that your problem is too special.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.