6 Answers, 1 is accepted
Unfortunately we are unable to reproduce the problematic behavior in our local tests. Please review the attached sample application that demonstrates our observations and let us know how we can observe the erroneous issue locally so we can investigate it further.
Regards,
Manuel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
When I click on a subcomponent under the gear or bearings category, I am expecting to see plots of datapoints appearing in radcharts in a ListBox. For some reason(s), that is not happening.
1. Collection Architecture:
---------------------------------
public class AirMechViewModel
{
private CategoryCollection subcomponentCategoryCollection;
public AirMechViewModel()
{
subcomponentCategoryCollection =
new CategoryCollection();
}
public Window1 View { get; set; }
public ObservableCollection<Category> MechanicalDiagnosticCategories
{
get { return subcomponentCategoryCollection; }
}
}
public
class CategoryCollection : ObservableCollection<Category>
{
public CategoryCollection()
{
Populate();
}
protected virtual ObservableCollection<SubcomponentItem> GearSubcomponentTemplateTables()
{
ObservableCollection<SubcomponentItem> gearSubcomponentTemplateTables = new
ObservableCollection<SubcomponentItem>();
gearSubcomponentTemplateTables.Add(
new SubcomponentItem("Residual Kurtosis"));
gearSubcomponentTemplateTables.Add(
new SubcomponentItem("Residual RMS"));
return gearSubcomponentTemplateTables;
}
protected virtual ObservableCollection<SubcomponentItem> BearingSubcomponentTemplateTables()
{
ObservableCollection<SubcomponentItem> bearingSubcomponentTemplateTables = new
ObservableCollection<SubcomponentItem>();
bearingSubcomponentTemplateTables.Add(
new SubcomponentItem("Envelope RMS"));
bearingSubcomponentTemplateTables.Add(
new SubcomponentItem("Envelope Inner Race Energy"));
return bearingSubcomponentTemplateTables;
}
private void Populate()
{
Add(
new Category("GEAR"));
this[0].SubcomponentCollection.Add(new GearSubcomponent("Left Input Spiral Bevel Pinion 22T",
GearSubcomponentTemplateTables(), subcomponentConstantsCollection));
this[0].SubcomponentCollection.Add(new GearSubcomponent("Left Input Spiral Bevel Gear 80T",
GearSubcomponentTemplateTables(), subcomponentConstantsCollection));
Add(new Category("BEARINGS"));
this[1].SubcomponentCollection.Add(new BearingSubcomponent("Fan Bearing", BearingSubcomponentTemplateTables());
this[1].SubcomponentCollection.Add(new BearingSubcomponent("Hydraulic Pump 4 Preload",
BearingSubcomponentTemplateTables());
}
}
public
class Category
{
private ObservableCollection<Subcomponent> subcomponentCollection;
public Category(string categoryName)
{
subcomponentCollection =
new ObservableCollection<Subcomponent>();
this.categoryName = categoryName;
}
public ObservableCollection<Subcomponent> SubcomponentCollection
{
get { return subcomponentCollection; }
set {subcomponentCollection = value;}
}
public string CategoryName
{
get { return categoryName; }
set {categoryName = value;}
}
}
public
class Subcomponent
{
private ObservableCollection<SubcomponentItem> subcomponentItems;
private String componentName;
private String subcomponentName;
public Subcomponent()
{
subcomponentItems =
new ObservableCollection<SubcomponentItem>();
subcomponentName =
String.Empty;
componentName =
String.Empty;
}
public virtual ObservableCollection<SubcomponentItem> SubcomponentItems
{
get { return subcomponentItems; }
set {subcomponentItems = value;}
}
public virtual String ComponentName
{
get { return componentName; }
set {componentName = value;}
}
public virtual String SubcomponentName
{
get { return this.subcomponentName; }
set {this.subcomponentName = value;}
}
public
virtual void GetGraphDataPoints(String subcomponentName, ObservableCollection<SubcomponentItem>
subcomponentItems)
{
this.subcomponentItems = subcomponentItems;
this.subcomponentName = subcomponentName;
for (int index = 0; index < subcomponentItems.Count; index++)
{
subcomponentItems[index].InitiateDataPoints(current[subcomponentItems[index].ChartName.ToLower()]);
}
}
}
public class SubcomponentItem
{
private ObservableCollection<DataPoint> conditionIndicatorDataPoints; // A list will also suffice
private string chartName;
public SubcomponentItem(string chartName)
{
this.chartName = chartName;
this.conditionIndicatorDataPoints = new ObservableCollection<DataPoint>();
}
public ObservableCollection<DataPoint> ConditionIndicatorDataPoints
{
get { return conditionIndicatorDataPoints; }
set {conditionIndicatorDataPoints = value;}
}
public string ChartName
{
get { return chartName; }
set {chartName = value;}
}
public void InitiateDataPoints()
{
Random rand = new Random(DateTime.Now.Millisecond);
for (int index = 0; index < 6; index++)
{
conditionIndicatorDataPoints.Add(new DataPoint(Math.Round(rand.NextDouble() * 10, 2)));
}
}
}
public
class DataPoint
{
private double yPlotPoint;
public DataPoint()
{
yPlotPoint = 0.0;
}
public DataPoint(double plotPoint)
{
this.yPlotPoint = plotPoint;
}
public double YPlotPoint
{
get { return yPlotPoint; }
}
}
2. Data Types for Collection:
------------------------------------
public
class GearSubcomponent: Subcomponent
{
public GearSubcomponent()
{}
public GearSubcomponent(string subcomponentName, ObservableCollection<SubcomponentItem> subcomponentItems)
{
GetGraphDataPoints(subcomponentName, subcomponentItems);
}
}
public class BearingSubcomponent: Subcomponent
{
public BearingSubcomponent()
{}
public BearingSubcomponent(string subcomponentName, ObservableCollection<SubcomponentItem> subcomponentItems)
{
GetGraphDataPoints(subcomponentName, subcomponentItems);
}
}
3. Template for the PanelBar:
--------------------------------------
<HierarchicalDataTemplate x:Key="radPanelBarHierarchicalDataDataTemplate" ItemsSource="{Binding SubcomponentCollection}">
<Border Margin="3" BorderThickness="1" BorderBrush="Transparent" CornerRadius="4">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" FontWeight="Bold" Text="{Binding Path=CategoryName}" />
</Grid>
</Border>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<TextBlock Grid.Row="1" FontWeight="Bold" Text="{Binding Path=SubcomponentName}"/>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
4. DataTemplates for ListBox:
--------------------------------------
<
DataTemplate DataType="{x:Type modl:BearingSubcomponent}">
<Grid >
<telerik:RadChart x:Name="bearing" Width="299" Height="299" ItemsSource="{Binding ConditionIndicatorDataPoints}">
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView>
<telerik:ChartDefaultView.ChartTitle>
<telerik:ChartTitle Content="{Binding Path=ChartName}" />
</telerik:ChartDefaultView.ChartTitle>
<telerik:ChartDefaultView.ChartLegend>
<telerik:ChartLegend Header="BEARING"/>
</telerik:ChartDefaultView.ChartLegend>
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea >
<telerik:ChartArea.AxisY>
<telerik:AxisY Title="GDF"/>
</telerik:ChartArea.AxisY>
<telerik:ChartArea.AxisX>
<telerik:AxisX Title="OPTIME"/>
</telerik:ChartArea.AxisX>
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
<telerik:RadChart.SeriesMappings>
<telerik:SeriesMapping>
<telerik:SeriesMapping.SeriesDefinition>
<telerik:LineSeriesDefinition />
</telerik:SeriesMapping.SeriesDefinition>
<telerik:SeriesMapping.ItemMappings>
<telerik:ItemMapping DataPointMember="YValue" FieldName="YPlotPoint" />
</telerik:SeriesMapping.ItemMappings>
</telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>
</telerik:RadChart>
</Grid>
</DataTemplate>
5. Style for ListBox:
-------------------------
<
Style x:Key="conditionIndicatorItemControlTemplate" TargetType="{x:Type ListBox}">
<Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
<Setter Property="Template">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel></WrapPanel>
</ItemsPanelTemplate>
</Setter.Value>
</Style>
6. Content of my 'Window1.xaml file':
-----------------------------------------------
<
Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="TITLE BAR" Background="#FFBDB7A9"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<telerik:RadPanelBar x:Name="subcomponentCategories" Grid.Column="0"
BorderThickness="1" BorderBrush="#9098A3" Background="#FFBDB7A9"
ItemsSource="{Binding Path=MechanicalDiagnosticCategories}"
ItemTemplate="{StaticResource radPanelBarHierarchicalDataDataTemplate}">
</telerik:RadPanelBar>
<Grid Grid.Column="1" >
<Border>
<ListBox x:Name="conditionIndicatorItemControl"
HorizontalAlignment="Left"
VerticalAlignment="Top"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Background="Blue"
Style="{DynamicResource conditionIndicatorItemControlTemplate}"
ItemsSource="{Binding ElementName=subcomponentCategories, Path=SelectedItem.SubcomponentItems}"
SnapsToDevicePixels="True">
</ListBox>
</Border>
</Grid>
</Grid>
</Grid>
7. The content of my 'Window1.xaml.cs' file:
------------------------------------------------------
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
DataContext = new AirMechViewModel();
}
}
Unfortunately we were unable to compile the pasted code locally. Either the formatting coruppted the snippets or some parts are missing in the first place but we are getting errors about missing template for the ListBox in XAML, and in code -- "The name 'subcomponentConstantsCollection' does not exist in the current context", "The name 'current' does not exist in the current context".
We would ask you to open a formal support ticket and send us a runnable version of your application (file attachments are not allowed in the public forums) so we can advise you properly how to proceed. We apologize for the additional roundtrip necessary to resolve this issue.
All the best,
Manuel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
We are sorry for the misunderstanding -- it seemed you provided the source code in order to replicate exactly the scenario you are working on (as our original sample application did not help in resolving the issue) and that is why we asked if you could provide us with a runnable version of the same code.
Nevertheless, on further testing we were able to reproduce the problem in our local tests as well and unfortunately we must confirm it is a bug within the chart control. Unfortunately we cannot suggest you a workaround at the moment but we have discussed this issue with our developers and it will be fixed for the weekly internal build scheduled for Friday.
We are sorry for the temporary inconvenience. We have also updated your Telerik points for the report.
Greetings,
Manuel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.