This is a migrated thread and some comments may be shown as answers.
Repeating Date on X Axis
6 Answers 37 Views
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 19 Oct 2011, 01:02 AM
Hi does anyone know what setting would cause the date to get repeated on the Y Axis? please see the attached screen shot. 

The data definitely only has the 7 data points that are displayed on the chart and there is only one series added. 

Thanks,
Richard

ObservableCollection<ReportingDatapointDate> reportData = new ObservableCollection<ReportingDatapointDate>();
// Vaules taken from Web Service ... 
 
SeriesMapping seriesMapping = new SeriesMapping
      {
          LegendLabel = "Test Data",
          SeriesDefinition = new BarSeriesDefinition{
                 InteractivitySettings ={
                         SelectionScope =InteractivityScope.Series,
                         HoverScope =InteractivityScope.Series,
                         SelectionMode =ChartSelectionMode.Single
                     }
             }
      };
 
 
seriesMapping.ItemMappings.Add(new ItemMapping("DateTimeAxisValue", DataPointMember.XValue));
seriesMapping.ItemMappings.Add(new ItemMapping("NumberAxisValue", DataPointMember.YValue));
 
 
chart.SeriesMappings.Add(seriesMapping);
chart.ItemsSource = reportData;
 
             
             
             
public class ReportingDatapointDate
{
    public DateTime DateTimeAxisValue { get; set; }
    public double NumberAxisValue { get; set; }
}


6 Answers, 1 is accepted

Sort by
0
Accepted
Peshito
Telerik team
answered on 21 Oct 2011, 01:06 PM
Hello Richard,

Dates, displayed in your X-axis, are repeated because you are adding your DateTime objects as X values. This causes the axis to go into strict mode in which the items are drawn from Min to Max using a calculated step.

Try using XCategory as your DataPoint.Member instead of using XValue. More about categorical charts can be found here.

Regards,
Peshito
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Richard
Top achievements
Rank 1
answered on 21 Oct 2011, 01:14 PM
Peshito you are a genius! 

Thank you so much that's been driving me crazy ! 

Richard
0
Rahul
Top achievements
Rank 1
answered on 25 Mar 2013, 11:26 AM
but this does not work for multiple series mapping. it will group the identical dates but what if on particluar day there is not data for one item and has data for another item. As this the scenario for my stuff.



Thanks
Rahul
0
Peshito
Telerik team
answered on 28 Mar 2013, 09:20 AM
Hello Rahul,

Please refer to our online help topic here where you can find more about empty values behavior.

You can also take a look at our online demo example:
http://demos.telerik.com/silverlight-old/#Chart/EmptyValues

Hope this helps.

All the best,
Peshito
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rahul
Top achievements
Rank 1
answered on 28 Mar 2013, 09:58 AM
Hi Peshito,
                          Thanks for replying. Any help in solving this  issue asap will be great. I am attaching two images. The one I have used XCategory which groups the dates for 2 items. Suppose if you have to items you want it to draw then it will group 2 items by date and if one of the item does not have value on that day then it puts that items values at the last which I do not want. Please take a look at the images and below code also.

 1> not desired one.
 2> desired result.


Below is the xaml--

 

<

 

 

telerik:RadChart Grid.Row="1" Grid.ColumnSpan="2" x:Name="radTimeGraph" ItemsSource="{Binding Job_TimeSeries,Mode=OneWay}"

 

 

 

Background="Transparent" BorderBrush="{x:Null}"

 

 

 

 

 

 

 

HorizontalAlignment="Left" Margin="0,0,5,0" SeriesMappings="{Binding ChartSeriesMapping}"

 

 

 

 

 

 

 

VerticalAlignment="Top"

 

 

 

 

 

 

 

Visibility="{Binding ChartVisibility}">

 

 

 

 


 

<

 

 

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>

 

</

 

 

telerik:RadChart>

 

 

 

 




view model code--

 

private

 

 

void AddSeriesMapping()

 

{

ChartSeriesMapping =

 

new SeriesMappingCollection();

 

 

 

if (item_Series != null && item_Series.Count > 0)

 

{

 

 

foreach (var series_data in originalData)

 

{

ChartSeriesMapping.Add(GetSeries(series_data ));

}

}

}


 

private

 

 

SeriesMapping GetSeries(series_data  jobTS_data)

 

{

 

 

SeriesMapping series = new SeriesMapping();

 

series.ItemsSource = jobTS_data.TSData;

 

 

int range = (Convert.ToDateTime(EndDate) - Convert.ToDateTime(StartDate)).Days;

 

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.Drop,

 

 

};

 

 

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 = "Minutes" });

 

series.ItemMappings.Add(

 

new ItemMapping() { DataPointMember = DataPointMember.XValue, FieldName = "Date"});

 

IsStatsExpanded =

 

false;

 

 

 

return series;

 

}

0
Peshito
Telerik team
answered on 02 Apr 2013, 07:10 AM
Hello Rahul,

As my colleague Evgenia has already replied in the other forum thread you have here, if you need to enforce strict ordering of items on the XAxis, you'll need to sort the XCategories before providing them to the chart.

I would also suggest to keep the conversation in a single thread so it is easier for both sides to follow.

Kind regards,
Peshito
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Richard
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Richard
Top achievements
Rank 1
Rahul
Top achievements
Rank 1
Share this question
or