This question is locked. New answers and comments are not allowed.
Hi,
I got a line chart which can show data with both linear and logarithmic y-axis. The user can show and hide data series using checkboxes bound to seriesvisibility properties in the ViewModel.
When in linear mode a function finds the largest value of the visible series and sets the Y-axis range using the AddRange() function.
When in logarithmic mode AutoRange decide the Y-axis range. Both the AutoRange and IsLogaritmic properties of the chart are bound to bools in the ViewModel.
By default the chart are set to logarithmic. My problem are when the user disables logarithmic and enables it again. When this happens the the dataseries are drawn as expected, but the Y-axis values are wrong. Instead of values 1/10/100/1000 etc. they range from -0.5/0.0.5/1 etc. See attached images.
My code for switching between log/lin :
Where MaxRange are sent to the code behing using mvvmlight messenging :
My AxisY are set in xaml as :
Any idea why this is happening?
I got a line chart which can show data with both linear and logarithmic y-axis. The user can show and hide data series using checkboxes bound to seriesvisibility properties in the ViewModel.
When in linear mode a function finds the largest value of the visible series and sets the Y-axis range using the AddRange() function.
When in logarithmic mode AutoRange decide the Y-axis range. Both the AutoRange and IsLogaritmic properties of the chart are bound to bools in the ViewModel.
By default the chart are set to logarithmic. My problem are when the user disables logarithmic and enables it again. When this happens the the dataseries are drawn as expected, but the Y-axis values are wrong. Instead of values 1/10/100/1000 etc. they range from -0.5/0.0.5/1 etc. See attached images.
My code for switching between log/lin :
public
RelayCommand IsLogCommand
{
get
{
if
(_IsLogCommand ==
null
)
{
_IsLogCommand =
new
RelayCommand(() =>
{
AutoRange = !AutoRange;
IsLog = !IsLog;
MaxRange = FindMaxInVisible();
});
}
return
_IsLogCommand;
}
}
Where MaxRange are sent to the code behing using mvvmlight messenging :
Messenger.Default.Register<PropertyChangedMessage<
double
>>(
this
,
(action) =>
{
if
((MyChart!=
null
))
{
AxisY = MyChart.DefaultView.ChartArea.AxisY;
MaxRange = (
int
)(action.NewValue);
if
(!AxisY.IsLogarithmic)
{
MaxRange = Math.Round(MaxRange * 1.1);
AxisY.AddRange(-Math.Round(0.1 * MaxRange), (
int
)MaxRange, (
int
)MaxRange / 10);
}
}
});
My AxisY are set in xaml as :
<
telerik:ChartArea.AxisY
>
<
telerik:AxisY
x:Name
=
"AxisY"
IsLogarithmic
=
"{Binding IsLog,Mode=OneWay,Source={StaticResource VM}}"
AutoRange
=
"{Binding AutoRange,Mode=OneWay,Source={StaticResource VM}}"
LogarithmBase
=
"10"
MinValue
=
"0"
MinorTicksVisibility
=
"Collapsed"
MajorTicksVisibility
=
"Collapsed"
ExtendDirection
=
"None"
>
</
telerik:AxisY
>
</
telerik:ChartArea.AxisY
>
Any idea why this is happening?