Tooltip on SplineSeriesDefinition doesn't work

4 posts, 0 answers
  1. Davide
    Davide avatar
    3 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2012 Link to this post

    Hi everyone,
    I'm desperately trying to show a tooltip on a SplineSeriesDefinition, but it doesn't work. I've read the most of the related post but unluckily, I wasn't able to fix my problem. I have a DataSeries populated with several DataPoint. I tried to set the tooltip on every DataPoint, on the SplineSeriesDefinition and even on the SeriesMapping unsuccessfully. All that I want is a tooltip when mouse is over the curve. Please, I urgently need to fix this problem. Might someone help me, please?
    Below there's the definition of the RadChart in my XAML code, and a piece of code of my CS file:

    <telerik:RadChart Name="radChartCurva" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Left" Grid.Row="0" />

    foreach (DatosGrafica graf in media)
                            {
                                DataPoint dp = new DataPoint(graf.valorX, graf.ValorPunto);
                                dp.Tooltip = graf.ValorPunto.ToString();
                                seriesCurva.Add(dp);
                                seriesMedia.Add(new DataPoint(graf.valorX, graf.Media));
                            }
                            seriesCurva.LegendLabel = StringResources.curve;
                            seriesMedia.LegendLabel = StringResources.average;
                            
                            SplineSeriesDefinition serieDef = new SplineSeriesDefinition();
                            SplineSeriesDefinition serieDef2 = new SplineSeriesDefinition();
                            serieDef.ShowItemLabels = false;
                            serieDef.ShowPointMarks = false;
                            serieDef.ShowItemToolTips = true;
                            serieDef2.ShowItemLabels = false;
                            serieDef2.ShowPointMarks = false;
                            serieDef2.ShowItemToolTips = true;


                            seriesCurva.Definition = serieDef;
                            seriesMedia.Definition = serieDef2;


                            SeriesMapping sm = new SeriesMapping();
                            sm.SeriesDefinition = serieDef;
                            sm.ItemMappings.Add(new ItemMapping("XValue",DataPointMember.XValue));
                            sm.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));
                            this.radChartCurva.SeriesMappings.Add(sm);
                            this.radChartCurva.DefaultView.ChartArea.DataSeries.Add(seriesMedia);
                            this.radChartCurva.DefaultView.ChartArea.DataSeries.Add(seriesCurva);

    What's wrong with my code?

    Thanks in advance guys :-)
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 26 Oct 2012 Link to this post

    Hi Davide,

    Thank you for the attached code snippets, I was able to create a project based on this code. I had to alter a few things in order to compile and run the project. When I ran it the first time I saw an empty chart with no series in it. Then I commented one line and I did see a chart with two spline series (one on top of the other) displayed properly. When I hovered the mouse over the line - a tooltip showed up as expected.

    I have attached the project in mind, for your reference. This is the line that I commented:
    //this.radChartCurva.SeriesMappings.Add(sm);

    In the given context this series mapping does nothing so it is safe to remove it. Do try the attachment and let us know how it goes.

    All the best,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Davide
    Davide avatar
    3 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Hi Petar,

    thank you very much for your help! It was very useful! I forgot to add this piece of code, and comparing your code to mine I found that it makes not apper the Tooltip:

    radChartCurva.Content = "\t " + StringResources.brand + ": " + drw.Marca; 

    When I comment this line the tooltip appears. I tried to add this line to your code too, and your tooltip didn't work anymore. Is it a bug or is it its normal behaviour? What do you think about it? Is there any chance to show both the Content of the RadChart and the tooltip of a Spline?

    Thank you very much Petar.

    I owe you one! :D


                            
  5. Davide
    Davide avatar
    3 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Hi Petar,

    maybe I found a solution. I replaced radChartCurva.Content with radChartCurva.DefaultView.ChartTitle.Content. Now everything works fine!!
    Again, thank you very much for your help! :)

    Best regards!
Back to Top