Dynamically generating the charts

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 19, 2008 2:56 pm

Hi asupriya,

Revisiting the example I posed I've found it didn't work fine for synchronizing all charts when scrolling. I've fixed it modifying Scroll event implementation like this:

Code: Select all

    Private Sub tChart1_Scroll(ByVal sender As Object, ByVal e As System.EventArgs)
        UpdateAxes(CType(sender, Steema.TeeChart.Chart).Parent)
    End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Mon Dec 22, 2008 5:38 am

Thank you very much for the help. It was very helpful.

1. I figured the scroll event handler problem on friday, but it was simple enough to make that change. I have few issues with the axistool scroll event. I want to allow both the rightclik-mouse drag and the axistool to do scrolling. Your code works for mouse-drag scenario. In case of axistool, the same scroll event handler is raised, but the ctype throws (rightly) the exception. Is there a way i can get both working without conflict?

2. UndoneZoomed - It doesn't unzoom unless we unzoom it only from the chart that has zoomed it. The event handler is correctly called for the undozoomed event even when unzoomed from other charts, but it simply doesn't get the OrgChart.Axes.Bottom.Minimum and maximum reset to the unzoom levels unless the event is invoked by the same chart where zoom occured. Same behavior can be observed in the example you posted as well. Please suggest if there is any way to fix it. Its not a big problem for us, but it'd be nice to fix!

3. Legend.click event works great. Thanks. How can i set the cursor to hand symbol when the mouse hovers over the legend?

4. Chart.Footer.Image somehow doesn't showup. I don't get any exception/error. But, it simply doesn't show up. I set the footer.image as follows.

Code: Select all

teechart1.Footer.Image = My.Resources.myLogo
5. Metafile saving option:
When tried to save the image to wmf/emf formats, i get the following error. All other image formats work fine.

"Parameter is not valid"

My code is as follows

Code: Select all

Case EMFFormat
                        Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = teechart1.Export.Image.Metafile
                        MetaFile.Height = 500
                        MetaFile.Width = teechart1.Width
                        MetaFile.EMFFormat = True
                        MetaFile.Save(fileToSave & ".Emf")
6. I want to set the chart background to white while printing/saving to image. teechart1.Panel.Color = Color.White somehow not doing anything. Any suggestions?

Thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 22, 2008 9:32 am

Hi asupriya,
1. I figured the scroll event handler problem on friday, but it was simple enough to make that change. I have few issues with the axistool scroll event. I want to allow both the rightclik-mouse drag and the axistool to do scrolling. Your code works for mouse-drag scenario. In case of axistool, the same scroll event handler is raised, but the ctype throws (rightly) the exception. Is there a way i can get both working without conflict?
I'm not able to reproduce this here. Can you please modify the example I posted here or send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
2. UndoneZoomed - It doesn't unzoom unless we unzoom it only from the chart that has zoomed it. The event handler is correctly called for the undozoomed event even when unzoomed from other charts, but it simply doesn't get the OrgChart.Axes.Bottom.Minimum and maximum reset to the unzoom levels unless the event is invoked by the same chart where zoom occured. Same behavior can be observed in the example you posted as well. Please suggest if there is any way to fix it. Its not a big problem for us, but it'd be nice to fix!
It works fine for me here using TeeChart version we posted last Friday at the client area with the last example code I posted here. Could you please check it works fine for you
3. Legend.click event works great. Thanks. How can i set the cursor to hand symbol when the mouse hovers over the legend?
You can implement MouseMove event like this:

Code: Select all

    Private Sub tChart1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        Dim MyChart As Steema.TeeChart.TChart = CType(sender, Steema.TeeChart.TChart)

        If MyChart.Legend.Clicked(e.X, e.Y) <> -1 Then
            MyChart.Cursor = Cursors.Hand
        Else
            MyChart.Cursor = Cursors.Default
        End If
    End Sub
4. Chart.Footer.Image somehow doesn't showup. I don't get any exception/error. But, it simply doesn't show up. I set the footer.image as follows.

Code:
teechart1.Footer.Image = My.Resources.myLogo
You need to do this:

Code: Select all

			tChart1.Footer.Visible = True
			tChart1.Footer.Text = " "
			tChart1.Footer.Transparent = False
			tChart1.Footer.Image = pictureBox1.Image
5. Metafile saving option:
When tried to save the image to wmf/emf formats, i get the following error. All other image formats work fine.

"Parameter is not valid"

My code is as follows
Code:
Case EMFFormat
Dim MetaFile As Steema.TeeChart.Export.MetafileFormat = teechart1.Export.Image.Metafile
MetaFile.Height = 500
MetaFile.Width = teechart1.Width
MetaFile.EMFFormat = True
MetaFile.Save(fileToSave & ".Emf")
This is most likely because you need to set EMFFormat like this:

Code: Select all

			metaFile.EMFFormat = System.Drawing.Imaging.EmfType.EmfOnly
6. I want to set the chart background to white while printing/saving to image. teechart1.Panel.Color = Color.White somehow not doing anything. Any suggestions?
Try this:

Code: Select all

			tChart1.Panel.Gradient.Visible = False
			tChart1.Panel.Color = Color.White
			tChart1.Walls.Back.Visible = False
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Tue Dec 23, 2008 6:47 am

Thanks for the solutions. I am very pleased to see that TeeChart component is very easy to use and equally powerful. I didn't have similar pleasent experience with other chart components i used previously (Nplot, Dundas, etc.).

The issue with the axistool went away when i changed the "sender" object to me.activecontrol. So, no need to further pursue this issue.

1. I uploaded the project to the upload page (file name is Test-TeeChartProj.zip ). The project has the compiled exes as well so that you can simply run and see the issue with undozoomed event.

2. Footer: I need to have both the text and image displayed in the footer. As you see from the uploaded project, such an attempt simply streaches the image.

3. On the uploaded test project, rightclick on a chart and choose print. You will get preview of multiple charts. How do i achieve the following?

a. I need to be able to print to multiple pages in case the whole print job "spills over" to more than one page.

b. I need to put border around the chart and have the footer (or user notes of length of about 250 chars) near the border.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 23, 2008 9:50 am

Hi asupriya,

Thanks for the example project.
1. I uploaded the project to the upload page (file name is Test-TeeChartProj.zip ). The project has the compiled exes as well so that you can simply run and see the issue with undozoomed event.
This can be solved implementing UndoneZoom event like this:

Code: Select all

    Private Sub tChart1_UndoneZoom(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim MyChart As Steema.TeeChart.TChart

        For i As Integer = 0 To panels.Length - 1
            MyChart = CType(panels(i).Controls.Item(0), Steema.TeeChart.TChart)
            MyChart.Axes.Bottom.Automatic = True
            MyChart.Axes.Left.Automatic = True
            MyChart.Refresh()
        Next
    End Sub
I have also implemented some other enhancements in your example. I'll send you .vb file by e-mail.
2. Footer: I need to have both the text and image displayed in the footer. As you see from the uploaded project, such an attempt simply streaches the image.
I'm not sure about what you are trying to achieve here but you could try doing something like this:

Code: Select all

    Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
        g.Draw(TChart1.Footer.ShapeBounds.X - PictureBox1.Image.Width, TChart1.Footer.ShapeBounds.Y, PictureBox1.Image)
    End Sub
I have also included this in your example.
3. On the uploaded test project, rightclick on a chart and choose print. You will get preview of multiple charts. How do i achieve the following?
You should create your PrintDocument like this:

http://www.teechart.net/support/viewtopic.php?t=5756
http://www.teechart.net/support/viewtopic.php?t=5490
a. I need to be able to print to multiple pages in case the whole print job "spills over" to more than one page.
You could try something like what I suggested here.
b. I need to put border around the chart and have the footer (or user notes of length of about 250 chars) near the border.
You could try something like this.

I also strongly recommend you to read Tutorial14 - Printing Charts, specially the Print previewing several Charts on one page and Mixing printed Chart output with other print output sections. You'll find the tutorials at TeeChart's program group.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Fri Dec 26, 2008 3:00 am

Narcis,

Thanks alot for the guidance. I really appreciate it.

1. The time lag in cursor sync. issue is persistent across machines with 1 GB RAM as well. I am uploading the same test project that has each of the charts with 18000 points and width of 2000. I also tried the cursortool1.fastcusor = true, but it is of no use as the charts are not redrawn, the cursor leaves its marks on the charts as it moves with mouse.
The elapse time (now visible as form's title) shows well above 7000ms on several "average" laptops/desktops.

Please suggest if there is a better way of sync.'ing the cursor.

Added on 29th Dec 2008

2. I tried to follow the document_PrintPage method that helps print multiple charts into multiple pages. I can get multiple pages, but it seems that somehow the e.Graphics.DrawImage is called "infinite" times even if i call it for four charts. Also, the charts are drawn one over the other. I am uploading slightly modified project that has implementation with e.Graphics.DrawImage in document_printpage event. Please suggest if i should do something different. The project file name uploaded via upload page is Test-TeeChartProj-29Dec2008.zip

3. Chart Alignment: Please see uploaded teeChartIsssue.ppt file. You suggested to set the MyChart.Axes.Left.Labels.CustomSize to large enough value so that the charts automatically align themselves. If you see the uploaded ppt file, all the charts start at the same point, but few of them start to slightly deviate from the others. I need them to be vertically aligned. Same behavior can be observed with the charts generated from the test project uploaded for point 2. I am setting fastline.drawallpoints to false and also treatNulls property to DoNotPaint style. I do not know if that makes any difference. But, it was the same case even if i don't set these properties.

Thanks for your help.

Added on 03 Jan 2009

1. How can i know if a chart is in viewable area of screen? I have several charts arranged in vertical manner and i am thinking that updating the cursor only the viewable charts will greatly reduce the lag in cursor movements. (Steema.TeeChart.TChart).IsAccessible property always return false for every chart when put in a loop.

The snippet of code is as follows:

Code: Select all

If CType(Panel2.Controls.Item(i), Steema.TeeChart.TChart).IsAccessible Then
                        CType(DestChart.Tools.Item(0), Steema.TeeChart.Tools.CursorTool).XValue = myXValue
                    End If
Added on 04 Jan 2009

1. I need to display 'Y' as a % of change value from a base value. Is there any easyway of doing it without hurting the performance when i havelarge number of points per chart and multiple charts (similar to test project that i uploaded on 26th Dec 2008)?
Last edited by asupriya on Mon Jan 05, 2009 2:53 am, edited 3 times in total.

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Tue Dec 30, 2008 1:21 pm

I am wondering how much more longer i have to wait for support.

Can someone provide some suggestions?

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Fri Jan 02, 2009 2:24 pm

Its almost a week and i am still waiting for someone to suggest some solution for my issues.

I thought support responds in about 2-3 business days and its getting really delayed.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Jan 05, 2009 9:13 am

Hi asupriya,

Sorry for the delayed reply. We will look at the issues you posted and get back to you ASAP.

For further issues it would be helpful if you started a new thread for each different issue, for example: one thread for cursor sync, another one for printing, etc. I think this way it should be easier to follow up for you and us.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jan 05, 2009 2:10 pm

asupriya,
asupriya wrote: Please suggest if there is a better way of sync.'ing the cursor.
My best suggestion is that you use one of your own original ideas which is to use custom axes instead of separate chart objects. You can then draw your own "cursor tool" on the chart as in the following example:

Code: Select all

  Private Sub InitializeChart()
    Dim chartWidth As Int32 = 1000
    Dim chartOffset As Int16 = 0
    Dim numCharts As Integer = 5
    Dim axis1 As Steema.TeeChart.Axis
    Dim i As Integer
    Dim myFastLine As Steema.TeeChart.Styles.FastLine

    'Define chart properties
    MyChart = New Steema.TeeChart.TChart()
    MyChart.Legend.Visible = False
    MyChart.Aspect.View3D = False
    MyChart.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Series
    MyChart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Right
    MyChart.Width = chartWidth
    MyChart.Height = numCharts * 150 'each axis is 150 pixel height
    MyChart.Header.Text = ""
    MyChart.Axes.Left.EndPosition = 0

    MyChart.Panel.MarginTop = 0
    MyChart.Panel.MarginBottom = 0
    MyChart.Axes.Left.Labels.CustomSize = 60

    MyChart.Axes.Left.MinimumOffset = 10
    MyChart.Axes.Left.MaximumOffset = 10
    MyChart.Axes.Bottom.MinimumOffset = 10
    MyChart.Axes.Bottom.MaximumOffset = 10
    MyChart.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
    MyChart.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit

    Me.Controls.Add(MyChart)

    Dim myStartPos As Double = 0.5
    Dim myChartSize As Double = (100 / numCharts) - 1

    For i = 0 To numCharts - 1

      axis1 = New Steema.TeeChart.Axis(MyChart.Chart) ' define an axis for this series
      MyChart.Axes.Custom.Add(axis1)
      axis1.Horizontal = False
      axis1.OtherSide = False
      axis1.Labels.CustomSize = 100
      axis1.Title.Angle = 90
      axis1.StartPosition = myStartPos
      axis1.EndPosition = (myStartPos + myChartSize) Mod 100
      myStartPos += (myChartSize + 0.4)

      myFastLine = New Steema.TeeChart.Styles.FastLine()
      MyChart.Series.Add(myFastLine)

      myFastLine.DrawAllPoints = True
      myFastLine.CustomVertAxis = axis1
      myFastLine.FillSampleValues()

      AddHandler MyChart.AfterDraw, AddressOf tChart1_AfterDraw
      AddHandler MyChart.MouseMove, AddressOf tChart1_MouseMove
    Next
  End Sub

  Dim myPoint As Point

  Private Sub tChart1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    myPoint = e.Location
    Dim text As String = "XValue: " + MyChart.Axes.Bottom.CalcPosPoint(myPoint.X).ToString()
    MyChart.Header.Text = text
    MyChart.Invalidate()
  End Sub

  Private Sub tChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D)
    Dim top As Integer = MyChart.Chart.ChartRect.Top
    Dim bottom As Integer = MyChart.Chart.ChartRect.Bottom

    g.VerticalLine(myPoint.X, top, bottom)
  End Sub
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jan 05, 2009 2:12 pm

asupriya,
asupriya wrote: Added on 29th Dec 2008
If you follow my above suggestion, which I strongly suggest you do, then these issues should resolves themselves.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jan 05, 2009 2:14 pm

asupriya,
asupriya wrote: Added on 03 Jan 2009
Again, using custom axes instead of separate tchart objects will make this unnecessary.
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Mon Jan 05, 2009 2:47 pm

asupriya,
asupriya wrote: Added on 04 Jan 2009

1. I need to display 'Y' as a % of change value from a base value. Is there any easyway of doing it without hurting the performance when i havelarge number of points per chart and multiple charts (similar to test project that i uploaded on 26th Dec 2008)?
Of course, the more operations you perform the slower your chart is going to be. This is inevitable.

You can get the YValues by using code similar to the following (can be used in the example I gave earlier):

Code: Select all

  Dim myPoint As Point
  Dim myText As String

  Private Sub tChart1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    myPoint = e.Location
    Dim xIndex As Integer = MyChart(0).XValues.IndexOf(Steema.TeeChart.Utils.Round(MyChart.Axes.Bottom.CalcPosPoint(myPoint.X)))
    If xIndex > -1 Then
      myText = MyChart(0).YValues(xIndex).ToString()
    End If
    MyChart.Header.Text = "Series(0) YValue: " + myText
    MyChart.Invalidate()
  End Sub
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Post by asupriya » Tue Jan 06, 2009 2:31 pm

Thanks. I think separate chart objects seems to be the choice of the user and no options in that regard.
Added on 03 Jan 2009

1. How can i know if a chart is in viewable area of screen? I have several charts arranged in vertical manner and i am thinking that updating the cursor only the viewable charts will greatly reduce the lag in cursor movements. (Steema.TeeChart.TChart).IsAccessible property always return false for every chart when put in a loop.

The snippet of code is as follows:
Code:
If CType(Panel2.Controls.Item(i), Steema.TeeChart.TChart).IsAccessible Then
CType(DestChart.Tools.Item(0), Steema.TeeChart.Tools.CursorTool).XValue = myXValue
End If
Please answer this question as it holds key to the solution to many of my problems.

asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

Multi-chart issue

Post by asupriya » Tue Jan 06, 2009 2:36 pm

Please also suggest solution to multi-chart printing and chart x-axis values alignment issues
Added on 29th Dec 2008

2. I tried to follow the document_PrintPage method that helps print multiple charts into multiple pages. I can get multiple pages, but it seems that somehow the e.Graphics.DrawImage is called "infinite" times even if i call it for four charts. Also, the charts are drawn one over the other. I am uploading slightly modified project that has implementation with e.Graphics.DrawImage in document_printpage event. Please suggest if i should do something different. The project file name uploaded via upload page is Test-TeeChartProj-29Dec2008.zip

3. Chart Alignment: Please see uploaded teeChartIsssue.ppt file. You suggested to set the MyChart.Axes.Left.Labels.CustomSize to large enough value so that the charts automatically align themselves. If you see the uploaded ppt file, all the charts start at the same point, but few of them start to slightly deviate from the others. I need them to be vertically aligned. Same behavior can be observed with the charts generated from the test project uploaded for point 2. I am setting fastline.drawallpoints to false and also treatNulls property to DoNotPaint style. I do not know if that makes any difference. But, it was the same case even if i don't set these properties.

Post Reply