?
Solved

Vb.net Graph Control not displaying line graph properly

Posted on 2010-09-16
7
Medium Priority
?
991 Views
Last Modified: 2012-05-10
Hello,
I'm have a weird problem. I've developed a vb.net application with a feature that allows users to create a graph.  Users are able to select one of four graph styles and then generate a graph.  For some reason, I am having a weird result when users select line graph as shown in the image below.  The other selections such a column, stacked, and stacked column are right on the money.
LineGraph.JPG
0
Comment
Question by:chtullu135
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 

Author Comment

by:chtullu135
ID: 33694199
Here is some additional information.  When I export the graph via the interface, using excel automation, the line graph works fine.  The problem appears to be with the chart object in the form
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 33750572
Hi chtullu135,

I ran into that myself not long ago, think I initially resolved it by switching the xaxis and yaxis values, line chart draws horizontally, your other chart types draw vertically.

If you give a title to the axisX, you should be able to see if this is the case, because the title will be rendered on the vertical axis for your line chart, but on the horizontal axis for the other chart types, maybe it's the other way round, whatever, you'll see the location of axisX shifts.

<axisx LineColor="64, 64, 64, 64"  LabelAutoFitMaxFontSize="8"  Title="xaxis">

hth

Alan
0
 

Author Comment

by:chtullu135
ID: 33770693
Thanks, I'll give it a try.
0
 

Author Comment

by:chtullu135
ID: 33803207
Hello,

BTW below is the code I am using to create the graph.  It works fine for everything with the exception of a couple of line graphs.  These seem to be the ones that use percentages.
 Dim xfield As String = "ForecastYear"
                    Dim xval As New ArrayList

                    For Each r As DataRow In ds.Rows
                        xval.Add(r.Item(xfield))
                    Next

                    Dim yfield As String = "MetricValue"
                    Dim yval As New ArrayList
                    For Each r As DataRow In ds.Rows
                        If strReportMetricName = "% Renewable Electricity Generation (Including Hydropower), annual" Then
                            yval.Add(r.Item(yfield) * 100)
                        ElseIf strReportMetricName = "% Advanced Vehicles Based on Sales, annual" Then
                            yval.Add(r.Item(yfield) * 100)
                        Else
                            yval.Add(r.Item(yfield))
                        End If

                    Next
                    Chart1.Series(strSeriesName).Points.DataBindXY(xval, yval)

Open in new window

0
 

Accepted Solution

by:
chtullu135 earned 0 total points
ID: 33810251
Actually the array list wasn't the problem.  The array was being populated by a data access function I had written not by the datagridview.  In stepping through the code, I found that the array was being populated in the wrong order.  So the array was receiving out of order data.  I went to the stored procedure that was used to populate this array and found that I had forgotten to add an order by clause to the select statement.  I remembered from basic relational database theory that the sort order of retrieved records is not guaranteed unless you explicitly set it using an Order by clause.  Once I added it, the array was populated correctly.  BTW thanks for the tip about declaring arraylists at the class level.  I'll keep it in mind
0

Featured Post

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question