This is a migrated thread and some comments may be shown as answers.

Single Point data serie

11 Answers 69 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
andrea bellagamba
Top achievements
Rank 1
andrea bellagamba asked on 04 Sep 2009, 08:17 AM
Hi ,
I am using a chart with SplineSeriesDefinition databinding.
My probelm is that when the serie contains only 1 point, than the chart does not show anything.
I would expect a single PointMark being displayed.

I am missing setting some specific property of the chart?

11 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 08 Sep 2009, 11:27 AM
Hi andrea,

This is the default behavior of RadChart because at least two points are needed to render a spline. Unfortunately, there is no property exposed to make the chart render a single point mark in case of a single data point.  I will forward your view to our developers for further consideration.

Sincerely yours,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrea bellagamba
Top achievements
Rank 1
answered on 08 Sep 2009, 09:47 PM
ok, thanks, can you suggest me which kind of chart serie I shall use in case I have only one point?
Since I use databinding for populating the series, I can easly change the spline into something else when I detect only 1 point.
thanks
0
Velin
Telerik team
answered on 11 Sep 2009, 11:26 AM
Hello Andrea,

In case there is only one data point you can switch the series definition to BarSeriesDefinition. Similar behavior can be seen in this online example.

Hope this helps.

Greetings,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrea bellagamba
Top achievements
Rank 1
answered on 14 Sep 2009, 08:28 AM
Unfortunatly the BarSeriesDefinition is not a good solution in may case, since I am using Mutliple series in the same chart, and it would be confusing to have SPlines and Bar together.
I thought about using the Bubble instead, but I can't fnd out how to set the size of the buble itself.
0
Velin
Telerik team
answered on 16 Sep 2009, 12:46 PM
Hello Andrea,

You can set up a bubble series this way:
            DataSeries s = new DataSeries(); 
            BubbleSeriesDefinition bbl = new BubbleSeriesDefinition(); 
            bbl.BubbleSizeRepresents = BubbleSizeRepresentation.Diameter; 
            hb.BubbleSizeRelative = false
            s.Definition = bbl
 
            s.Add(new DataPoint() { BubbleSize = 10YValue = 4562 }); 

Or if you are data binding RadChart you will need additional ItemMapping for your bubble SeriesMapping:
            BubbleSeriesDefinition bbl = new BubbleSeriesDefinition(); 
            bbl.BubbleSizeRepresents = BubbleSizeRepresentation.Diameter; 
            bbl.BubbleSizeRelative = false
 
            SeriesMapping sm = new SeriesMapping(); 
            sm.SeriesDefinition = bbl
            ItemMapping yim = new ItemMapping("YValue", DataPointMember.YValue); 
            ItemMapping bsim = new ItemMapping("BubbleSize", DataPointMember.BubbleSize); 
            sm.ItemMappings.Add(yim); 
            sm.ItemMappings.Add(bsim); 

 Hope this will help.

Sincerely yours,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrea bellagamba
Top achievements
Rank 1
answered on 17 Sep 2009, 12:20 PM
HI,

 I tried your suggestion but still teh chart is showing nothig:
Here is how I create the SeriesMapping:

...

                List<List<StatisticsResponse>> statsDay1 = new List<List<StatisticsResponse>>();                
                int collectionIndex = 0;
                foreach (StatisticResponseChartSerie srcs in _allStatisticsResponses)
                {
                    string name = srcs.Name;
                    if (collectionIndex == 0)
                        name = _appResources.Get(srcs.Name);

                    var serie = SerieDefinition(name, srcs.Response);
                    serie.CollectionIndex = collectionIndex++;
                    _chart.SeriesMappings.Add(serie);
                    _displayingDataCounter++;
                    statsDay1.Add(srcs.Response);
                }

                _chart.ItemsSource = statsDay1;
...


protected SeriesMapping SerieDefinition(string serieName, List<StatisticsResponse> responses)
        {
            SeriesMapping seriesMapping = new SeriesMapping();
            seriesMapping.LegendLabel = serieName;
           

            if (responses.Count > 1)
            {
                //create a line if there is more then 1 point
                seriesMapping.SeriesDefinition = new SplineSeriesDefinition();
                seriesMapping.SeriesDefinition.ShowItemLabels = false;
                seriesMapping.SeriesDefinition.ShowItemToolTips = true;
                seriesMapping.SeriesDefinition.DefaultLabelFormat = "N0";
                seriesMapping.SeriesDefinition.Appearance.StrokeThickness = 2d;
                ItemMapping itemMappingY = new ItemMapping("Clicks", DataPointMember.YValue);
                seriesMapping.ItemMappings.Add(itemMappingY);
            }
            else
            {
                if (responses.Any())
                {
                    //create a bubble if there is only 1 point
                    BubbleSeriesDefinition bbl = new BubbleSeriesDefinition();                   
                    bbl.BubbleSizeRepresents = BubbleSizeRepresentation.Diameter;
                    bbl.BubbleSizeRelative = false;

                    seriesMapping.SeriesDefinition = bbl;
                    seriesMapping.SeriesDefinition.ShowItemLabels = false;
                    seriesMapping.SeriesDefinition.ShowItemToolTips = true;
                    ItemMapping yim = new ItemMapping("YValue", DataPointMember.YValue);
                    ItemMapping bsim = new ItemMapping("BubbleSize", DataPointMember.BubbleSize);
                    seriesMapping.ItemMappings.Add(yim);
                    seriesMapping.ItemMappings.Add(bsim);
                }
            }
            return seriesMapping;

0
Velin
Telerik team
answered on 22 Sep 2009, 10:34 AM
Hello Andrea,

Please, find attached a simple application demonstrating this behavior. Here is the code behind:
public partial class MainPage : UserControl 
    { 
        public MainPage() 
        { 
            InitializeComponent(); 
 
            PopulateChart(GetLineSeriesMapping(), GetMultipleDataPoints()); 
        } 
 
        private void PopulateChart(SeriesMapping m, IList<MyData> s) 
        { 
            RadChart1.SeriesMappings.Clear(); 
            RadChart1.SeriesMappings.Add(m); 
            RadChart1.ItemsSource = s; 
        } 
 
        SeriesMapping GetLineSeriesMapping() 
        { 
            SeriesMapping m = new SeriesMapping(); 
            m.SeriesDefinition = new LineSeriesDefinition(); 
            m.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); 
            return m; 
        } 
 
        SeriesMapping GetBubbleSeriesMapping() 
        { 
            SeriesMapping m = new SeriesMapping(); 
            m.SeriesDefinition = new BubbleSeriesDefinition() { BubbleSizeRelative = false }; 
            m.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); 
            m.ItemMappings.Add(new ItemMapping("BubbleSize", DataPointMember.BubbleSize)); 
            return m; 
        } 
 
        IList<MyData> GetSingleDataPoint() 
        { 
            List<MyData> result = new List<MyData>(); 
            result.Add(new MyData() { YValue = 5BubbleSize = 10 }); 
 
            return result; 
        } 
 
        IList<MyData> GetMultipleDataPoints() 
        { 
            List<MyData> result = new List<MyData>(); 
            result.AddRange(new[] { new MyData(){YValue=1},  
               new MyData(){YValue=2},new MyData(){YValue=3},new MyData(){YValue=4},new MyData(){YValue=5} }); 
 
            return result; 
        } 
 
        private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            PopulateChart(GetBubbleSeriesMapping(), GetSingleDataPoint()); 
        } 
 
    } 
 
    public class MyData 
    { 
        public double YValue { get; set; } 
        public double BubbleSize { get; set; } 
    } 


All the best,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrea bellagamba
Top achievements
Rank 1
answered on 22 Sep 2009, 08:19 PM
Hi,
 very nice of you trying to help me, but this is still not solving my problem.

I have a multiple series chart.
The series data,  is made by a collection of DateTime (X axis) and a numeric value (Y axis)
the data is dynamically binded.

Now the problem is that radChart does not show anything when a serie contains a single point.
My case has often a series with single points.

the idea of using the bubble serie is good.
But in your example you showe either a Bubble serie or a Spline, but I need to show both at the same time.
How would you do that?
0
Dwight
Telerik team
answered on 25 Sep 2009, 07:11 AM
Hi andrea,

You can add multiple series mappings at the same time:
RadChart1.SeriesMappings.Clear(); 
RadChart1.SeriesMappings.Add(splineSeriesMapping); 
RadChart1.SeriesMappings.Add(bubbleSeriesMapping); 

Best wishes,
Evtim
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrea bellagamba
Top achievements
Rank 1
answered on 25 Sep 2009, 08:51 AM

I figure that out thanks.
 the problem is the I databind the ItemSource, but i f define a bubble serie the way you hav esuggested and a spline serie teh way you have define, and add them in the chart seriesMapping list, the moment I go and bind teh data, I get an error becasue the itemsmapping is different.

 

I don't Understand why you don't make the splice display a single point, I guess it will an isssue for many people.

0
Velin
Telerik team
answered on 30 Sep 2009, 10:49 AM
Hi andrea,

Thanks for the suggestion. Our developers will consider the possible ways to enable a single data point spline rendering.

You can try to clear and repopulate the series mappings of RadChart to ensure you have the right series mapping.

Hope this helps.

Sincerely yours,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
andrea bellagamba
Top achievements
Rank 1
Answers by
Velin
Telerik team
andrea bellagamba
Top achievements
Rank 1
Dwight
Telerik team
Share this question
or