GalleryPanel - activate specific chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Adam
Newbie
Newbie
Posts: 17
Joined: Tue Nov 06, 2012 12:00 am

GalleryPanel - activate specific chart

Post by Adam » Fri Feb 15, 2013 8:11 am

Hello,

I'm using GalleryPanel to show several predefined charts with different series types.

Is it possible to select (in runtime) a specific chart type based on a saved parameter? I display GalleryPanel window several times and I want to keep last selection active.

Setting SelectedChart to a specific value doesn't seem to work. Though SelectedChart property is set correctly but I can't see it in the window (the border of the specific chart is not highlighted).
Sample code in vb.net looks like this:

For Each galleryChart As GalleryChart In _galleryPanel.Charts
If galleryChart(0).GetType() Is expectedTeeChartType Then
_galleryPanel.SelectedChart = galleryChart
Exit For
End If
Next

regards, Adam

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

Re: GalleryPanel - activate specific chart

Post by Sandra » Fri Feb 15, 2013 4:06 pm

Hello Adam,

I have made a simple code using a GalleryChart and it works in correct way for me:

Code: Select all

    Private lineSeries1 As Steema.TeeChart.Styles.Line
    Private galleryPanel1 As GalleryPanel
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        InitializeChart()

    End Sub

    Private Sub InitializeChart()

        lineSeries1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
        lineSeries1.FillSampleValues(10)
        galleryPanel1 = New GalleryPanel()
        Me.Controls.Add(galleryPanel1)
        galleryPanel1.Left = TChart1.Left - 200
        galleryPanel1.Top = TChart1.Top
        galleryPanel1.Width = 200
        galleryPanel1.Height = TChart1.Height
        galleryPanel1.NumRows = 3
        galleryPanel1.NumCols = 2

        galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Line))
        galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Bar))
        galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Points))
        galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Area))

        AddHandler galleryPanel1.OnChangeChart, AddressOf galleryPanel1_OnChangeChart
        AddHandler galleryPanel1.OnSubSelected, AddressOf galleryPanel1_OnSubSelected

    End Sub

    Private Sub galleryPanel1_OnChangeChart(sender As Object, e As System.EventArgs)
        Dim s As Steema.TeeChart.Styles.Series = TChart1(0)
        Steema.TeeChart.Styles.Series.ChangeType(s, galleryPanel1.SelectedChart(0).[GetType]())
    End Sub

    Private Sub galleryPanel1_OnSubSelected(sender As Object, e As System.EventArgs)
        galleryPanel1.SetSubSelected(TChart1(0), CInt(galleryPanel1.SelectedChart.Tag))
    End Sub
Could you tell us if it help you to solve your problem? If it doesn't help you, please send us a simple code because we can try to reproduce your problem.

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

Adam
Newbie
Newbie
Posts: 17
Joined: Tue Nov 06, 2012 12:00 am

Re: GalleryPanel - activate specific chart

Post by Adam » Mon Feb 18, 2013 9:36 am

Hello Sandra.

No doubt that your code works, I found the same sample in Feature demo.
But this is not what I was asking for. This code does not show how to select specific chart type in gallery panel.
Your code changes series type of a sample chart that is shown next to gallery panel when one of the chart type in gallery panel is clicked.

My question was how to programatically select on of the chart types on the gallery panel itself (without any sample chart shown).

I want to show a gallery panel but with 'Bar' styles chart already selected, then in your code it would be something like this:
...
galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Line))
galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Bar))
galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Points))
galleryPanel1.CreateGallerySeries(GetType(Steema.TeeChart.Styles.Area))
...
galleryPanel1.SelectedChart = galleryPanel.Charts(1) <---- this assignment does not work. Well, the property is set correctly, but I can't see it on the screen. Bar series chart is not selected (highlighted).

I attached two sample screenshots.
selected.png - this is how I would like gallery panel to look like
notselected.png - this is how it looks now though I set galleryPanel1.SelectedChart property to a correct value.

regards, Adam
Attachments
notselected.png
notselected.png (18.47 KiB) Viewed 9419 times
selected.png
selected.png (21.03 KiB) Viewed 9418 times

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

Re: GalleryPanel - activate specific chart

Post by Sandra » Tue Feb 19, 2013 4:45 pm

Hello Adam,

Sorry for the delay. The property you are using to set the Chart(galleryPanel1.Charts(1)) is correct, but you must change the style of subChart as I make in next c# code:

Code: Select all

    private void InitializeChart()
        {
            tChart1.Series.Add(lineSeries1 = new Steema.TeeChart.Styles.Line());
            lineSeries1.FillSampleValues(10);
            galleryPanel1 = new GalleryPanel();
            this.Controls.Add(galleryPanel1);
            galleryPanel1.Left = tChart1.Left - 200;
            galleryPanel1.Top = tChart1.Top;
            galleryPanel1.Width = 200;
            galleryPanel1.Height = tChart1.Height;
            galleryPanel1.NumRows = 3;
            galleryPanel1.NumCols = 2;
            galleryPanel1.CreateGallerySeries(typeof(Steema.TeeChart.Styles.Line));
            galleryPanel1.CreateGallerySeries(typeof(Steema.TeeChart.Styles.Bar));
            galleryPanel1.CreateGallerySeries(typeof(Steema.TeeChart.Styles.Points));
            galleryPanel1.CreateGallerySeries(typeof(Steema.TeeChart.Styles.Area));
            galleryPanel1.OnChangeChart += new EventHandler(galleryPanel1_OnChangeChart);
            galleryPanel1.OnSubSelected += new EventHandler(galleryPanel1_OnSubSelected);
          
            SetDefaultSelect();
            tChart1.Draw();

        }
        private void SetDefaultSelect()
        {
            galleryPanel1.SelectedChart = galleryPanel1.Charts[0];
            galleryPanel1.SelectedChart.Aspect.View3D = true;
            galleryPanel1.SelectedChart.Panel.Gradient.Visible = true;
            galleryPanel1.SelectedChart.Panel.Gradient.Direction = LinearGradientMode.Vertical;
            galleryPanel1.SelectedChart.Panel.Gradient.StartColor = Color.Silver;

            galleryPanel1.SelectedChart.Aspect.Rotation = 345;
            galleryPanel1.SelectedChart.Header.Font.Bold = true;
            galleryPanel1.SelectedChart.Header.Font.Color = Color.Black;
            galleryPanel1.SelectedChart.Header.Font.Size = 9;
            galleryPanel1.SelectedChart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.Raised;
				
        }

        private void galleryPanel1_OnChangeChart(object sender, System.EventArgs e)
        {
           
            Steema.TeeChart.Styles.Series s = tChart1[0];
            Steema.TeeChart.Styles.Series.ChangeType(ref s, galleryPanel1.SelectedChart[0].GetType());
        }

        private void galleryPanel1_OnSubSelected(object sender, System.EventArgs e)
        {
            galleryPanel1.SetSubSelected(tChart1[0], (int)galleryPanel1.SelectedChart.Tag);
        }
Could you tell us if previous code works 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

Adam
Newbie
Newbie
Posts: 17
Joined: Tue Nov 06, 2012 12:00 am

Re: GalleryPanel - activate specific chart

Post by Adam » Wed Feb 20, 2013 10:09 am

Thanks Sandra, now it works.

But, IMHO, SelectedChart property setter should do this code "for us", so we don't have to know all these visual panels, gradients, levels changes. But it's just my suggestion.

Thanks again,
Adam

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

Re: GalleryPanel - activate specific chart

Post by Sandra » Wed Feb 20, 2013 2:34 pm

Hello Adam,

I am glad my suggestion code works in your end :D.

On the other hand, I have added your request in wish-list with number [TF02016520] we will try to consider its inclusion to upcoming versions of TeeChartFor.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

Adam
Newbie
Newbie
Posts: 17
Joined: Tue Nov 06, 2012 12:00 am

Re: GalleryPanel - activate specific chart

Post by Adam » Mon Feb 25, 2013 1:28 pm

Hello Sandra.

One more question with gallery panel.
You told me how to select (highlight) specific chart in gallery panel.
But I also want to change sub-type of the chart (in run-time).

I can see that chart sub-type is passed via SelectedChart.Tag property and it's used in OnSubSelected.

So I want to select (highlight) specific chart type and also sub-type (passed to procedure as a integer parameter). How can I do this?

regards, Adam

Adam
Newbie
Newbie
Posts: 17
Joined: Tue Nov 06, 2012 12:00 am

Re: GalleryPanel - activate specific chart

Post by Adam » Tue Feb 26, 2013 1:08 pm

I already found a solution.
I just had to change SelectedChart series based on saved tag parameter.

Adam

Post Reply