Hello,
is there any Possibility to bind all Axes and all Plots only in Viewmodel ?
Now i have defined the Axes and Plots in Xaml, but i want to generate it dynamic. Is this possible via the ViewModel ?
My Graph looks now like this:
<ni:Graph x:Name="graph" Grid.Row="0" Margin="10,10,5,5" Grid.Column="0" DataSource="{Binding chartCollection}" PreferIndexData="True" SuppressScaleLayout="True"><ni:Graph.Axes><ni:AxisDouble x:Name="xScale" Orientation="Horizontal" Adjuster="ContinuousChart" InteractionMode="None" Visibility="Hidden" Range="0, 600, System.Double"></ni:AxisDouble><ni:AxisDouble Orientation="Horizontal" Range="0, 60, System.Double" /><ni:AxisDouble x:Name="yScale1" Range="0,900" Orientation="Vertical" MinorDivisions="{x:Null}" Adjuster="None" InteractionMode="None" InnerMargin="5" BaselineStroke="{StaticResource YScale1Brush}" ><ni:AxisDouble.MajorDivisions><ni:RangeLabeledDivisions LabelBrush="{StaticResource YScale1Brush}" /></ni:AxisDouble.MajorDivisions></ni:AxisDouble><ni:AxisDouble x:Name="yScale2" Range="0,900" Orientation="Vertical" MinorDivisions="{x:Null}" Adjuster="None" InteractionMode="None" InnerMargin="10" BaselineStroke="{StaticResource YScale2Brush}" ><ni:AxisDouble.MajorDivisions><ni:RangeLabeledDivisions LabelBrush="{StaticResource YScale2Brush}" /></ni:AxisDouble.MajorDivisions></ni:AxisDouble><ni:AxisDouble x:Name="yScale3" Range="0, 900, System.Double" Orientation="Vertical" MinorDivisions="{x:Null}" Adjuster="None" InteractionMode="None" Location="Far" InnerMargin="5" BaselineStroke="{StaticResource YScale3Brush}" ><ni:AxisDouble.MajorDivisions><ni:RangeLabeledDivisions LabelBrush="{StaticResource YScale3Brush}" /></ni:AxisDouble.MajorDivisions></ni:AxisDouble><ni:AxisDouble x:Name="yScale4" Range="0, 900, System.Double" Orientation="Vertical" MinorDivisions="{x:Null}" Adjuster="None" InteractionMode="None" Location="Far" InnerMargin="10" BaselineStroke="{StaticResource YScale4Brush}"><ni:AxisDouble.MajorDivisions><ni:RangeLabeledDivisions LabelBrush="{StaticResource YScale4Brush}" /></ni:AxisDouble.MajorDivisions></ni:AxisDouble></ni:Graph.Axes><ni:Graph.Plots><ni:Plot VerticalScale="{Binding ElementName=yScale1}" Label="TA1"><ni:LinePlotRenderer Stroke="{Binding Plot1Color}" StrokeThickness="3" /></ni:Plot><ni:Plot VerticalScale="{Binding ElementName=yScale2}" Label="TA2"><ni:LinePlotRenderer Stroke="Yellow" StrokeThickness="3" /></ni:Plot><ni:Plot VerticalScale="{Binding ElementName=yScale3}" Label="NA1"><ni:LinePlotRenderer Stroke="Blue" StrokeThickness="3" /></ni:Plot><ni:Plot VerticalScale="{Binding ElementName=yScale4}" Label="NA2" ><ni:LinePlotRenderer Stroke="Red" StrokeThickness="3" /></ni:Plot></ni:Graph.Plots></ni:Graph>
My ViewModel looks aktually like this:
public ChartCollection<double>[] chartCollection { get; set; } chartCollection = new[] { new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000), new ChartCollection<double>(1000) }; and data-insert : test = hw.T_a1Actual.ToString(); chartCollection[0].Append(hw.T_a1Actual); chartCollection[1].Append(hw.T_a2Actual); chartCollection[2].Append(hw.n_a1Actual); chartCollection[3].Append(hw.n_a2Actual); }));
But i want to generate all Axes and all Plots dynamic. What is the best Way to do this ?
Can i do this via the ViewModel ?
Thanks in advance
Manuel