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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Charts for ASP.NET - Urgent. 2

Status
Not open for further replies.

dpdoug

Programmer
Nov 27, 2002
455
US
I urgently need to get ahold of a chart/graph that will easily integrate with ASP.NET and does not use DLLs. My host will not install any dlls on its server, so it will have to be either script based or something that compiles with VS.NET.

I found some beautiful charts made by Advanced Software Engineering called ChartDirector and relatively inexpensive. But the problem is you have to install a dll. (see:
If anyone knows of some easy to use and quick to develop in charting scripts that are not too expensive, let me know, I would be very greatful. I'm getting some pressure to get some progress made on this project, so I need something that will be quick for me to develop some nice looking charts and graphs.

Thanks!!

dpdoug
 
A non-compiled charting tool, I cannot offer you. However, with any ASP.Net project if you set your reference property CopyLocal to true the dll doesn't exactly have to be installed. It is just copied to the server with project as if it was an aspx or vb file.

It doesn't exactly mean that dlls are not installed but at the least the user wouldn't perceive it that way.

ComponentOne also does some nice graphs for .Net

Eva
 
What do you mean by "the user wouldn't perceive it that way"? The user being the web host?

See, some web hosts (mine for example) don't want any dlls installed or registered on their server. But if those dlls will run the same in .NET without them being installed and registered, that would be fine with me. But that's news to me.

Thanks for the tip.

dpdoug
 
dp: I use ChartDirector, a wonderful product, and there is little you can't do with it -- I put the their dll file in the bin directory, and no registration or any other action was required. My guess is that ChartDirector's dll would be ok. I think ev is correct.

dp: If you decide to use ChartDirector, let me know, have tons of code (also CD has a user's forum up; and they will answer questions usually within 1 day -- excellent service)

dp; you can see several of the ChartDirector chart styles at -- a dot NET data forum I created.

.
 
Wow! Thanks a lot Isadore. I really like ChartDirector, and was kind of disappointed that I couldn't use it. But since it works for you - it should work for me too.

Thanks for the tip!!!

dpdoug
 
By the way, yes I will use it and I'd like to see some of that code you have.

I went to your site - very nicely done!

dpdoug
 
dp: Thanks -- Chart Director has a few ins and out, etc... but the nice thing is, Peter Kwan, one of the principle owners of the company - a very nice fellow indeed - he's an engineer, company is out of Hong Kong - their staff, as you could imagine, are no less than the best in SE Asia -- these guys have never let a problem sit on their support forum for more than 24 hours -- that I can remember -- these people are very decent -- and their latest version of ChartDirector has beautiful options, e.g., the box-whisker:


etc, etc...

Anyway, fire me an email to biochem3d@cs.com and I'll group some files, zip 'em up and fire on over. I can assure you one thing, there is of course no substitute for pluggin and chuggin, but the code I will send you will certainly help and will save you much time in referencing - you can always see the pages operation at the forum above.

The level of support for ChartDirector, which is one of many good charting programs (albeit many are a few more dollars, ChartDirector license is only $99).

References:

1. They have a support forum, which as I mentioned, they respond rapidly. And generally they get it right, in the first response. There is a year of history of topics discussed that you can easily page through. As you can imagine, there will be tons of code throughout these threads.

2. ChartDirector puts out a pdf file, their owner's manual, how to use, and the examples are generally no more than a couple of clicks away - fast reference, etc...

3. My zip files, which will cover 2 or 3 hundred other oddities...

you'll enjoy it, no doubt.
 
dp: One more note. This University that I work for are as "security gun shy" as they come. I can guarantee you that if there was a security concern with chartdirector's dll file, I would have been the first to find out.

If they say no, you have them contact Peter Kwan -- Peter will email them and lay it out for ya...
 
Isadore:
I added the ChartDirector.dll to my bin folder and added a reference to it in References in my project. I checked the properties and and found the ColyLocal was already set to true.

I ran a test page with the simple example that they give in Getting Started: The First Project. The ASP page came up but all there was there was a broken link where the IMG tag and the SRC to the ASP page is.

What am I doing wrong??

dpdoug


 
dp: I would debug the image. When your aspx page is opened, right click and get the ImageURL and paste that in the URL window, hit return, and caputre error --

Hard to say; post the page so I can copy and test it.

 
This is the error I get when I run the page with code in it:

Error Type:
Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'ChartDirector.API'
/rsc/charts/chart_ontime.asp, line 14


dpdoug
 
dp: Doug - I'm am not too familiar with asp pages - I am strickly using aspx.

This may be part of the problem. If you are using aspx and not asp paste your entire page, we'll check it out.
 
dp: Send Peter an email -- by posting at his Support forum. Give him the error code -- he'll get back to you, as I said, within a day --
 
Hi,

I am hoping that someone might be able to help. I am trying to use ChartDirector to produce a bar chart of some simple statistics for a web application I am building. This problem has been driving me nuts over the past few days!

Basically what I want to do is count the number of records allocated to a system derived from a SQL query and display this in a bar chart format. eg System 1 - 12 , System 2 - 25 and so on. Not a difficult concept and not an unreasonable request.

I have written my query to find the systems and the number of records allocated:

Code:
strSQL=SELECT System AS Label, COUNT(ID) AS IDCount FROM tblSystems INNER JOIN tblRecords ON tblSystem.SystemID=tblRecords.SystemID GROUP BY System ORDER BY System

My problem comes when I try to add the data layer to the barchart.

At the moment, I am building the labels for the x axis as follows

Code:
While objDR.Read()
  l_strLabels += g_objDR("Label") & ", "
  l_strData += g_objDR("IDCount") & ", "
End While

and parsing the strings as follow:

Code:
l_strLabels = Left(l_strLabels, (Len(l_strLabels) - 2))
l_strData = Left(l_strData, (Len(l_strData) - 2))

When I try to add the labels to the chart it works fine. I am using the following code to do this:

Code:
Dim l_strGraphLabels() As String = {l_strLabels}
c.xAxis().setLabels(l_strGraphLabels)

The problem comes when I try to add the data layer in a similar fashion:

Code:
l_strData = Left(l_strData, (Len(l_strData) - 2))
Dim l_dblGraphData() As String = {(l_strData)}
c.addBarLayer(CDbl(l_dblGraphData))

The chart does not display because of the error message "Cast from string "1, 3, 2, 2, 2, 10, 5, 3, 2" to type 'Double' is not valid."

Now I know I might be going about this the wrong way, but I am not too sure how else this can be achieved. This is the first time that I am using ChartDirector.

If there is anything you can suggest (hints/tips/references) that can help me to resolve the problem and produce the desired output it would be much appreciated!

Thanks in advance,
SonD

 
I've had the same error before. The problem is, if I'm not mistaken, that the array you are using here is string type:

c.addBarLayer(CDbl(l_dblGraphData))

I think trying to convert a string array to a double is what's giving you trouble.

It must be of type double to begin with. l_strData is a string that you are using in your loop to concatenating a string of numbers into. Change this to a double and put an element that increments with each pass through the loop inserting into it the numbers from g_objDR("IDCount").

I would suspect that IDCount is an integer, so you may need to convert it to a double passing through the loop, I don't know.

Also I don't think this will work:
Code:
Dim l_dblGraphData() As String = {(l_strData)}
It looks like you intended for l_dblGraphData to be a double and you are trying to assign a string of numbers to a string array... at any rate l_dblGraphData needs to be a double.

I hope this helps.
 
Thanks for responding so quickly! I have managed to figure out what was going on. This is what I have ended up with ...

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  Dim intIndex As Integer = 0
  Dim intMaxArrSize As Integer=20
  Dim arrResults(intMaxArrSize) As Double
  Dim arrLabels(intMaxArrSize) As String

  '--connection and sql code here 
  
  While objDR.Read()
    arrResults(intIndex) = objDR("IDCount")
    arrLabels(intIndex) = objDR("Label")
    intIndex = (intIndex + 1)
  End While

  objDR.Close()

  '--close connection here

  '--output the chart
  Dim c As XYChart = New XYChart(800, 800)
  Dim colors() As Integer = {&HEADFDF, &HFF0000, &H999966, &H333366, &HC3C3E6}

  c.setPlotArea(50, 50, 700, 400)
  c.addTitle("Title", "Arial", 10, &H330000)

  c.addBarLayer(arrResults, colors).setBorderColor(-1, 1)

  c.xAxis().setLabels(arrLabels)
  c.xAxis().setLabelStyle("Arial", 8, &H330000, 90)
  c.xAxis().setTitle("X Axis Title")

  c.yAxis().setTitle("Y Axis Title")

  Response.ContentType = "image/png"
  Response.BinaryWrite(c.makeChart(Chart.PNG))
  Response.End()

End Sub

Thanks once again for your help.

SonD
 
SonD: Nice solution. Your code is nice example of populating arrays for use in ChartDirector, you should re-post this at ChartDirector for those new to ChartDirector to view there.

ChartDirector is a great product, and gets better with each new version.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top