Solved

Vb.net Graph Control not displaying line graph properly

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now