I have a chart which implements a Logarithmic Scale for the Y-Axis as described here:
http://www.telerik.com/help/wpf/radchart-features-axes-logarithmic-scale.html
I some cases, when the IsLogarithmic Property is toggled for Line Series types, the Point Marks become skewed. The lines themselves seem to be plotted correctly, but the Point Marks will appear in their old positions. This behavior only occurs for only certain data sets.
Below is an example which demonstrates the problem.
XAML:
Code Behind:
View Model
Model:
http://www.telerik.com/help/wpf/radchart-features-axes-logarithmic-scale.html
I some cases, when the IsLogarithmic Property is toggled for Line Series types, the Point Marks become skewed. The lines themselves seem to be plotted correctly, but the Point Marks will appear in their old positions. This behavior only occurs for only certain data sets.
Below is an example which demonstrates the problem.
XAML:
<
Window
x:Class
=
"LogarithmicScale.MainWindow"
xmlns:telerikChart
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"
xmlns:telerikCharting
=
"clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"
xmlns:example
=
"clr-namespace:Telerik.Windows.Examples.Chart.LogarithmicScale"
Title
=
"MainWindow"
Height
=
"700"
Width
=
"900"
WindowStartupLocation
=
"CenterScreen"
>
<
Window.DataContext
>
<
example:ExampleViewModel
/>
</
Window.DataContext
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
CheckBox
x:Name
=
"ToggleLogModeCheckBox"
Content
=
"Use Logarithmic Y-Axis"
IsChecked
=
"False"
Margin
=
"6"
Grid.Row
=
"0"
Checked
=
"ToggleLogModeCheckBox_Checked"
Unchecked
=
"ToggleLogModeCheckBox_Checked"
/>
<
telerikChart:RadChart
x:Name
=
"RadChart1"
Grid.Row
=
"1"
ItemsSource
=
"{Binding Data}"
>
<
telerikChart:RadChart.DefaultView
>
<
telerikCharting:ChartDefaultView
>
<
telerikCharting:ChartDefaultView.ChartArea
>
<
telerikCharting:ChartArea
LegendName
=
"PrimaryLegend"
>
<
telerikCharting:ChartArea.AxisX
>
<
telerikCharting:AxisX
/>
</
telerikCharting:ChartArea.AxisX
>
<
telerikCharting:ChartArea.AxisY
>
<
telerikCharting:AxisY
x:Name
=
"LogAxis"
IsLogarithmic
=
"False"
Title
=
"Total population"
/>
</
telerikCharting:ChartArea.AxisY
>
</
telerikCharting:ChartArea
>
</
telerikCharting:ChartDefaultView.ChartArea
>
<
telerikCharting:ChartDefaultView.ChartLegend
>
<
telerikCharting:ChartLegend
x:Name
=
"PrimaryLegend"
/>
</
telerikCharting:ChartDefaultView.ChartLegend
>
</
telerikCharting:ChartDefaultView
>
</
telerikChart:RadChart.DefaultView
>
<
telerikChart:RadChart.SeriesMappings
>
<
telerikCharting:SeriesMapping
CollectionIndex
=
"0"
>
<
telerikCharting:SeriesMapping.SeriesDefinition
>
<
telerikCharting:LineSeriesDefinition
ShowItemLabels
=
"False"
/>
</
telerikCharting:SeriesMapping.SeriesDefinition
>
<
telerikCharting:SeriesMapping.ItemMappings
>
<
telerikCharting:ItemMapping
FieldName
=
"Population"
DataPointMember
=
"YValue"
/>
<
telerikCharting:ItemMapping
FieldName
=
"Time"
DataPointMember
=
"XValue"
/>
</
telerikCharting:SeriesMapping.ItemMappings
>
</
telerikCharting:SeriesMapping
>
<
telerikCharting:SeriesMapping
CollectionIndex
=
"1"
>
<
telerikCharting:SeriesMapping.SeriesDefinition
>
<
telerikCharting:LineSeriesDefinition
ShowItemLabels
=
"False"
/>
</
telerikCharting:SeriesMapping.SeriesDefinition
>
<
telerikCharting:SeriesMapping.ItemMappings
>
<
telerikCharting:ItemMapping
FieldName
=
"Population"
DataPointMember
=
"YValue"
/>
<
telerikCharting:ItemMapping
FieldName
=
"Time"
DataPointMember
=
"XValue"
/>
</
telerikCharting:SeriesMapping.ItemMappings
>
</
telerikCharting:SeriesMapping
>
</
telerikChart:RadChart.SeriesMappings
>
</
telerikChart:RadChart
>
</
Grid
>
</
Window
>
Code Behind:
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
namespace
LogarithmicScale
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
}
private
void
ToggleLogModeCheckBox_Checked(
object
sender, RoutedEventArgs e)
{
if
(
this
.RadChart1 !=
null
)
RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = (
bool
)((CheckBox)sender).IsChecked;
}
}
}
View Model
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ComponentModel;
namespace
Telerik.Windows.Examples.Chart.LogarithmicScale
{
public
class
ExampleViewModel : ViewModelBase
{
private
List<List<Stats>> data;
public
List<List<Stats>> Data
{
get
{
return
this
.data;
}
set
{
if
(
this
.data != value)
{
this
.data = value;
this
.NotifyPropertyChanged(
"Data"
);
}
}
}
public
ExampleViewModel()
{
List<Stats> list0 =
new
List<Stats>();
List<Stats> list1 =
new
List<Stats>();
List<List<Stats>> listindex =
new
List<List<Stats>>();
for
(
int
i = 0; i <= 1000; i++)
list0.Add(
new
Stats(i, 1 * i));
for
(
int
i = 0; i <= 1000; i++)
list1.Add(
new
Stats(i, i * 10));
listindex.Add(list0);
listindex.Add(list1);
this
.Data = listindex;
}
}
public
class
ViewModelBase : INotifyPropertyChanged, INotifyPropertyChanging
{
public
event
PropertyChangedEventHandler PropertyChanged;
public
event
PropertyChangingEventHandler PropertyChanging;
protected
void
NotifyPropertyChanged(String info)
{
if
(PropertyChanged !=
null
)
{
PropertyChanged(
this
,
new
PropertyChangedEventArgs(info));
}
}
protected
void
NotifyPropertyChanging(String info)
{
if
(PropertyChanging !=
null
)
{
PropertyChanging(
this
,
new
PropertyChangingEventArgs(info));
}
}
}
}
Model:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
Telerik.Windows.Examples.Chart.LogarithmicScale
{
public
class
Stats
{
private
int
_time;
public
int
Time
{
get
{
return
this
._time;
}
set
{
this
._time = value;
}
}
private
int
_population;
public
int
Population
{
get
{
return
this
._population;
}
set
{
this
._population = value;
}
}
public
Stats(
int
time,
int
population)
{
this
.Time = time;
this
.Population = population;
}
}
}