Pre loader

Tag: Binding

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

1 vote
5k views

Hi, Support team.

I’m using MVVM pattern and trying to implement multi-chart which can insert Box Annotations at the same time into each chart .
So I’m testing in SciChart Example [“DigitalAnalyzerPerformanceDemo”] to know how to implement this.

But what i only got is just looping through and create annotation for each ChannelViewModels.

In the Demo, the VisibleRange ‘XRange’ is shared to all the ChannelViewModels by binding TwoWay-mode in ParentViewModel without looping for each ChildViewModels.
Like this, I wonder is there ways to apply BoxAnnotation all the ChannelViewModel at the same time by binding in ParentViewModel.

    <!-- BottomAxis -->
        <s:SciChartSurface Grid.Column="1">
            <s:SciChartSurface.XAxis>
                <s:NumericAxis Height="30"
                               AxisAlignment="Bottom"
                               VisibleRange="{Binding XRange, Mode=TwoWay}"                 
                               LabelProvider="{StaticResource TimeLabelProvider}"
                               MajorTickLineStyle="{StaticResource TimeAxisMajorTickLineStyle}"
                               MinorTickLineStyle="{StaticResource TimeAxisMinorTickLineStyle}"/>
            </s:SciChartSurface.XAxis>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis Visibility="Collapsed"/>
            </s:SciChartSurface.YAxis>
        </s:SciChartSurface>
    </Grid>

    <!--  Create an X Axis with GrowBy  -->
     <s:SciChartSurface.XAxis>
           <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                    VisibleRangeLimitMode="Min"
                    VisibleRangeLimit="0,0"
                    VisibleRange="{Binding DataContext.XRange, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}"/>
     </s:SciChartSurface.XAxis>

I tried to bind annotation in ParentViewModel like XRange Binding method, But it doesn’t work.


This is View.xaml.

<Grid Grid.IsSharedSizeScope="True" IsEnabled="{Binding IsLoading, Converter={StaticResource InvertBooleanConverter}}">


    <!-- BottomAxis -->
        <s:SciChartSurface Grid.Column="1">
            <s:SciChartSurface.XAxis>
                <s:NumericAxis Height="30"
                               AxisAlignment="Bottom"
                               VisibleRange="{Binding XRange, Mode=TwoWay}"                 
                               LabelProvider="{StaticResource TimeLabelProvider}"
                               MajorTickLineStyle="{StaticResource TimeAxisMajorTickLineStyle}"
                               MinorTickLineStyle="{StaticResource TimeAxisMinorTickLineStyle}"/>
            </s:SciChartSurface.XAxis>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis Visibility="Collapsed"/>
            </s:SciChartSurface.YAxis>
        </s:SciChartSurface>
    </Grid>

    <!-- Channels -->
        <ScrollViewer Background="#1C1C1E"
                      VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Disabled">

            <b:Interaction.Behaviors>
                <common:DigitalAnalyzerScrollBehavior ChannelHeightDelta="10" ChangeChannelHeightCommand="{Binding ChangeChannelHeightCommand}"/>
            </b:Interaction.Behaviors>

            <ItemsControl x:Name="chartItemsControl" ItemsSource="{Binding ChannelViewModels}">

                <b:Interaction.Behaviors>
                    <common:FocusedChannelScrollBehavior ScrollToFocusedChannel="False"/>
                </b:Interaction.Behaviors>

                <ItemsControl.ItemTemplate>
                    <DataTemplate DataType="{x:Type local:ChannelViewModel}">
                        <Grid Background="#2D2C32" Height="{Binding ChannelHeight, Mode=OneWay}" Focusable="False" UseLayoutRounding="False" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="ChannelNames" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Border BorderThickness="0,0,0,1" BorderBrush="#1C1C1E">
                                <DockPanel>
                                    <Border DockPanel.Dock="Left"     
                                            Background="{Binding ChannelColor, Mode=OneWay}" 
                                            Width="5"/>

                                    <TextBlock DockPanel.Dock="Left"
                                               Margin="10,5"
                                               VerticalAlignment="Center"
                                               Foreground="White"
                                               Text="{Binding ChannelName}"/>
                                </DockPanel>
                            </Border>

                            <s:SciChartSurface x:Name="channelSurface" Grid.Column="1"
                                               RenderableSeries="{Binding RenderableSeries}"
                                               Annotations="{s:AnnotationsBinding  DataContext.Annotations, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2} }">

                                <!--  Create an X Axis with GrowBy  -->
                                <s:SciChartSurface.XAxis>
                                    <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                                                   VisibleRangeLimitMode="Min"
                                                   VisibleRangeLimit="0,0"
                                                   VisibleRange="{Binding DataContext.XRange, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ItemsControl, AncestorLevel=2}}"/>
                                </s:SciChartSurface.XAxis>

                                <!--  Create a Y Axis with GrowBy. Optional bands give a cool look and feel for minimal performance impact  -->
                                <s:SciChartSurface.YAxis>
                                    <s:NumericAxis Style="{StaticResource HiddenAxisStyle}"
                                                   VisibleRange="{Binding YRange, Mode=OneWay}"/>
                                </s:SciChartSurface.YAxis>

                                <s:SciChartSurface.ChartModifier>
                                    <s:ModifierGroup s:MouseManager.MouseEventGroup="ChannelModifierGroup">
                                        <s:RubberBandXyZoomModifier IsAnimated="False" IsXAxisOnly="True" ZoomExtentsY="False" ReceiveHandledEvents="True" IsEnabled="{Binding IsChecked, Mode=OneWay, ElementName=IsZoomEnabled}"/>
                                        <s:ZoomPanModifier ZoomExtentsY="False" XyDirection="XDirection" IsEnabled="{Binding IsChecked, Mode=OneWay, ElementName=IsPanEnabled}"/>
                                        <s:ZoomExtentsModifier XyDirection="XDirection" IsAnimated="False" />
                                        <s:MouseWheelZoomModifier XyDirection="XDirection" />
                                    </s:ModifierGroup>
                                </s:SciChartSurface.ChartModifier>
                            </s:SciChartSurface>

                            <Border Grid.Column="1"
                                    BorderThickness="0,0,0,1"
                                    BorderBrush="#2D2C32"
                                    VerticalAlignment="Bottom"/>
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Border>


</Grid>

This is ViewModel.cs

public class DigitalAnalyzerExampleViewModel : BaseViewModel
{
    private bool _isLoading;
    private DoubleRange _xRange;

    public DigitalAnalyzerExampleViewModel()
    {
        ChannelViewModels = new ObservableCollection<ChannelViewModel>();
        Annotations = new ObservableCollection<IAnnotationViewModel>();
        Annotations.Add(new BoxAnnotationViewModel() { X1 = 0, X2 = 1000, Y1 = 0, Y2 = 1 }); //I want to implement sharing annotation like this.

        SelectedChannelType = "Digital";
        SelectedChannelCount = 32;
        SelectedPointCount = 1000000;
        SelectedResamplingPrecision =ResamplingPrecision.Default;
        SelectedStrokeThickness = 1;

        ChangeChannelHeightCommand = new ActionCommand<object>((d) =>
        {
            var delta = (double)d;
            foreach (var channelViewModel in ChannelViewModels)
            {
                channelViewModel.SetChannelHeightDelta(delta);
            }
        });

        AddChannelCommand = new ActionCommand(async () =>
        {
            IsLoading = true;

            var isDigital = SelectedChannelType == "Digital";
            await AddChannels(isDigital ? 1 : 0, isDigital ? 0 : 1);

            IsLoading = false;
        });

        LoadChannelsCommand = new ActionCommand(async () =>
        {
            IsLoading = true;

            // Clear ViewModels
            foreach (var channelVm in ChannelViewModels)
            {
                channelVm.Clear();
            }
            ChannelViewModels.Clear();
            XRange = null;

            // Create a bunch of Digital channels
            await AddChannels(SelectedChannelCount, 0);

            XRange = new DoubleRange(0, SelectedPointCount);
            IsLoading = false;
        });

        LoadChannelsCommand.Execute(null);
    }


    public ObservableCollection<ChannelViewModel> ChannelViewModels { get; private set; }
    public ObservableCollection<IAnnotationViewModel> Annotations { get; private set; }

    public string SelectedChannelType { get; set; }


    public ResamplingPrecision SelectedResamplingPrecision { get; set; }

    public int SelectedChannelCount { get; set; }

    public ActionCommand<object> ChangeChannelHeightCommand { get; }

    public ActionCommand AddChannelCommand { get; }

    public ActionCommand LoadChannelsCommand { get; }

    public long TotalPoints => ChannelViewModels.Sum(c => (long)c.DataCount);

    public bool IsLoading
    {
        get => _isLoading;
        set
        {
            _isLoading = value;
            OnPropertyChanged(nameof(IsLoading));
        }
    }

    public bool IsEmpty => ChannelViewModels.Count <= 0;

    public DoubleRange XRange
    {
        get => _xRange;
        set
        {
            _xRange = value;
            OnPropertyChanged(nameof(XRange));
        }
    }
}

+Attached image below is what i want to implement.
++I also attached tried code in .zip .

0 votes
5k views

Hi,
I am trying to create a new FastUniformHeatMap at runtime and bind it to a dataset, everything needs to be done in the code behind and I am not using MVVM.
I can create the HeatMap in the code behind with:

        SciChartSurface g2d = new SciChartSurface();
        FastUniformHeatmapRenderableSeries fuhrs = new FastUniformHeatmapRenderableSeries();
        HeatmapColorPalette hcp = new HeatmapColorPalette();
        NumericAxis xaxis = new NumericAxis();
        NumericAxis yaxis = new NumericAxis();
        g2d.RenderableSeries = new ObservableCollection<IRenderableSeries>() { fuhrs };
        g2d.XAxis = xaxis;
        g2d.YAxis = yaxis;

I can set the DataSeries with:

       g2d.RenderableSeries[0].DataSeries = myDataSeries;

(Where myDataSeries is a property returning a UniformHeatMapDataSeries object)

and I get my image, however, it is not bound to the property and if myDataSeries changes the image will not change.

How do I bind the DataSeries instead of just setting it, in this case?

I can make it work easily from the Xaml:

< sciChart:FastUniformHeatmapRenderableSeries DataSeries=”{Binding Path=myDataSeries, Mode=OneWay}” />

but I cannot figure out how to do it from the code behind.

1 vote
0 answers
7k views

Hi Sci Chart,

I am using WPF with MVVM.

What i want to achieve is by reading the rollover modifier current hit point data, when user click left click, i want to add VerticalSliceModifier in the graph based on the hit point.

Attach is my code from xaml and viewmodel.

I have two issues which are:
“if (DistanceSeriesData.SeriesInfo.Count > 0)”, i always get zero count of seriesinfo.

In DistanceVerticalLines?.Add(new VerticalLineAnnotation(), the added Distance Vertical Lines data did not reflect in graph.

0 votes
7k views

Hello,

I am trying to export my 3D chart to a file using SciChart3DSurface.ExportToFile. However, I am getting this error:

InvalidOperationException: There was an error reflecting property ‘InputBindings’.

Code behind:

var surface = ResultTestContent.Positional6DOFErrorTestPage.PositionalChart;
surface.ExportToFile($@"C:\temp\ChartTest.jpeg", SciChart.Core.ExportType.Jpeg, true,new Size(800,800));

XAML:

<s3D:SciChart3DSurface x:Name="PositionalChart" Grid.Column="1" ShowLicensingWarnings="True"
                    IsFpsCounterVisible="False"
                     IsAxisCubeVisible="True"
                     IsXyzGizmoVisible="False"
                     CoordinateSystem="RightHanded"
                           Background="White"
                           DebugWhyDoesntSciChartRender="True" RenderableSeries="{extensions:SeriesBinding RenderSeries3DViewModels}"
                           Visibility="Collapsed">

        <!-- Create XAxis -->
        <s3D:SciChart3DSurface.XAxis>
            <s3D:NumericAxis3D TickTextBrush="Black" AxisTitle="X (mm)" DrawMajorBands="True" DrawMajorGridLines="True"
                    DrawMinorGridLines="False"
                    DrawMajorTicks="True"
                    DrawMinorTicks="True"
                               MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                    AxisBandsFill="LightCyan"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.XAxis>
        <!-- Create YAxis -->
        <s3D:SciChart3DSurface.YAxis>
            <s3D:NumericAxis3D AxisTitle="Z (mm)" MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                               DrawMinorGridLines="False"
                    AxisBandsFill="LightCyan"
                    TickTextBrush="Black"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.YAxis>
        <!-- Create ZAxis -->
        <s3D:SciChart3DSurface.ZAxis>
            <s3D:NumericAxis3D AxisTitle="Y (mm)" MajorGridLineStyle="{StaticResource ResourceKey=MajorGridLineStyle}"
                               MinorGridLineStyle="{StaticResource ResourceKey=MinorGridLineStyle}"
                               DrawMinorGridLines="False"
                    AxisBandsFill="LightCyan"
                    TickTextBrush="Black"
                    FontSize="10"
                    TickLabelAlignment="Camera"
                               GrowBy="0.1, 0.1"/>
        </s3D:SciChart3DSurface.ZAxis>

        <!-- Create Interactivity Modifiers for rotating camera -->
        <s3D:SciChart3DSurface.ChartModifier>
            <s3D:ModifierGroup3D>
                <s3D:OrbitModifier3D ExecuteOn="MouseLeftButton" ExecuteWhen="None"/>
                <s3D:MouseWheelZoomModifier3D MouseWheelSensitivity="90" />
                <s3D:FreeLookModifier3D ExecuteOn="MouseRightButton"/>
                <s3D:TooltipModifier3D IsEnabled="True" SourceMode="AllSeries" ShowTooltipOn="MouseOver"/>
            </s3D:ModifierGroup3D>
        </s3D:SciChart3DSurface.ChartModifier>
    </s3D:SciChart3DSurface>

I’ve removed the binding from the xaml, yet I am still getting the same issue. Any help is appreciated, thanks.

0 votes
11k views

Hello

I have 2 charts, a 2D Heatmap and a 3D Waterfall chart, and I want to be able to programmatically change their color palettes.

The 2D heatmap is set up like this, with the GradientStops bound to an ObservableCollection:

...
<s:HeatmapColorPalette x:Key="HeatmapColorPalette" Maximum="{Binding MaxValue,Mode=TwoWay}"  GradientStops="{Binding ColorPalette}"/>
...
<s:SciChartSurface.RenderableSeries>
    <s:FastUniformHeatmapRenderableSeries 
        x:Name="heatmapSeries" 
        DataSeries="{Binding Data}"
        ColorMap="{StaticResource HeatmapColorPalette}">
    </s:FastUniformHeatmapRenderableSeries>
 </s:SciChartSurface.RenderableSeries>
...

This works as expected. When the binding changes the palette/heatmap changes.

The 3D waterfall is set up the similarly:

...
<s3D:GradientColorPalette x:Key="GradientColorPalette" IsStepped="False"  GradientStops="{Binding ColorPalette}" />
...
<s3D:SciChart3DSurface.RenderableSeries>
    <s3D:WaterfallRenderableSeries3D
        x:Name="waterfallSeries"
        DataSeries="{Binding Data3D}"
        YColorMapping="{StaticResource GradientColorPalette}"
        SliceThickness="1">
    </s3D:WaterfallRenderableSeries3D>
</s3D:SciChart3DSurface.RenderableSeries>
...

This, when passed the same data, doesn’t render the chart.
This chart otherwise works fine if I define the GradientStops statically in the XAML.

This is the GradientStops definition (in f#):

let BlueRed = 
        new ObservableCollection<GradientStop>([
            new GradientStop(Color.FromRgb(0x00uy,0x00uy,0xFFuy),0.0)
            new GradientStop(Color.FromRgb(0xFFuy,0x00uy,0x00uy),1.0)
        ])

I am not sure what I am missing.

(edit: apologies for formatting issues in the question)

0 votes
0 answers
8k views

Hi,

I would like to know if there’s a way to show a list of Annotations for which the coordinates are stored in lists in my c# code. I can bind the items in the lists like this:

s:SciChartSurface.Annotations …>
s:CustomAnnotation X1=”{Binding XList[0]}” Y1=”{Binding YList[0]}” …/>
s:CustomAnnotation X1=”{Binding XList[1]}” Y1=”{Binding YList[1]}” …/>
s:CustomAnnotation X1=”{Binding XList[2]}” Y1=”{Binding YList[2]}” …/>
s:CustomAnnotation X1=”{Binding XList[3]}” Y1=”{Binding YList[3]}” …/>
/s:SciChartSurface.Annotations …>

Is there a way to do this with something like ItemsControl?

Thanks,
Rachel

1 vote
9k views

Hello, SciChart Team!
i have an issue using mouse drag event ( RubberBandXyZoomModifier, ZoomPanMidifier). the message says “NullReferenceException in SciChart.Charting.dll ” or “Thread.cs not found” from time to time.
after some experiments i figured out that the app starts to crush after i change XAxis type .
i have a simple mvvm user control used to display both arrays of double and datebound data, XAxes of SciChart Surfase is bound to an observable collection of IAxis elements. if i need to change chart type i clear this collection and create an axis of desired type (DateTimeAxisViewModel or NumericAxisViewModel). after that the series can be added, but zooming causes crash with nearly to no info.

i attached a solution, which lacks only scichart dlls in order to run (hopefully), Window_Loaded method has a commented line which changes chart type and makes app crush on zooming, would be nice if you checked it out.
Thanks in advance!
Alexander

0 votes
10k views

Hi,

I’m trying to bind the maximum value of the HeatmapColorPalette in v5 in order to autorange the colormap to the data.

        <s:FastUniformHeatmapRenderableSeries x:Name="heatmapSeries" DataSeries="{Binding Data}" Opacity="0.9">
            <s:FastUniformHeatmapRenderableSeries.ColorMap>
                <s:HeatmapColorPalette Maximum="{Binding ColorMaximum}">
                    <s:HeatmapColorPalette.GradientStops>
                        <GradientStop Offset="0" Color="DarkBlue"/>
                        <GradientStop Offset="0.2" Color="CornflowerBlue"/>
                        <GradientStop Offset="0.4" Color="DarkGreen"/>
                        <GradientStop Offset="0.6" Color="Chartreuse"/>
                        <GradientStop Offset="0.8" Color="Yellow"/>
                        <GradientStop Offset="1" Color="Red"/>
                    </s:HeatmapColorPalette.GradientStops>
                </s:HeatmapColorPalette>
            </s:FastUniformHeatmapRenderableSeries.ColorMap>
        </s:FastUniformHeatmapRenderableSeries>

This previously worked in v4

            <s:FastHeatMapRenderableSeries x:Name="heatmapSeries" 
                                           DataSeries="{Binding Data}" 
                                           Opacity="0.9"
                                           Maximum="{Binding ColorMaximum}" 
                                           Minimum="{Binding ColorMinimum}"/>

The heatmap no longer refreshes to the new range when using the FastUniformHeatmapRenderableSeries instead of FastHeatMapRenderableSeries. Does anyone know why?

Regards,

  • Kevin Yeh asked 6 years ago
  • last active 6 years ago
0 votes
6k views

Hi,

I´ve encountered following problem. My application should visualize variables of a machine. The user can select those variables an organize them in goups. For each group a SciChartSurface should be visualized with the selected variable as DataSeries.

Therefore I created a ViewModel for those groups. Holding them in a ObservableCollection wich is bound to an ItemsControl:

<ItemsControl
        Grid.Row="1"
        Grid.Column="1"
        Grid.ColumnSpan="6"
        HorizontalContentAlignment="Stretch"
        VerticalContentAlignment="Stretch"
        PreviewMouseWheel="XAxis_MouseWheel"
        PreviewMouseUp="ListView_OnMiddleMouseUp"
        d:PreviewKeyDown="ListView_OnPreviewKeyDown"
        d:PreviewKeyUp="ListView_OnPreviewKeyUp"
        ItemsSource="{Binding ChartViewModels}"
        >
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="1"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="traceControl:ChartViewModel">
                <Grid
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    >

                    <s:SciChartSurface Loaded="ChartSurface_Loaded" 
                                       Unloaded="ChartSurface_Unloaded"
                                       Background="White"

                                       >

                      <!-- Some other stuff is also in here, modifiers and axissetup -->

                    </s:SciChartSurface>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>

    </ItemsControl>

There is a Refresh-Action. It does clearing the the ViewModel Collection and creating new ViewModels depending on the configuration and fill them in the ViewModel Collection.

If both actionparts (clearing and filling data) were executed together in for example the ICommand of a button, the memory footprint is increasing each time the refresh button is hit.

If the actionparts were executed one by one, e.g. a clear button and a fill button, everything is fine.

Do I miss something?

Thanks in advance!

Markus

p.s. I was not allowed to add Screenshots of dotMemory

0 votes
7k views

I am trying to bind from my ViewModel to the DataSeries of a ScatterRenderableSeries3D, but no data is showing.

I am binding in this way:

My ViewModel has a property of type ObservableCollection<XyzDataSeries3D<DateTime, double, int>>. I can populate ChartItems, and see the data in it. The property is being notified of change as expected.

If I populate the DataSeries directly from code behind, it works, but not when being bound.

What am I doing wrong?

0 votes
10k views

Hello,

I want to use user’s settings in my application. I’ve created my own window for settings with checkboxes and colorpickers.

I’ve binded my series with settings like that

 <s:SciChartSurface.RenderableSeries>
            <s:FastLineRenderableSeries x:Name="tLineSeries1" StrokeDashArray="7 4" StrokeThickness="3" YAxisId="RightAxis" >
                <s:FastLineRenderableSeries.IsVisible>
                    <Binding Source="{x:Static ProjectProperties:Settings.Default}" Path="Visibility1" />
                </s:FastLineRenderableSeries.IsVisible>
                <s:FastLineRenderableSeries.SeriesColor>
                    <Binding Source="{x:Static ProjectProperties:Settings.Default}" Path="Color1" />
                </s:FastLineRenderableSeries.SeriesColor>
            </s:FastLineRenderableSeries>

Everything is working fine and after restarting the application i get the colors and visibility of series as i want.

The problems starts after turning on ShowVisibilityCheckboxes=”true” in LegendModifier. After that, my settings dont work at all. Is there any way how can i bind checkboxes from the legends with my own created checkboxes or settings? In other words, how can i make them both to work “together”?

0 votes
12k views

Hi,

in a MVVM scenario, I bind the AnimatedVisibleRange to a property in the view model.

 <s:SciChartSurface SeriesSource="{Binding ChartSeries}">
   <s:SciChartSurface.XAxis>
     <s:NumericAxis AxisTitle="x" AnimatedVisibleRange="{Binding XVisibleRange, Mode=TwoWay}" AutoRange="Never" />
   </s:SciChartSurface.XAxis>
   <s:SciChartSurface.YAxis>
     <s:NumericAxis AxisTitle="y" AnimatedVisibleRange="{Binding YVisibleRange, Mode=TwoWay}" AutoRange="Never" />
   </s:SciChartSurface.YAxis>
   <s:SciChartSurface.ChartModifier>
     <s:ModifierGroup>
       <s:MouseWheelZoomModifier IsEnabled="True" XyDirection="XDirection"/>
     </s:ModifierGroup>
   </s:SciChartSurface.ChartModifier>
 </s:SciChartSurface>

Setting the XVisibleRange property in the view model smoothly animates the view. However, when I zoom in the chart with the mouse wheel, the view model property receives no updates (so the XVisibleRange property in the view model always stays on the value initially set by the view model).

The same thing works when I bind he VisibleRange instead of the AnimatedVisibleRange, i.e. in that case I get an update of the view model property on every mouse wheel zoom.

Is this intendend, or a bug? Building a workaround would require additional bindings, which I would like to avoid.

Best regards,

Andree

0 votes
17k views

I’m trying to dynamically create chart surfaces and renderable series, but I’m having trouble binding one of the axes to another one, like you would do with this code in XAML:

<s:CategoryDateTimeAxis VisibleRange="{Binding ElementName=priceChart,
                                                                    Path=XAxis.VisibleRange,
                                                                    Mode=TwoWay}" />

I need to accomplish the same thing directly in C# but there are no methods related to binding at all. From the MSDN reference pages I’ve seen that any element that extends FrameworkElement has the Binding property, but it seems the axes don’t extend from that.

Could someone help me out in binding this axis to another axis (for the record, the other one is defined in XAML)?

1 vote
17k views

In my project the output panel showing the following binding errors

System.Windows.Data Error: 40 : BindingExpression path error: 'Exponent' property not found on 'object' ''DefaultTickLabelViewModel' (HashCode=56110932)'. BindingExpression:Path=Exponent; DataItem='DefaultTickLabelViewModel' (HashCode=56110932); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
System.Windows.Data Error: 40 : BindingExpression path error: 'HasExponent' property not found on 'object' ''DefaultTickLabelViewModel' (HashCode=56110932)'. BindingExpression:Path=HasExponent; DataItem='DefaultTickLabelViewModel' (HashCode=56110932); target element is 'TextBlock' (Name='exponent'); target property is 'Visibility' (type 'Visibility')
System.Windows.Data Error: 40 : BindingExpression path error: 'Separator' property not found on 'object' ''DefaultTickLabelViewModel' (HashCode=9331561)'. BindingExpression:Path=Separator; DataItem='DefaultTickLabelViewModel' (HashCode=9331561); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')

my Line chart view code is here (I can’t able to make attachment)

<UserControl x:Class="Instron.Database.Presentation.DatabaseViews.Views.Visualization.LineChartView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:SciChart="clr-namespace:Abt.Controls.SciChart;assembly=Abt.Controls.SciChart.Wpf.3.0"
             xmlns:s="http://schemas.abtsoftware.co.uk/scichart" 
             mc:Ignorable="d" Width="Auto" Height="Auto"   
             xmlns:gbl="clr-namespace:Instron.Database.Presentation.DatabaseViews.Globalization">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="ContentControlDataTemplate.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid >

        <TextBlock  FontSize="24" 
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    TextWrapping="Wrap"   
                    Foreground="DimGray"
                    Visibility="{Binding IsAxisVisible,Converter={StaticResource  NotBooleanToVisibilityConverter}}" >
                    <TextBlock.Text>
                        <gbl:TranslateExtension>
                            <gbl:TranslateExtension.DesignTimeText>Either X or Y axis do not contain sufficient data</gbl:TranslateExtension.DesignTimeText>
                            <gbl:TranslateExtension.StringId>010000123</gbl:TranslateExtension.StringId>
                        </gbl:TranslateExtension>
                    </TextBlock.Text>
        </TextBlock>

        <s:SciChartSurface x:Name="sciChart" ChartTitle="{Binding ChartName}" Style="{StaticResource SciChartSurfaceStyle}"   Visibility="{Binding IsLegendVisible,Converter={StaticResource  BoolToVisibilityConverter}}" 
            GridLinesPanelStyle="{StaticResource GridLinesPanelStyle }"  RenderableSeries="{Binding RenderableSeries}"  Margin="0,-5,0,-10"
               DataContextChanged="sciChart_DataContextChanged" Rendered="sciChart_Rendered"  ViewportManager="{Binding ViewportManager}">

            <s:SciChartSurface.ContextMenu>
                <ContextMenu >
                    <MenuItem  Command="{Binding SaveAsCommand}">
                        <MenuItem.Header>
                            <gbl:TranslateExtension>
                                <gbl:TranslateExtension.DesignTimeText>SaveAs</gbl:TranslateExtension.DesignTimeText>
                                <gbl:TranslateExtension.StringId>010000126</gbl:TranslateExtension.StringId>
                            </gbl:TranslateExtension>
                        </MenuItem.Header>
                    </MenuItem>
                    <MenuItem  Command="{Binding CopyCommand}">
                        <MenuItem.Header>
                            <gbl:TranslateExtension>
                                <gbl:TranslateExtension.DesignTimeText>Copy</gbl:TranslateExtension.DesignTimeText>
                                <gbl:TranslateExtension.StringId>010000127</gbl:TranslateExtension.StringId>
                            </gbl:TranslateExtension>
                        </MenuItem.Header>
                    </MenuItem>
                    <MenuItem  Command="{Binding PrintCommand}">
                        <MenuItem.Header>
                            <gbl:TranslateExtension>
                                <gbl:TranslateExtension.DesignTimeText>Print</gbl:TranslateExtension.DesignTimeText>
                                <gbl:TranslateExtension.StringId>010000128</gbl:TranslateExtension.StringId>
                            </gbl:TranslateExtension>
                        </MenuItem.Header>
                    </MenuItem>
                </ContextMenu>
            </s:SciChartSurface.ContextMenu>

            <s:SciChartSurface.XAxis>
                <s:NumericAxis  AutoTicks="False" GrowBy="0.05, 0.05"  
                                DrawMajorGridLines="{Binding IsLegendVisible}"  DrawMinorGridLines ="False"
                                AxisTitle="{Binding XAxisName}"  TitleStyle="{StaticResource AxisTitleStyle}" TickLabelStyle="{StaticResource AxisLabelStyle}" 
                                LabelProvider="{Binding XLabelFormatter}"
                                MajorDelta="1" MinorDelta="0.2"
                                 />
            </s:SciChartSurface.XAxis>

            <s:SciChartSurface.YAxis>
                <s:NumericAxis  GrowBy="1, 1" TickLabelStyle="{StaticResource AxisLabelStyle}" DrawMajorGridLines="{Binding IsLegendVisible}"
                                AxisAlignment="Left"  DrawMinorGridLines ="False"
                                AxisTitle="{Binding YAxisTitle}" 
                                TitleStyle="{StaticResource AxisTitleStyle}" />
            </s:SciChartSurface.YAxis>

            <!--  Adding the ZoomPanModifier gives SciChart the ability to pan on mouse-drag  -->
            <s:SciChartSurface.ChartModifier>
                <s:ModifierGroup>
                    <s:XAxisDragModifier ClipModeX="ClipAtExtents"/>
                    <s:YAxisDragModifier ClipToBounds="True" />
                    <s:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True" IsXAxisOnly="False" ZoomExtentsY="False" IsAnimated="True"/>
                    <s:ZoomExtentsModifier x:Name="zoomExtentsModifier" ClipToBounds="True" ExecuteOn="MouseDoubleClick"/>
                    <s:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllVisibleSeries" />
                </s:ModifierGroup>
            </s:SciChartSurface.ChartModifier>

        <s:SciChartSurface.Annotations>
                <s:CustomAnnotation>
                    <s:CustomAnnotation.ContentTemplate>
                        <DataTemplate>
                            <s:SciChartLegend  x:Name="legendControl" Margin="2,2" Orientation="Horizontal"  Background="Transparent" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                Visibility="{Binding IsLegendVisible,Converter={StaticResource  BoolToVisibilityConverter}}" 
                                LegendData="{Binding LegendData, ElementName=legendModifier,Mode=OneWay}" >

                                <s:SciChartLegend.Resources>
                                    <SciChart:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
                                </s:SciChartLegend.Resources>
                                <s:SciChartLegend.ItemTemplate>
                                    <DataTemplate DataType="SciChart:XyzSeriesInfo">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                           <Rectangle Grid.Column="0"
                                                VerticalAlignment="Center"
                                                Stretch="Fill"
                                                Width="10"

                                                StrokeThickness="10"
                                                Stroke="{Binding SeriesColor,
                                                Converter={StaticResource ColorToBrushConverter}}" />
                                            <TextBlock Grid.Column="1" Foreground="Black" 
                                                Margin="2,0,15,0"
                                                HorizontalAlignment="Center"
                                                Text="{Binding SeriesName}" FontWeight="Normal"/>
                                            </Grid>
                                    </DataTemplate>
                                </s:SciChartLegend.ItemTemplate>
                            </s:SciChartLegend>
                        </DataTemplate>
                    </s:CustomAnnotation.ContentTemplate>
                </s:CustomAnnotation>
            </s:SciChartSurface.Annotations>
        </s:SciChartSurface>
    </Grid>
</UserControl>
  • Raghupathy asked 9 years ago
  • last active 9 years ago
1 vote
0 answers
16k views

I’m trying to MouseEventGroup:

        <s:ModifierGroup s:MouseManager.MouseEventGroup="{Binding SharedMouseGroupId}">

Where SharedMouseGroupId is

    private String sharedMouseGroupId;
    public String SharedMouseGroupId
    {
        get { return this.sharedMouseGroupId; }
        set
        {
            this.sharedMouseGroupId = value;
            RaisePropertyChanged(() => SharedMouseGroupId);
        }
    }

And init:

        SharedMouseGroupId = Guid.NewGuid().ToString();

But this doesn’t work.
If i subscribe on Loaded event of surface and manually set MouseEventGroup, this work.

        MouseManager.SetMouseEventGroup((DependencyObject)c.ChartModifier, ViewModel.Parent.SharedMouseGroupId);
1 vote
17k views

Hi,

I have a scichart surface defined in xaml like this,

<local:SciChartSurface x:Name="_ChartSurface"  Annotations="{Binding ChartAnnotations}">

        </local:SciChartSurface>

In the code behind I have ChartAnnotations defined as,

 public const string ChartAnnotationsPropertyName = "ChartAnnotations";
        private AnnotationCollection _ChartAnnotations = new AnnotationCollection();
        public AnnotationCollection ChartAnnotations
        {
            get { return _ChartAnnotations; }
            set
            {
                if (_ChartAnnotations == value)
                    return;

                _ChartAnnotations = value;
                RaisePropertyChanged(ChartAnnotationsPropertyName);
            }
        }

 public ViewModelExample()
{  
  ChartAnnotations.CollectionChanged += ChartAnnotations_CollectionChanged;    
}

 void ChartAnnotations_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            RaisePropertyChanged(ChartAnnotationsPropertyName);          
        }

Than in the code behind, I just initialize and add some annotations to the ChartAnnotations collection to populate my chart. The problem is that my Annotations property on the scichart surface is still null, and the RaisePropertyChanged() is not affecting the Bindings at all. I’m certain that the DataContext is set right as other stuff in the graph works fine. I works when I explicitly set the surface’s Annotations property with my ChartAnnotations collection, but obviously this is less than ideal.

Is there an additional step that I’m missing here?

Thanks

  • kewur asked 10 years ago
  • last active 10 years ago
0 votes
14k views

Hi,

I have some charts binded to a viewmodel. I wanted to produce a bar chart, so I want to modify the AxisAlignment.

If I specify a hardcoded alignment in the XAML, it works fine.

If I bind the alignment to the viewModel, the chart does not render, and I get the following error in the output:

 SciChartSurface didn't render, because an exception was thrown:
      Message: The specified Visual and this Visual do not share a common ancestor, so there is no valid transformation between the two Visuals.

Stack Trace:    at System.Windows.Media.Visual.TransformToVisual(Visual visual)
   at A.cac257c85637821690b32a44bda9b120f.cd0eaed29fc1e87dfe7aa912a7f678b57(FrameworkElement c5aaca7e2018a1512249ec2e2170b4cc6, UIElement c708323fb6eac118d4fd2c5913dc2a6ed)
   at A.cac257c85637821690b32a44bda9b120f.cd0eaed29fc1e87dfe7aa912a7f678b57(FrameworkElement c5aaca7e2018a1512249ec2e2170b4cc6, IHitTestable cc9d5fbe91f2861ee865bbb5439d3b84d)
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.GetAxisOffset()
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.GetAxisParams()
   at Abt.Controls.SciChart.Visuals.Axes.AxisBase.OnBeginRenderPass()
   at A.cda144392e546b245ef5bb1ee71f22b3a.c64a51c8ba6b7cbda8b9d9380d6337036(ISciChartSurface c17037e8328cd0abc02d2a6957dfa450c, RenderPassInfo c16b8d70d2b6ecad8f9fca7ac3f5177b8)
   at A.cda144392e546b245ef5bb1ee71f22b3a.c1a2306a5cc0452a04d135e77f0de4ff1(ISciChartSurface c17037e8328cd0abc02d2a6957dfa450c, Size cacf0a4a95d1143f0c11e20d4508e7132)
   at A.cda144392e546b245ef5bb1ee71f22b3a.RenderLoop(IRenderContext2D renderContext)
   at Abt.Controls.SciChart.Visuals.SciChartSurface.ca065c0b671221e0e603d0e9bf2792494()

This is the axis XAML:

 <s:SciChartSurface.XAxis>
                                    <s:NumericAxis AxisAlignment="{Binding XAxisAlignment}" LabelProvider="{Binding LabelProvider}" AutoTicks="False" MajorDelta="1" MinorDelta="1" DrawMinorGridLines="False">
                                    </s:NumericAxis>
                                </s:SciChartSurface.XAxis>

                                <s:SciChartSurface.YAxis>
                                    <s:NumericAxis AxisAlignment="{Binding YAxisAlignment}" AxisTitle="Number of crimes" GrowBy="0,1"/>
                                </s:SciChartSurface.YAxis>

And the properties I’m binding to:

public AxisAlignment XAxisAlignment { get; private set; }

public AxisAlignment YAxisAlignment { get; private set; }

Any help is appreciated.

Thanks,
Charbel

  • cabdo asked 10 years ago
  • last active 10 years ago
Showing 17 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies