Problem to Chart

Hi,
The chart in the beginning part of page, is not being shown properly with the data from the table
http://my-friend.co/HouseList4/Default.aspx?userid=mc1

what can be the reason of problem? Here are the codes to create the chart

                string query = "select [house_sch].dbo.getletter(ROW_NUMBER() OVER (ORDER BY house_id)) house_name, price from [house_sch].[dbo].[house_tab] order by house_id";
                DataTable dt = GetData(query);

                string[] x = new string[dt.Rows.Count];
                decimal[] y = new decimal[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    x[i] = dt.Rows[i][0].ToString();
                    y[i] = Convert.ToInt32(dt.Rows[i][1]);
                }
                BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries { Data = y });
                BarChart1.CategoriesAxis = string.Join(",", x);
                BarChart1.ChartTitle = "房价的起伏与升跌";

Open in new window

LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
well, I just done a similar page with scripts above and it seems worked to me (just a bit off for the positioning)

snap.jpg
what error have you encountered?
0
HuaMin ChenProblem resolverAuthor Commented:
Thanks a lot. What did you adjust to show the chart?

There is no error to the chart.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I didn't adjust much:

Front end:

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <ajaxToolkit:BarChart ID="BarChart1" runat="server" Height="425px">
        </ajaxToolkit:BarChart>

Open in new window


code behind: (for testing purposes, I use my own datatable with test data)

protected void Page_Load(object sender, EventArgs e)
        {
            //string query = "select [house_sch].dbo.getletter(ROW_NUMBER() OVER (ORDER BY house_id)) house_name, price from [house_sch].[dbo].[house_tab] order by house_id";
            //DataTable dt = GetData(query);
            
            SqlConnection conn = new SqlConnection("Data Source=machine;Initial Catalog=myDB;Persist Security Info=True;User ID=userid;Password=password");
            conn.Open();

            SqlCommand cmd = new SqlCommand("select Field1, Field2 from YourTable", conn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);

            string[] x = new string[dt.Rows.Count];
            decimal[] y = new decimal[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                x[i] = dt.Rows[i][0].ToString();
                y[i] = Convert.ToInt32(dt.Rows[i][1]);
            }
            BarChart1.Series.Add(new AjaxControlToolkit.BarChartSeries { Data = y });
            BarChart1.CategoriesAxis = string.Join(",", x);
            BarChart1.ChartTitle = "房价的起伏与升跌";

        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

HuaMin ChenProblem resolverAuthor Commented:
Appreciated. What can be reason that chart is not shown properly, to my case?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
What can be reason that chart is not shown properly, to my case?

try to put some break points in your codes and then check and make sure your DataTable dt returns something?
0
HuaMin ChenProblem resolverAuthor Commented:
Yes, query is returning records below
21d.png
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Yes, query is returning records

ok, try make sure:

you got ScriptManager in front end?

<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

Open in new window


and make break point(s) in code behind, probably at line:

string[] x = new string[dt.Rows.Count];

Open in new window


and see if you can find out the abnormally?
0
HuaMin ChenProblem resolverAuthor Commented:
Yes, details are fine. There was no problem at all, before this, and I do not know why problem arose, without applying any change/adjustment.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
ok, no idea too.

try to re-build your solution and see if there's any errors

also use simple method as shown in ID: 42482247, perhaps on a new page file and see if you can generate that chart successfully.
0
HuaMin ChenProblem resolverAuthor Commented:
Sorry to that I want to see if there is any clue now, to current issue.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
think need apply some debugging techniques (like putting the break points, etc) in order to find out the exact issues from your codes.

but unfortunately we can't remotely login to your System  for debugging, so we only can provide guidance how we usually solve similar issues.
0
HuaMin ChenProblem resolverAuthor Commented:
I am checking the deployed Web page and how to detect the reason of current problem?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I am checking the deployed Web page and how to detect the reason of current problem?
another way will be write the log to a file and debug from it.

have you heard about log4net library before?

you can easily integrate it to your VS project via Nuget:

log4net 2.0.8
https://www.nuget.org/packages/log4net/
0
HuaMin ChenProblem resolverAuthor Commented:
Hi Ryan,
I did also show you the query last time. Do you think which column value (of query) can give any clue of the issue?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
Do you think which column value (of query) can give any clue of the issue?
if your query did return records then your chart should show the results...

i would suggest to use the techniques mentioned (putting breakpoints and write to log, etc) for debugging.

else you probably can start doing a basic one and then use it to examine your existing one.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.