line series doesn't display properly with 2 bar series

7 posts, 1 answers
  1. Jeffrey
    Jeffrey avatar
    2 posts
    Member since:
    Nov 2012

    Posted 20 Feb 2015 Link to this post

    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.
  2. Answer
    Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 23 Feb 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeffrey
    Jeffrey avatar
    2 posts
    Member since:
    Nov 2012

    Posted 25 Feb 2015 in reply to Peshito Link to this post

    Thank you Peshito, this really helps me.
  5. sai
    sai avatar
    43 posts
    Member since:
    Feb 2015

    Posted 19 Aug 2015 in reply to Peshito Link to this post

    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.

  6. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 20 Aug 2015 Link to this post

    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
  7. sai
    sai avatar
    43 posts
    Member since:
    Feb 2015

    Posted 20 Aug 2015 in reply to Peshito Link to this post

    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.?

  8. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 24 Aug 2015 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready