Hi Team,
Is it possible to create a category series with dynamic series elements.
Below mentioned is the way my requirement of xam data chart should looks like.
In the below mentioned sample the series are predefined as 5 but as per my requirement the number of series are dynamic that are categorized by a fixed category.
Can you please provide a sample if you have any.Thanks in advance for all you do.
The below mentioned part needs to be dynamic where the value member path should be dynamic.
Sample code :
Title="{Binding StringEnergyCoal, Source={StaticResource DataViewModel}}" XAxis="{Binding ElementName=BarXAxis}" YAxis="{Binding ElementName=BarYAxis}" IsHighlightingEnabled="True" IsTransitionInEnabled="True"> Title="{Binding StringEnergyHydro, Source={StaticResource DataViewModel}}" XAxis="{Binding ElementName=BarXAxis}" YAxis="{Binding ElementName=BarYAxis}" IsHighlightingEnabled="True" IsTransitionInEnabled="True"> Title="{Binding StringEnergyNuclear, Source={StaticResource DataViewModel}}" XAxis="{Binding ElementName=BarXAxis}" YAxis="{Binding ElementName=BarYAxis}" IsHighlightingEnabled="True" IsTransitionInEnabled="True"> Title="{Binding StringEnergyGas, Source={StaticResource DataViewModel}}" XAxis="{Binding ElementName=BarXAxis}" YAxis="{Binding ElementName=BarYAxis}" IsHighlightingEnabled="True" IsTransitionInEnabled="True"> Title="{Binding StringEnergyOil, Source={StaticResource DataViewModel}}" XAxis="{Binding ElementName=BarXAxis}" YAxis="{Binding ElementName=BarYAxis}" IsHighlightingEnabled="True" IsTransitionInEnabled="True">
Regards,
Sridhar.
Hi Sridhar,
If I understand the behavior that you are interested in achieving with the DataChart, it sounds like you want to dynamically modify the number of series during runtime and not necessarily change the ValueMemberPath for a given series?
Both behaviors are certainly possible as long as you are defining each of your series at some point and adding them to the chart’s Series collection or for the latter behavior, (if you really do want to modify the ValueMemberPath for your series during runtime) as long as an appropriate public property off of the underlying object is exposed, you can certainly change the path to some other value as well.
I’ve attached a basic sample for swapping out series, (as this scenario sounds closest to your goal) where categories are defined for energy sources and the series associated with specific country energy production are dynamically added and removed from the chart.
Please find the sample attached and if you have any further questions, or if I’ve misunderstood your intention, please let me know.
Chris K.
Hi Chris,
Thanks for your prompt response.But this is not exactly what i need .here is my requirement.
I have got a fixed number of rop (30,45,60,90).Consider these are category series.
Then i have got a dynamic number of reports each report has some report specific properties which i am displaying in the form of a tool tip for each report.
Each report falls under the mentioned categories(30,45,60,90) .
Note :Each report is dynamic .In the example you have provided the reports or chart elements are defined in the xaml .
The issue i am facing if i add the series dynamically i need to have a datatable with 4 rows that represent 4 categories and for each extra series(reports)
i need to add a column dynamically to the datatable and set the value .
So for each series (row) i have 4 columns that represent 4 reports with their values.
But the issue each report item has multiple values specific to that report such as colour,value and 5 to 6 properties which cannot be made as a single column value as per my requirement.Hope you understand my requirement .Thanks in advance fo all you do.
Xaml Code:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" >
<!--<Border Grid.Row="0" Height="{Binding ElementName=gdReportGraph,Path=Height}" BorderBrush="Black" BorderThickness="0.5" HorizontalAlignment="Stretch"
Margin="20,20,20,20" VerticalAlignment="Stretch" Visibility="Hidden" ></Border>-->
<Grid Name="GdReportGraph" Visibility="Visible" >
<Grid.Resources>
<ContentControl x:Key="VariationTooltip" >
<StackPanel Orientation="Vertical" Background="Transparent" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="Service: " FontWeight="Bold" Foreground="Black"/>
<TextBlock Text="{Binding Item.ServiceName}" Foreground="Black" />
</StackPanel>
<TextBlock Text="Report: " FontWeight="Bold" Foreground="Black" />
<TextBlock Text="{Binding Item.ReportName}" Foreground="Black" />
<TextBlock Text="{Binding Item.ToolTipHeaderText}" FontWeight="Bold" Foreground="Black" />
<TextBlock Text="{Binding Item.DataDensityValue}" Foreground="Black" />
<TextBlock Text="Actual Value: " FontWeight="Bold" Foreground="Black" Visibility="{Binding Item.ToolTipVisibility}"/>
<TextBlock Text="{Binding Item.NormalizedUpdateRate}" Foreground="Black" Visibility="{Binding Item.ToolTipVisibility}"/>
<TextBlock Text="Difference: " FontWeight="Bold" Foreground="Black" Visibility="{Binding Item.ToolTipVisibility}"/>
<TextBlock Text="{Binding Item.DensityVariation}" Foreground="Black" Visibility="{Binding Item.ToolTipVisibility}"/>
<TextBlock Text="Repeats: " FontWeight="Bold" Foreground="Black" />
<TextBlock Text="{Binding Item.OptimizedSequence}" Foreground="Black" />
</ContentControl>
</Grid.Resources>
<RowDefinition Height="10"/>
<RowDefinition Height="*"/>
<ig:XamDataChart x:Name="Chart" Margin="2,2,0,-200" Grid.Row="1" >
<ig:XamDataChart.Axes>
<ig:CategoryXAxis x:Name="XAxis" ItemsSource="{Binding ListOfReportDistribution,UpdateSourceTrigger=PropertyChanged}" Label="{}{RopReport}" Title="Reports" Overlap="1" >
<!--Label="{}{ReportName}"-->
<!--<ig:CategoryXAxis.LabelSettings >
<ig:AxisLabelSettings Angle="-60" VerticalAlignment="Center" TextAlignment="Justify" />
</ig:CategoryXAxis.LabelSettings>-->
</ig:CategoryXAxis>
<ig:NumericYAxis x:Name="YAxis" MinimumValue="0" MajorStrokeThickness="0" MinorStrokeThickness="0" Title="Data Density (pts/ft)" >
<ig:NumericYAxis.TitleSettings >
<ig:TitleSettings Angle="-90" Position="Auto" />
</ig:NumericYAxis.TitleSettings>
</ig:NumericYAxis>
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:ColumnSeries Name="DensitySeries" Margin="0,0,0,0" ShowDefaultTooltip="True" HorizontalAlignment="Stretch" XAxis="{Binding ElementName=XAxis}" YAxis="{Binding ElementName=YAxis}"
ItemsSource="{Binding ListOfReportDistribution,UpdateSourceTrigger=PropertyChanged}" ValueMemberPath="DataDensityValue"
Thickness='0' MinWidth="200" Outline='Black' LegendItemVisibility="Visible" IsTransitionInEnabled="True" ToolTip="{StaticResource VariationTooltip}"
IsCustomCategoryStyleAllowed="True" AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyle" >
<ig:ColumnSeries.LegendItemBadgeTemplate>
<DataTemplate>
</DataTemplate>
</ig:ColumnSeries.LegendItemBadgeTemplate>
</ig:ColumnSeries>
<ig:ColumnSeries Name="DensityVariationSeries" ShowDefaultTooltip="True" HorizontalAlignment="Stretch"
XAxis="{Binding ElementName=XAxis}" YAxis="{Binding ElementName=YAxis}"
ItemsSource="{Binding ListOfReportDistribution,UpdateSourceTrigger=PropertyChanged}" Brush="Transparent"
DashArray="20,2" ToolTip="{StaticResource VariationTooltip}" ToolTipService.IsEnabled="True"
AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyle" ValueMemberPath="NormalizedUpdateRate"
MinWidth="200" Outline='Black' LegendItemVisibility="Visible" IsTransitionInEnabled="True" >
</ig:XamDataChart.Series>
</ig:XamDataChart>
</Grid>
<Grid Name="ReportGraphRop" >
<ContentControl x:Key="VariationTooltipRop" >
<ig:XamDataChart x:Name="DataChartRop" Visibility="Hidden" >
<ig:CategoryXAxis x:Name="Xaxis" ItemsSource="{Binding DefaultView}" Label="{}{RopReport}" Title="Reports"/>
<ig:NumericYAxis x:Name="Yaxis" MinimumValue="0" MajorStrokeThickness="0" MinorStrokeThickness="0" Title="Data Density (pts/ft)" >
<ig:XamDataChart.Series >
<ig:ColumnSeries Margin="0,0,0,0" Name="DensitySeriesRop" ShowDefaultTooltip="True" HorizontalAlignment="Stretch"
XAxis="{Binding ElementName=XAxis}" YAxis="{Binding ElementName=YAxis}" ItemsSource="{Binding DefaultView}" ValueMemberPath="DataDensityValue"
Thickness='0' Outline='Black' LegendItemVisibility="Visible" IsTransitionInEnabled="True" ToolTip="{StaticResource VariationTooltipRop}"
IsCustomCategoryStyleAllowed="True" AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyleBasedonRop" >
Sridhar
Attached is the sample which explains the problem i am facing in dynamic addition of series .
Hello Sridhar,
I have been investigating into this issue, as Chris is not currently in the office at the moment.
I believe that I understand this issue that you are seeing, but the sample project that you had sent doesn't really seem to demonstrate the issue that you mentioned in your recent post. Being that each report item has multiple values specific to that particular report though, I am curious if it would be possible on your end to set those "specific" values for columns that do not contain that value to null.
For example, suppose you had a DataTable with the columns RopReport, Report1, Report2, Report3, and only report 3 has a "Color" property for a particular RopReport value. In this case, you could add something like a "Report3Color" column to your table. For the RopReport value where this color exists, you could set the color there, and for all other RopReport values, this column value would be null.
Another option could be to create a Column with its data type being some sort of custom class or interface of your creation. What this would allow you to do is essentially populate these column values with custom objects that hold different properties corresponding to a specific report. You could then bind your XamDataChart tooltips to those underlying nested properties in order to display them in the chart.
I'm not positive that the above would really resolve this issue in your scenario as I'm not entirely sure I completely understand your scenario on this matter. If the above is not exactly what you were looking for, would it be possible for you to please provide some more information on this matter?
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
Thanks a lot for your suggestions.
If possible can you please provide me a sample that follows the 2nd approach.
Thanks in advance for all you do.
I have attached a sample project to demonstrate my second approach, as requested.
In this sample, note that there exists an interface named IReport that both the NormalReport and PropertySpecificReport classes derive from. In the DataTable, there are columns that target the type IReport, so they can accept both of these NormalReport and PropertySpecificReport types. The "PropertySpecificReport" type has a Brush property that the NormalReport type doesn't, and this Brush will be shown as the Fill of a Rectangle in the tooltips for the columns that represent PropertySpecificReport objects.
One little snag that I ran into is that the XamDataChart does not accept nested properties for the ValueMemberPath of its series. To get around this, for each "IReport" column in the data table, I created a second column named ReportNValue that returns the Value meant for the ValueMemberPath of the particular report object that exists in the IReport column.
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.