Multiple graph management

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Yacu
Newbie
Newbie
Posts: 31
Joined: Tue Dec 23, 2008 12:00 am

Multiple graph management

Post by Yacu » Wed Feb 20, 2013 5:03 pm

I am updating to VB .NET an old application written in VB6 which created a bunch of graphs, positioned them on screen using a customizable pattern and managed them using an index based approach (Each graph was created at runtime and assigned an index which was used for individual editing, zooming, etc...)
Since index controls have dissapeared in .NET as such I wonder which would be the best way to replicate the same behaviour
I am attaching a screen capture so that you can appreciate what I'm trying to replicate.
Thanks in advance
Multiple graph.jpg
Multiple graph.jpg (42.09 KiB) Viewed 13945 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple graph management

Post by Sandra » Thu Feb 21, 2013 12:15 pm

Hell Yacu,

Would be very grateful if you can send us your VB6 code because we can try to reproduce exactly the behavior as it have in VB6 and can to find a solution in .Net.

Thanks,
Best Regards,
Sandra Pazos / 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

Yacu
Newbie
Newbie
Posts: 31
Joined: Tue Dec 23, 2008 12:00 am

Re: Multiple graph management

Post by Yacu » Wed Mar 06, 2013 6:31 pm

I'm sending you an excerpt of the code which produced the graphs in VB6
GCuadro(0) is a fomatted graph which was used as a model for the rest:

numerodeviñetas = nfilas * ncolumnas
hmarco = Marco_graficos.Height
wmarco = Marco_graficos.Width
left1 = 50: top1 = 150
hgrafico = (hmarco - (nfilas * top1)) / nfilas
wgrafico = (wmarco - (ncolumnasporpantalla * left1)) / ncolumnasporpantalla

With Gcuadro(0)
.Visible = True
.Left = left1: .Top = top1
.Width = wgrafico: .Height = hgrafico
End With
For i = 1 To numerodeviñetas - 1: Load Gcuadro(i): Gcuadro(i).Visible = False: Next i
columna = 0
For i = 0 To numerodeviñetas - 1 Step nfilas 'Dibuja los todos los gráficos de una columna fila a fila
For nf = 1 To nfilas
With Gcuadro(i + (nf - 1))
.Left = left1 + (columna * (left1 + wgrafico))
.Top = (nf * top1) + ((nf - 1) * hgrafico)
'.Visible = True
End With
Next nf
columna = columna + 1
Next i

'Charts load
Open App.Path + "\config_TR.txt" For Input As #1
Do While Not EOF(1)
Input #1, numerodecuadro, codigo_estacion, nombre_estacion
If existefichero(DirBasesTiempoReal + codigo_estacion + "_TR.mdb") Then
tiempoini = Now
dtStart = GetTickCount
Call Prepara_grafico_TR(Gcuadro(numerodecuadro), nombre_estacion, "linea", qfechai, qfechaf, codigo_estacion, sqlnivel2, CampoP, campoH_Q)
End If
Loop
Close 1


The question again is how can I define in .NET an array of charts which can be addressed through the particular index of any one chart

What I'm trying to do in VB.NET should look like this:

FileOpen(1, App_Path() & "\" + "config_TR.txt", OpenMode.Input)
xxx = LineInput(1) : datoslinea = xxx.Split(" ") : nfilas = Val(datoslinea(0))
xxx = LineInput(1) : datoslinea = xxx.Split(" ") : ncolumnas = Val(datoslinea(0))
numerodeviñetas = nfilas * ncolumnas
hgrafico = (hmarco - (nfilas * top1)) / nfilas
wgrafico = (wmarco - (ncolumnasporpantalla * left1)) / ncolumnasporpantalla

Dim pList As List(Of Steema.TeeChart.Chart) = New List(Of Steema.TeeChart.Chart)()

columna = 0
For i = 0 To numerodeviñetas - 1 Step nfilas 'Dibuja los todos los gráficos de una columna fila a fila
For nf = 1 To nfilas
Dim GraficoTR As New Steema.TeeChart.Chart
GraficoTR.Chart.Parent = GCuadro

GraficoTR.Tag = i
pList.Add(GraficoTR)
' I need an AddHandler here to zoom or edit the graph indexed i
Next
columna = columna + 1
Next i

Yacu
Newbie
Newbie
Posts: 31
Joined: Tue Dec 23, 2008 12:00 am

Re: Multiple graph management

Post by Yacu » Wed Mar 06, 2013 6:37 pm

By the way, Gcuadro(0) template looks like this
Gcuadro(0).jpg
Gcuadro(0).jpg (19.36 KiB) Viewed 13934 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple graph management

Post by Sandra » Thu Mar 07, 2013 12:07 pm

Hello Yacu,

Thanks for information. I have made a simple code with a list that has 4 Charts and I can access to the index chart and work with all charts without problems:

Code: Select all

    Private listChart As List(Of Steema.TeeChart.TChart)
    Private Sub InitializeChart()
        TChart1.Visible = False
        listChart = New List(Of Steema.TeeChart.TChart)()

        For i As Integer = 0 To 3
            listChart.Add(New Steema.TeeChart.TChart())
            listChart(i).Tag = i
            listChart(i).Header.Text = "TeeChart" & i.ToString()
            listChart(i).Height = 150
            listChart(i).Width = 350
            Me.Controls.Add(listChart(i))

            If i Mod 2 = 0 Then
                listChart(i).Left = 100   (i * 200)
                listChart(i).Top = 70
            ElseIf i Mod 3 = 0 Then
                listChart(i).Left = listChart(2).Left
                listChart(i).Top = 100   (i * 50)
            Else
                listChart(i).Left = listChart(0).Left
                listChart(i).Top = 100   (i * 150)
            End If
        Next

        Dim line As Steema.TeeChart.Styles.Line = New Steema.TeeChart.Styles.Line(listChart(0).Chart)
        line.FillSampleValues()
    End Sub
Could you please, tell us if previous code help you to achieve as you want?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Yacu
Newbie
Newbie
Posts: 31
Joined: Tue Dec 23, 2008 12:00 am

Re: Multiple graph management

Post by Yacu » Thu Mar 07, 2013 4:50 pm

Thank you, Sandra, the code that you sent works, it creates graph in a tile fashion as I need.
Can you tell me how can I edit a particular graph (find its index and operate with it) using the mouse to select it?
In my case, there will be more graphs than a screen can handle, many of them will be hidden because of the left coordinate and I will only operate with one single graph in the visibility zone.

Thanks again

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple graph management

Post by Sandra » Fri Mar 08, 2013 12:04 pm

Hello Yacu,

I think you can access to concretely chart of list using the click and double click event or Mouse events as do in next simple code:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        List<Steema.TeeChart.TChart> listChart;
        private void InitializeChart()
        {
            tChart1.Visible = false;
            listChart = new List<TChart>();

            for (int i = 0; i < 4; i++)
            {
                listChart.Add(new Steema.TeeChart.TChart());
                listChart[i].Tag = i;
                listChart[i].Header.Text = "TeeChart" + i.ToString();
                listChart[i].Height = 150;
                listChart[i].Width = 350;
                this.Controls.Add(listChart[i]);

                if (i % 2 == 0)
                {
                    listChart[i].Left = 100 + (i * 200);
                    listChart[i].Top = 70;
                }
                else if (i % 3 == 0)
                {
                    listChart[i].Left = listChart[2].Left;
                    listChart[i].Top = 100 + (i * 50);
                }
                else
                {
                    listChart[i].Left = listChart[0].Left;
                    listChart[i].Top = 100 + (i * 150);
                }
        
                listChart[i].Click += new EventHandler(Form1_Click);
                Steema.TeeChart.Styles.Line line = new Line(listChart[0].Chart);
                line.FillSampleValues();

            }
        }

        void Form1_Click(object sender, EventArgs e)
        {
            if (sender is Steema.TeeChart.TChart)
            {
                (sender as Steema.TeeChart.TChart).ShowEditor();
            }
        }
Could you tell us if previous code works in your end?
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Yacu
Newbie
Newbie
Posts: 31
Joined: Tue Dec 23, 2008 12:00 am

Re: Multiple graph management

Post by Yacu » Fri Mar 08, 2013 12:48 pm

With your suggestion I found a way that works beautifully, I just had to add a handler and a subroutine to handle the mouse click on the chart.
Thank you very much, you can now close the request

AddHandler listChart(i).MouseDown, AddressOf SELECCIONGRAFICO_mousedown
Me.Controls.Add(listChart(i))

Private Sub SELECCIONGRAFICO_mousedown(ByVal sender As Object, ByVal e As EventArgs)
Dim i As Short = sender.tag
If listChart(i).Height >= 150 Then
listChart(i).Height = 50
listChart(i).Width = 250
Else
listChart(i).Height = 150
listChart(i).Width = 350
End If
End Sub

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple graph management

Post by Sandra » Fri Mar 08, 2013 12:58 pm

Hello Yacu,

Thanks for your information it sure help other clients. On the other hand, I am glad that you have closed your request :D.

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply