This question is locked. New answers and comments are not allowed.
I have a chart with 3 BarSeries and each one can be hidden. The problem occurs when I hide the BarSerie with the biggest value. The LinearAxis does not rescale and keeps the maximum. ActualRange.Maximum cannot be set, and LinearAxis.Maximum has no effect. Is there a way to reset ActualRange whenever I hide a BarSerie?
https://dl.dropboxusercontent.com/u/26902722/TelerikCharts.zip
https://dl.dropboxusercontent.com/u/26902722/TelerikCharts.zip
using
System.Collections.Generic;
using
System.Windows;
using
System.Windows.Controls;
using
Telerik.Charting;
using
Telerik.Windows.Controls;
using
Telerik.Windows.Controls.Charting;
using
Telerik.Windows.Controls.ChartView;
using
TelerikCharts.Internal;
namespace
TelerikCharts
{
public
partial
class
MainPage : UserControl
{
public
MainPage()
{
InitializeComponent();
DataContext =
new
TelerikChartsTestsModel() { refChart = chart,refLinearAxis = linearAxis};
}
}
public
class
TelerikChartsTestsModel : BusyBase
{
public
RadCartesianChart refChart;
public
LinearAxis refLinearAxis;
//data
#region
List<ConsumptionDay> _consumptionDaysWeek1=
new
List<ConsumptionDay>()
{
{
new
ConsumptionDay(){Day=
"Monday"
,Value=10}},
{
new
ConsumptionDay(){Day=
"Tuesday"
,Value=20}},
{
new
ConsumptionDay(){Day=
"Wednesday"
,Value=15}},
{
new
ConsumptionDay(){Day=
"Thursday"
,Value=30}},
{
new
ConsumptionDay(){Day=
"Friday"
,Value=25}},
{
new
ConsumptionDay(){Day=
"Saturday"
,Value=13}},
{
new
ConsumptionDay(){Day=
"Sunday"
,Value=14}},
};
List<ConsumptionDay> _consumptionDaysWeek2 =
new
List<ConsumptionDay>()
{
{
new
ConsumptionDay(){Day=
"Monday"
,Value=20}},
{
new
ConsumptionDay(){Day=
"Tuesday"
,Value=40}},
{
new
ConsumptionDay(){Day=
"Wednesday"
,Value=30}},
{
new
ConsumptionDay(){Day=
"Thursday"
,Value=60}},
{
new
ConsumptionDay(){Day=
"Friday"
,Value=50}},
{
new
ConsumptionDay(){Day=
"Saturday"
,Value=26}},
{
new
ConsumptionDay(){Day=
"Sunday"
,Value=28}},
};
List<ConsumptionDay> _consumptionDaysWeek3 =
new
List<ConsumptionDay>()
{
{
new
ConsumptionDay(){Day=
"Monday"
,Value=30}},
{
new
ConsumptionDay(){Day=
"Tuesday"
,Value=60}},
{
new
ConsumptionDay(){Day=
"Wednesday"
,Value=45}},
{
new
ConsumptionDay(){Day=
"Thursday"
,Value=90}},
{
new
ConsumptionDay(){Day=
"Friday"
,Value=75}},
{
new
ConsumptionDay(){Day=
"Saturday"
,Value=39}},
{
new
ConsumptionDay(){Day=
"Sunday"
,Value=42}},
};
#endregion
private
bool
_consumptionDaysWeek1Enabled;
private
bool
_consumptionDaysWeek2Enabled;
private
bool
_consumptionDaysWeek3Enabled;
private
double
_maximum=
double
.PositiveInfinity;
private
ChartSeriesCombineMode _barCombineMode = ChartSeriesCombineMode.Cluster;
public
TelerikChartsTestsModel()
{
}
public
double
Maximum
{
get
{
return
_maximum; }
set
{
_maximum = value;
OnPropertyChanged(
"Maximum"
);
}
}
public
bool
ConsumptionDaysWeek1Enabled
{
get
{
return
_consumptionDaysWeek1Enabled; }
set
{
_consumptionDaysWeek1Enabled = value;
OnPropertyChanged(
"ConsumptionDaysWeek1Enabled"
);
}
}
public
bool
ConsumptionDaysWeek2Enabled
{
get
{
return
_consumptionDaysWeek2Enabled; }
set
{
_consumptionDaysWeek2Enabled = value;
OnPropertyChanged(
"ConsumptionDaysWeek2Enabled"
);
}
}
public
bool
ConsumptionDaysWeek3Enabled
{
get
{
return
_consumptionDaysWeek3Enabled; }
set
{
_consumptionDaysWeek3Enabled = value;
OnPropertyChanged(
"ConsumptionDaysWeek3Enabled"
);
}
}
public
List<ConsumptionDay> ConsumptionDaysWeek1
{
get
{
return
_consumptionDaysWeek1; }
set
{
_consumptionDaysWeek1 = value;
OnPropertyChanged(
"ConsumptionDaysWeek1"
);
}
}
public
List<ConsumptionDay> ConsumptionDaysWeek2
{
get
{
return
_consumptionDaysWeek2; }
set
{
_consumptionDaysWeek2 = value;
OnPropertyChanged(
"ConsumptionDaysWeek2"
);
}
}
public
List<ConsumptionDay> ConsumptionDaysWeek3
{
get
{
return
_consumptionDaysWeek3; }
set
{
_consumptionDaysWeek3 = value;
OnPropertyChanged(
"ConsumptionDaysWeek3"
);
}
}
public
ChartSeriesCombineMode BarCombineMode
{
get
{
return
this
._barCombineMode;
}
set
{
_barCombineMode = value;
OnPropertyChanged(
"BarCombineMode"
);
}
}
}
public
class
ConsumptionDay
{
public
string
Day {
get
;
set
; }
public
int
Value {
get
;
set
; }
}
}
<
UserControl
x:Class
=
"TelerikCharts.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:converters
=
"clr-namespace:TelerikCharts.Converters"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
UserControl.Resources
>
<
converters:BoolVisibility
x:Key
=
"BoolVisibility"
/>
<
converters:BoolCombineModeCluster
x:Key
=
"BoolCombineModeCluster"
/>
<
telerik:BooleanToVisibilityConverter
x:Key
=
"VisibilityOfBool"
/>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
></
ColumnDefinition
>
<
ColumnDefinition
Width
=
"Auto"
></
ColumnDefinition
>
<!--<ColumnDefinition Width="*"></ColumnDefinition>-->
</
Grid.ColumnDefinitions
>
<
telerik:RadCartesianChart
x:Name
=
"chart"
Palette
=
"Metro"
>
<
telerik:RadCartesianChart.Series
>
<
telerik:BarSeries
CategoryBinding
=
"Day"
ValueBinding
=
"Value"
Visibility
=
"{Binding ConsumptionDaysWeek1Enabled, Converter={StaticResource VisibilityOfBool}}"
IsEnabled
=
"{Binding ConsumptionDaysWeek1Enabled}"
CombineMode
=
"{Binding Path=ConsumptionDaysWeek1Enabled, Converter={StaticResource BoolCombineModeCluster}}"
ItemsSource
=
"{Binding ConsumptionDaysWeek1}"
>
</
telerik:BarSeries
>
<
telerik:BarSeries
CategoryBinding
=
"Day"
ValueBinding
=
"Value"
Visibility
=
"{Binding ConsumptionDaysWeek2Enabled, Converter={StaticResource VisibilityOfBool}}"
IsEnabled
=
"{Binding ConsumptionDaysWeek2Enabled}"
CombineMode
=
"{Binding Path=ConsumptionDaysWeek2Enabled, Converter={StaticResource BoolCombineModeCluster}}"
ItemsSource
=
"{Binding ConsumptionDaysWeek2}"
>
</
telerik:BarSeries
>
<
telerik:BarSeries
CategoryBinding
=
"Day"
ValueBinding
=
"Value"
Visibility
=
"{Binding ConsumptionDaysWeek3Enabled, Converter={StaticResource VisibilityOfBool}}"
IsEnabled
=
"{Binding ConsumptionDaysWeek3Enabled}"
CombineMode
=
"{Binding Path=ConsumptionDaysWeek3Enabled, Converter={StaticResource BoolCombineModeCluster}}"
ItemsSource
=
"{Binding ConsumptionDaysWeek3}"
>
</
telerik:BarSeries
>
</
telerik:RadCartesianChart.Series
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:CategoricalAxis
></
telerik:CategoricalAxis
>
</
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
x:Name
=
"linearAxis"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
</
telerik:RadCartesianChart
>
<
StackPanel
Grid.Column
=
"1"
Orientation
=
"Vertical"
>
<
CheckBox
IsChecked
=
"{Binding ConsumptionDaysWeek1Enabled, Mode=TwoWay}"
>
<
TextBlock
Text
=
"ConsumptionDaysWeek1"
/>
</
CheckBox
>
<
CheckBox
IsChecked
=
"{Binding ConsumptionDaysWeek2Enabled, Mode=TwoWay}"
>
<
TextBlock
Text
=
"ConsumptionDaysWeek2"
/>
</
CheckBox
>
<
CheckBox
IsChecked
=
"{Binding ConsumptionDaysWeek3Enabled, Mode=TwoWay}"
>
<
TextBlock
Text
=
"ConsumptionDaysWeek3"
/>
</
CheckBox
>
</
StackPanel
>
</
Grid
>
</
UserControl
>