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

Chart 's x-axis showing improper dates and labelsteps

9 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 21 Mar 2013, 09:09 AM
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;
        }

9 Answers, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 1
answered on 25 Mar 2013, 06:21 AM
HI ,
      Can anyone help on this please ?
0
AMO
Top achievements
Rank 1
answered on 25 Mar 2013, 06:38 AM
Facing the same issue ....Can someone help out on this ?.
0
AMO
Top achievements
Rank 1
answered on 26 Mar 2013, 02:00 PM
Any solution  ????
0
AMO
Top achievements
Rank 1
answered on 27 Mar 2013, 02:14 PM
??
0
Rahul
Top achievements
Rank 1
answered on 28 Mar 2013, 04:16 AM
Please respond to this issue ASAP.  As this creating lot of issues.
0
AMO
Top achievements
Rank 1
answered on 28 Mar 2013, 01:30 PM

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 ??
0
Missing User
answered on 29 Mar 2013, 12:33 PM
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.

0
AMO
Top achievements
Rank 1
answered on 29 Mar 2013, 01:32 PM
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....
0
Missing User
answered on 03 Apr 2013, 10:04 AM
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.

Tags
General Discussions
Asked by
Rahul
Top achievements
Rank 1
Answers by
Rahul
Top achievements
Rank 1
AMO
Top achievements
Rank 1
Missing User
Share this question
or