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

line series doesn't display properly with 2 bar series

6 Answers 155 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jeffrey
Top achievements
Rank 1
Iron
Jeffrey asked on 20 Feb 2015, 09:37 AM
hi
in my chart, i have two bar series and two line series and i want to the points of each line series be displayed in the middle of each bar series, but actually the points of the line series are displayed in the middle of the two bars. i have attached the picture.

6 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 23 Feb 2015, 12:49 PM
Hi Jeffrey,

This is not supported out of the box and it is also control's normal behavior. The reason why the line series point is drawn in the middle, between your two bar series items is because this is where your data point is located.

In order to workaround that, I would first suggest you to use the newer chart control - ChartView. Second, you should set a margin to each line series which depends on the number of your data points and plot area size. I have attached a sample project using this approach. Please note that the sample assumes that all series have the same categories count. Furthermore the workaround will not work well in case you have zooming enabled.

Regards,
Peshito
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jeffrey
Top achievements
Rank 1
Iron
answered on 25 Feb 2015, 06:15 AM
Thank you Peshito, this really helps me.
0
sai
Top achievements
Rank 1
answered on 19 Aug 2015, 09:27 AM

Hi telerik team,

 I have issue with line graph in my application.

In the graph i have some data points with same values. in this case its really giving issue by displaying same values in around at data point.

 

please find the attached screen and give your valuble solution to rectify the same.

0
Peshito
Telerik team
answered on 20 Aug 2015, 07:43 AM
Hello,

In order to have your label values more readable, you could use the SmartLabels feature of the chart. You can find this feature demonstrated in our WPFdemos ChartView -> SmartLabels example.

As for the multiple zeros to be displayed as one, this is not supported out of the box and you could use the LabelDefinition property along with a converter to handle the displaying of the zero labels.

Hope this helps.

Regards,
Peshito
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
sai
Top achievements
Rank 1
answered on 20 Aug 2015, 08:53 AM

Hi,

 

I have already implemneted smartlabel for my graps.

But only the problem is displaying same label multiple times.

As you suggested with labeldefinition and converter.its not really going to help.

Why because this problem is not only for zero "0" if nay other values also if the data points have same value its displaying many times around the single point.

is there any other alternate option we have to display the single label when the datapoints are same.?

0
Peshito
Telerik team
answered on 24 Aug 2015, 01:00 PM
Hello,

Another option would be to use a custom LabelDefinition strategy using the LabelDefinition of the series. Then by creating your own Strategy you could iterate through the series' datapoints and if they match your logic to show an empty string or their actual label value. Attached is a sample project illustrating this approach.

Your LabelStrategy class would look like:
public class StackLabelStrategy : ChartSeriesLabelStrategy
   {
       public override LabelStrategyOptions Options
       {
           get { return LabelStrategyOptions.Content; }
       }
 
       List<LabelInfo> labelInfos = new List<LabelInfo>();       
 
       public override object GetLabelContent(DataPoint point, int labelIndex)
       {
           CategoricalDataPoint dataPoint = (CategoricalDataPoint)point;
           LineSeries series = (LineSeries)point.Presenter;
           RadCartesianChart chart = (RadCartesianChart)series.Chart;
 
           var labelInfo = this.labelInfos.FirstOrDefault(x => object.Equals(x.Category, dataPoint.Category) && object.Equals(x.Value, dataPoint.Value));
           if (labelInfo != null)
           {
               return String.Empty;
           }
           else
           {
               labelInfos.Add(new LabelInfo() { Category = dataPoint.Category, Value = dataPoint.Value });
               return dataPoint.Value.ToString();
           }
       }
   }
 
   public class LabelInfo
   {
       public object Category { get; set; }
       public double? Value { get; set; }
   }

Regards,
Peshito
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Jeffrey
Top achievements
Rank 1
Iron
Answers by
Peshito
Telerik team
Jeffrey
Top achievements
Rank 1
Iron
sai
Top achievements
Rank 1
Share this question
or