Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3590
Dynamically add series?
posted

The samples that come with the 10.2 DV product do not have any samples on dynamically adding anything and all my CTP code is completely different. Does anyone have a sample of dynamically adding a few series to a data chart? I am obviously missing something as I continuously get an error of value out of range but no details as to what value. My code does not throw any error, it simply gets caught in the app_unhandledexception.

What I have done is try to add items that will not change in the xaml and then dynamically add the series.

<igCtrls:XamDock x:Name="XamDataChartContainer" Margin="0">
        <Border Style="{StaticResource BorderStyle}">
            <Border.Effect>
                <DropShadowEffect Color="Black"
                                      BlurRadius="10"
                                      ShadowDepth="0"
                                      Opacity="0.7"></DropShadowEffect>
            </Border.Effect>
        </Border>
        <igChart:XamDataChart x:Name="xmDataChart" Margin="0" Height="300">
            <igChart:XamDataChart.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF435053" Offset="0"/>
                    <GradientStop Color="#FF404D50" Offset="1"/>
                </LinearGradientBrush>
            </igChart:XamDataChart.Background>
            <igChart:XamDataChart.Axes>
                <igChart:CategoryXAxis x:Name="XAxis"
                                        Style="{StaticResource CategoryXAxisStyle}"
                                        ItemsSource="{Binding}"
                                        Label="{}{TimeStamp:M/d HH:mm}">
                    <igChart:CategoryXAxis.LabelSettings>
                        <igChart:AxisLabelSettings Location="OutsideBottom"
                                                       Visibility="Visible" />
                    </igChart:CategoryXAxis.LabelSettings>
                </igChart:CategoryXAxis>
            </igChart:XamDataChart.Axes>
            <igChart:XamDataChart.Series>
                <!-- Dynamically add in the series -->
            </igChart:XamDataChart.Series>

           
        </igChart:XamDataChart>
        <igChart:Legend x:Name="xmLegendOTC"
                            Content="Legend"
                            igCtrls:XamDock.Edge="OutsideLeft"
                            igCtrls:XamDock.HorizontalDockAlignment="Left"
                            igCtrls:XamDock.VerticalDockAlignment="Top"
                            Style="{StaticResource LegendStyle}">
        </igChart:Legend>
        <StackPanel Orientation="Vertical"
                        igCtrls:XamDock.Edge="OutsideLeft"
                        igCtrls:XamDock.VerticalDockAlignment="Bottom"
                        Margin="0,0,0,0" >
            <Button x:Name="btnHistory" Click="btnHistory_Click" Width="32" Height="32"
                        Style="{StaticResource customButtonStyle}"
                        Margin="19,5"
                        ToolTipService.ToolTip="Show History">
                <Image Source="images/clock_play.png" Stretch="None" RenderTransformOrigin="0.5,0.5" />
            </Button>
            <Button x:Name="btnPrint" Click="btnPrint_Click" Width="32" Height="32" Style="{StaticResource customButtonStyle}" Margin="19,5" ToolTipService.ToolTip="Print">
                <Image Source="images/printer.png" Stretch="None" RenderTransformOrigin="0.5,0.5" />
            </Button>
        </StackPanel>
    </igCtrls:XamDock>

*** code behind ***
string channelName = "test series";

// create new Y axis
NumericYAxis yaxis = new NumericYAxis();
yaxis.Visibility = System.Windows.Visibility.Collapsed;
yaxis.Name = channelName;
xmDataChart.Axes.Add(yaxis);

StepLineSeries series = new StepLineSeries();
series.Title = channelName;
series.ValueMemberPath = "Value";
series.XAxis = xmDataChart.Axes["XAxis"] as CategoryXAxis;
//series.XAxis.Label = "{TimeStamp:HH:mm}";
series.YAxis = yaxis;

I have left some linkage off somewhere but I am unsure how to mixed the static and dynamic content into the same datachart.