Hi,
I've got stuck when using ChartView to display a ScatterPoint chart. The X-axis should be based on dates and I'm therefor using the DateTimeContinuousAxis but it doesn't work. My business object is quite alright because when I tried using a regular LinearAxis fed with the Year part my scatter points were shown.
I have a zipped test solution reproducing my error on the following link, http://ubuntuone.com/50qawHa1EqVFHfB6ik8L4B
For a quick view of the code, see below.
Does anyone have a clue why it's not working?
Regards, Clas Ericson
MainPage.xaml
ViewModel.cs
I've got stuck when using ChartView to display a ScatterPoint chart. The X-axis should be based on dates and I'm therefor using the DateTimeContinuousAxis but it doesn't work. My business object is quite alright because when I tried using a regular LinearAxis fed with the Year part my scatter points were shown.
I have a zipped test solution reproducing my error on the following link, http://ubuntuone.com/50qawHa1EqVFHfB6ik8L4B
For a quick view of the code, see below.
Does anyone have a clue why it's not working?
Regards, Clas Ericson
MainPage.xaml
<
UserControl
x:Class
=
"RadChartView_DateTimeContinuousAxis.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:chartView
=
"clr-namespace:Telerik.Windows.Controls.ChartView;assembly=Telerik.Windows.Controls.Chart"
xmlns:local
=
"clr-namespace:RadChartView_DateTimeContinuousAxis"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
UserControl.DataContext
>
<
local:ViewModel
/>
</
UserControl.DataContext
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadCartesianChart
x:Name
=
"chart"
Grid.Row
=
"2"
Grid.ColumnSpan
=
"2"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Stretch"
Margin
=
"0,0,0,0"
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:DateTimeContinuousAxis
PlotMode
=
"OnTicksPadded"
LastLabelVisibility
=
"Hidden"
Title
=
"Year"
MajorStep
=
"2"
MajorStepUnit
=
"Year"
LabelInterval
=
"4"
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
Title
=
"kWh/m2"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:RadCartesianChart.Behaviors
>
<
telerik:ChartPanAndZoomBehavior
PanMode
=
"Both"
ZoomMode
=
"Both"
>
</
telerik:ChartPanAndZoomBehavior
>
</
telerik:RadCartesianChart.Behaviors
>
<
telerik:RadCartesianChart.Grid
>
<
telerik:CartesianChartGrid
MajorLinesVisibility
=
"Y"
/>
</
telerik:RadCartesianChart.Grid
>
<
chartView:ScatterPointSeries
AllowSelect
=
"False"
ItemsSource
=
"{Binding ScatterData}"
XValueBinding
=
"XValue"
YValueBinding
=
"YValue"
>
<
chartView:ScatterPointSeries.PointTemplate
>
<
DataTemplate
>
<
Ellipse
Width
=
"5"
Height
=
"5"
Fill
=
"{Binding DataItem.FillBrush}"
/>
</
DataTemplate
>
</
chartView:ScatterPointSeries.PointTemplate
>
</
chartView:ScatterPointSeries
>
</
telerik:RadCartesianChart
>
</
Grid
>
</
UserControl
>
ViewModel.cs
using
System;
using
System.Collections.Generic;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Ink;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Telerik.Windows.Controls;
namespace
RadChartView_DateTimeContinuousAxis
{
public
class
ViewModel : ViewModelBase
{
public
IEnumerable<BuildYearsChartItem> ScatterData {
get
;
set
; }
/// <summary>
/// Default constructor
/// </summary>
public
ViewModel()
{
ScatterData =
new
List<BuildYearsChartItem>()
{
new
BuildYearsChartItem() { XValue =
new
DateTime(1948,1,1), YValue = 148.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) },
new
BuildYearsChartItem() { XValue =
new
DateTime(1963,1,1), YValue = 125.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) },
new
BuildYearsChartItem() { XValue =
new
DateTime(1978,1,1), YValue = 176.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) },
new
BuildYearsChartItem() { XValue =
new
DateTime(1982,1,1), YValue = 185.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) },
new
BuildYearsChartItem() { XValue =
new
DateTime(1987,1,1), YValue = 112.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) },
new
BuildYearsChartItem() { XValue =
new
DateTime(1996,1,1), YValue = 101.65, FillBrush =
new
SolidColorBrush(Color.FromArgb(255,128,128,255)) }
};
this
.OnPropertyChanged(
"ScatterData"
);
}
}
}