Chart 's x-axis showing improper dates and labelsteps

10 posts, 0 answers
  1. Rahul
    Rahul avatar
    10 posts
    Member since:
    Mar 2013

    Posted 21 Mar 2013 Link to this post

    Hi,
         I am using telerik chart control with silverlight 5.0. I am plotting a graph. On the x-axis, the label steps improperly.  The labelsteps are drawn/ plotted twice on the x-axis for the same date. Please help on this.


    Please see the attched file. following is the xaml code:
    <telerik:RadChart.DefaultView>
                                            <telerik:ChartDefaultView ChartLegendPosition="Right">
                                                <telerik:ChartDefaultView.ChartLegend>
                                                    <telerik:ChartLegend x:Name="chartLegend" Header="" UseAutoGeneratedItems="True"
                                                             MouseLeftButtonUp="chartLegend_MouseLeftButtonUp"
                                                             LegendItemStyle="{StaticResource LegendItemStyle}"
                                                             HorizontalAlignment="Center"
                                                             Background="Transparent" BorderBrush="{x:Null}" FontWeight="Bold"
                                                             />
                                                </telerik:ChartDefaultView.ChartLegend>
                                                <telerik:ChartDefaultView.ChartArea>
                                                    <telerik:ChartArea LegendName="chartLegend" ItemToolTipOpening="ChartArea_ItemToolTipOpening">
                                                        <telerik:ChartArea.AxisY>
                                                            <telerik:AxisY Title="Elapse Mins. (in min)" StripLinesVisibility="Collapsed"/>
                                                        </telerik:ChartArea.AxisY>
                                                        <telerik:ChartArea.AxisX>
                                                            <telerik:AxisX Title="Cycle Date"
                                                                           LabelRotationAngle="-70"
                                                               DefaultLabelFormat="dd MMM"    />
                                                        </telerik:ChartArea.AxisX>
                                                    </telerik:ChartArea>
                                                </telerik:ChartDefaultView.ChartArea>
                                            </telerik:ChartDefaultView>
                                        </telerik:RadChart.DefaultView>




    below is the viewmodel code in c#:

    private SeriesMapping GetSeries(JobTSData jobTS_data)
            {
                SeriesMapping series = new SeriesMapping();
                series.ItemsSource = jobTS_data.TSData;

                series.LegendLabel = jobTS_data.TSData.FirstOrDefault().UniqueJobIdParentID;
              
                SeriesDefinition seriesDef = null;
                switch (SelectedChartType)
                {
                    case "Bar":
                        seriesDef = new BarSeriesDefinition() { ShowItemLabels = Util.SHOW_ITEM_LABEL };
                        break;
                    case "Line":
                        seriesDef = new LineSeriesDefinition()
                        {
                            ShowItemLabels = Util.SHOW_ITEM_LABEL,
                            EmptyPointBehavior = EmptyPointBehavior.Gap,
                        };

                        break;
                    case "Scatter":
                        seriesDef = new ScatterSeriesDefinition()
                        {
                            ShowItemLabels = Util.SHOW_ITEM_LABEL
                        };
                        break;
                }
                seriesDef.ShowItemToolTips = true;
                series.SeriesDefinition = seriesDef;
                series.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.YValue, FieldName = "Elapse_Minutes" });
                series.ItemMappings.Add(new ItemMapping() { DataPointMember = DataPointMember.XValue, FieldName = "CycleDate"});
                IsStatsExpanded = false;
                return series;
            }

  2. Rahul
    Rahul avatar
    10 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    HI ,
          Can anyone help on this please ?
  3. DevCraft banner
  4. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 25 Mar 2013 Link to this post

    Facing the same issue ....Can someone help out on this ?.
  5. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 26 Mar 2013 Link to this post

    Any solution  ????
  6. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 27 Mar 2013 Link to this post

    ??
  7. Rahul
    Rahul avatar
    10 posts
    Member since:
    Mar 2013

    Posted 27 Mar 2013 Link to this post

    Please respond to this issue ASAP.  As this creating lot of issues.
  8. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 28 Mar 2013 Link to this post


    Even if we set the AutoRange = true for the x -axis , values seems to be repeating  .Is there a way ,wherein the optimal step is automatically calculated ??
  9. Missing user
    Missing user avatar

    Posted 29 Mar 2013 Link to this post

    Hello Rahul and Amo,

    This is caused by a combination of using XValue as a DataPointMember in the ItemMapping together with an incomplete DateTime format for the AxisX labels. Basically, what happens is that the chart plots the dates continously - the first label corresponds to something like "2013-03-14 00:00" and the one after that to a DateTime value that befalls on the same day, but a different hour (e.g.: "2013-03-14  12:00". Since you both use a DateTime format that shows only the month and day components of the date, it appears that the labels repeat themselves. If you set the AxisX DefaultLabelFormat to something like "yyyy-MM-dd hh:mm ss", you'll see that the chart doesn't repeat label values.

    To get around this, you should use XCategory for the DataPointMember instead of XValue in the ItemMapping.

    Regards,
    Ivan N.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. AMO
    AMO avatar
    31 posts
    Member since:
    Nov 2011

    Posted 29 Mar 2013 Link to this post

    Thanks Ivan !

    I tried using the format suggested by you , but still the date is repeating I have attaced the screenshot .

    Is this an issue with the control itself  ?

    Also , using XCategory will not work in my situation....
  11. Missing user
    Missing user avatar

    Posted 03 Apr 2013 Link to this post

    Hi Amo,

    If you still see repeating values, you can try setting the step of the X axis explicitly:
    this.radChart.DefaultView.ChartArea.AxisX.Step = 1.0;
    A value of 1 corresponds to a single day as defined by the OA Date format. Then, you should match the step with a DateTime format for that precision (e.g.: "yyyy-MM-dd"). Alternatively, if you need a time span of 12 hours, you should set the Step to 0.5 and the format to something like "yyyy-MM-dd hh". For an hourly precision, you should use a Step of 1.0 / 24 and the same "yyyy-MM-dd hh" format and so on.

    Regards,
    Ivan N.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner