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

Charting options 1

Status
Not open for further replies.

jebenson

Technical User
Feb 4, 2002
2,956
US
Hello all,
I am building an app that requires charting capabilities. Due to budgetary constraints, I cannot purchase a charting tool, and so must rely on free tools. I have tried the MSChart component, but I do not want to use a COM object if I can help it (plus, it sucks!). I have tried various free or "lite" tools, and settled tentatively on SoftwareFX's ChartFX Lite.

OK, so here are my questions:

1) Has anybody ever used ChartFX Lite before? I am able to get the charts built and displayed, but I am having trouble with printing. I can print using the following code:

Code:
Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
    hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
    Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
    hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
    ByVal dwRop As System.Int32) As Long

    Dim memoryImage As Bitmap

    Private WithEvents PrintDocument1 As Printing.PrintDocument

.....
'in a button's click event:
PrintDocument1 = New Printing.PrintDocument
PrintDialog1.Document = PrintDocument1
PrintDialog1.ShowDialog()

CaptureScreen()

PrintDocument1.Print()
PrintDocument1.Dispose()
PrintDocument1 = Nothing

.........

Private Sub CaptureScreen()
    Dim mygraphics As Graphics = Module1.AgyExpCharts(CurrentPage).CreateGraphics()
    Dim s As Size = Module1.AgyExpCharts(CurrentPage).Size
        memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
    Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
    Dim dc1 As IntPtr = mygraphics.GetHdc
    Dim dc2 As IntPtr = memoryGraphics.GetHdc
    BitBlt(dc2, 0, 0, Module1.AgyExpCharts(CurrentPage).Width, _
    Module1.AgyExpCharts(CurrentPage).Height, dc1, 0, 0, 13369376)
    mygraphics.ReleaseHdc(dc1)
    memoryGraphics.ReleaseHdc(dc2)
End Sub

.....

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
       ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
    PrintDocument1.PrintPage
        e.Graphics.DrawImage(memoryImage, 0, 0)
        [green]'Module1.AgyExpCharts(CurrentPage - 1).Paint(e.Graphics, New Rectangle(0, 0, e.Graphics.ClipBounds.Width, e.Graphics.ClipBounds.Height / 2), SoftwareFX.ChartFX.Lite.Base.PaintFlags.Print)[/green]
End Sub

If I use the CaptureScreen and BltBlt printing method, the PrintDialog box that is displayed is captured along with the chart image and printed out on top of the image. Not good.

If I comment out the CaptureScreen and e.Graphics.DrawImage calls, and use the ChartFX object's Paint method (the commented out line in the PrintDocument1_PrintPage sub), the chart is printed, but with several errors (e.g., too small, line markers not printed, etc.). Does anybody have any experience with this?

2) My second question is, does anybody have any suggestions as to other free or very cheap charting tools for VB .NET?

Sorry for the long-winded post.

Thanks,
JEB

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Crystal Reports comes with VS.Net Professional. If you are looking for report based charting.

If you are looking for control base charting, check on DevSource and Code Warrior, someone has likely already writen one.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
ThatRickGuy,
Thanks for your response. I am using CR for several other reports in this app, and initially used it for this portion as well. The problem is that the charts produced need to have an arbitrary number of series, and the CR that comes with Visual Studio does not - as far as I have been able to determine - support run-time manipulation of a chart's series. In other words, you have to know the number of series and have the chart designed with that number of series beforehand. I believe the full developer version of CR does allow run-time chart manipulation, but not the "lite" version bundled with VS.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
componentone has one and it was free in the vb.net resource kit so if you have that.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
I believe the full developer version of CR does allow run-time chart manipulation, but not the "lite" version bundled with VS."

Kinda. There is a CR runtime development library which allows you to do just that. The problem though is that you need a named key for each deployment of that library. As opposed to the royalty free libraries used to just dispaly a report. Makes your product significantly more expencive when you have to tack $500 on to each desktop.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Hey folks,
Thanks for all of the responses. I think I'm going to end up using the ComponentOne chart because it looks pretty good and seems to print well.

I love Tek-Tips. I don't know what I would do without you people!


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top