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
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.
Since I use databinding for populating the series, I can easly change the spline into something else when I detect only 1 point.
thanks
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.
I thought about using the Bubble instead, but I can't fnd out how to set the size of the buble itself.
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 = 10, YValue = 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.
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);
}
...
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;
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 = 5, BubbleSize = 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.
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?
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.
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.
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.