Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including Graphs in PrintDocuments

Status
Not open for further replies.

JScannell

Programmer
Jan 9, 2001
306
US
I have what appears to be an initialization problem when including graphs in a reporting scheme. I hope you understand this:
1. I have a dll that creates and populates a System.Windows.Forms.DataVisualization.Charting object
2. A SQL string is passed into this DLL as a part of the setup.
3. One of the setups, of course, will produce Y-axis labels based on the overall SQL results.
4. The first time I run my report with certain parameters set, the Y-axis labels are perfect.
5. If I then change my input parameters, the Y-axis labels are a repeat of the first run.

This shouldn't be since I create new instances of the charting object each time. Something, however, is left over from the first run.

I have attached a document for you to look at. There are screenshots of the run time results and I've also included the source code of my DLL and how it is setup.



Jerry Scannell
 
 https://files.engineering.com/getfile.aspx?folder=6bd3be03-3ad0-4b74-b528-b8b798c1e88d&file=Graphics-YAxis_Problem.pdf
This is odd. I solved the problem but I don't understand why I had to do it.

In my code, x and y points are added to each series. Of course, this is how the graph gets created in the first place. Not earth-shattering.

But it is what I had to do for each series that has me confused. I had to explicitly clear() out each series' points before I could add new ones. The reason why that is troubling is because I create new instances of the class each time, so why would data points from a previous instance of the object still be in there?

I've attached my new code with the bottom 3 lines being what I added.

I don't know why the points from the previous runs would have still been there. They caused my y-axis labels to stay the same from run to run. Whichever report I ran first would permanently set the labels.


Jerry Scannell
 
 https://files.engineering.com/getfile.aspx?folder=d43b2c0c-3746-47d4-b5c3-6b5d9717af77&file=Graphics-YAxis_Problem__Solution.pdf
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top