Solved

Vb.net Graph Control not displaying line graph properly

Posted on 2010-09-16
7
985 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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