I need to customize the labels on the X axis of a cartesian chart. The date/times are not uniform across the X axis (see attached screen shot) but we'd like to see the labels/tics at regular intervals.
For example, the attached chart starts a 5/19/2013 7:00:21 and we'd like to have a tick and label show as 5/19/2013 (midnight) even though there is not a data point at that time. Then we'd like to have a label and tickmark at midnight each following day. So in this case, we'd like to see 5/19/2013, 5/20/2013, and 5/21/2013.
Any ideas would be helpful (I've very new to using the Telerik WFP controls).
For example, the attached chart starts a 5/19/2013 7:00:21 and we'd like to have a tick and label show as 5/19/2013 (midnight) even though there is not a data point at that time. Then we'd like to have a label and tickmark at midnight each following day. So in this case, we'd like to see 5/19/2013, 5/20/2013, and 5/21/2013.
Any ideas would be helpful (I've very new to using the Telerik WFP controls).
<
Window
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
x:Class
=
"LatLon.Views.ChartWindow"
Title
=
"Chart"
Height
=
"600"
Width
=
"600"
>
<
Grid
>
<
telerik:RadCartesianChart
Name
=
"myChart"
>
<
telerik:RadCartesianChart.Grid
>
<
telerik:CartesianChartGrid
MajorLinesVisibility
=
"Y"
>
</
telerik:CartesianChartGrid
>
</
telerik:RadCartesianChart.Grid
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:DateTimeCategoricalAxis
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:SplineSeries
CategoryBinding
=
"XValue"
ValueBinding
=
"YValue"
>
</
telerik:SplineSeries
>
</
telerik:RadCartesianChart
>
</
Grid
>
</
Window
>
public
partial
class
ChartWindow : Window
{
public
DataTable chartDataTable;
public
string
yAxisLabel =
string
.Empty;
public
string
xAxisLabel =
string
.Empty;
public
int
xAxisColumn;
public
int
yAxisColumn;
public
ChartWindow()
{
InitializeComponent();
}
public
void
Render()
{
List<ChartData> ChartDatas =
new
List<ChartData>();
foreach
(DataRow dr
in
chartDataTable.Rows)
{
ChartData cdc =
new
ChartData();
cdc.XValue = (DateTime)dr[xAxisColumn];
cdc.YValue = Convert.ToDouble(dr[yAxisColumn].ToString());
ChartDatas.Add(cdc);
}
myChart.HorizontalAxis.LabelInterval = (
int
)(chartDataTable.Rows.Count / 10);
myChart.Series[0].ItemsSource = ChartDatas;
myChart.HorizontalAxis.Title = xAxisLabel;
myChart.VerticalAxis.Title = yAxisLabel;
myChart.HorizontalAxis.LabelFitMode = Telerik.Charting.AxisLabelFitMode.Rotate;
myChart.HorizontalAxis.LabelRotationAngle = 45;
}
}
public
class
ChartData
{
public
DateTime XValue {
get
;
set
; }
public
double
YValue {
get
;
set
; }
}