Pre loader

DirectX not working for multiple charts

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

0
0

I was curious, and had mentioned this in another thread, but verified what I thought. My first SciChart instance is drawing in DirectX and subsequent charts are not. Please see attached. Each chart is being created and placed inside a tabitem.

I used the suggested annotation to show the version being used (from the support forum) and found why my images are not as crisp in most of my charts.

s3d:DirectXHelper.TryApplyDirectXRenderer="True"
s3d:DirectXHelper.FallbackType="{x:Type s:HighQualityRenderSurface}"
Version
5.2.2.11833
Images
  • You must to post comments
0
0

Hi Chris,

I’m afraid I’m not able to reproduce this using version 5.2.1.11757 (Stable) or 5.2.2.11833 (Nightly).

Here is my code:

<Window x:Class="WpfApp12.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
        xmlns:s3D="http://schemas.abtsoftware.co.uk/scichart3D"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
            <TabControl>
                <TabControl.Items>
                    <TabItem Header="Tab1">
                    <s:SciChartSurface x:Name="scs0" s3D:DirectXHelper.TryApplyDirectXRenderer="True">
                            <s:SciChartSurface.Annotations>
                                <s:TextAnnotation DataContext="{Binding Path=ParentSurface.RenderSurface, RelativeSource={RelativeSource Self}}" Text="{Binding Path=.}" X1="2" Y1="2"/>
                        </s:SciChartSurface.Annotations>
                            <s:SciChartSurface.XAxis>
                                <s:NumericAxis/>
                            </s:SciChartSurface.XAxis>
                            <s:SciChartSurface.YAxis>
                                <s:NumericAxis/>
                            </s:SciChartSurface.YAxis>
                    </s:SciChartSurface>
                    </TabItem>
                <TabItem Header="Tab2" >
                    <s:SciChartSurface x:Name="scs1" s3D:DirectXHelper.TryApplyDirectXRenderer="True"
                                       s:ThemeManager.Theme="Chrome">
                        <s:SciChartSurface.Annotations>
                            <s:TextAnnotation DataContext="{Binding Path=ParentSurface.RenderSurface, RelativeSource={RelativeSource Self}}" Text="{Binding Path=.}" X1="2" Y1="2"/>
                        </s:SciChartSurface.Annotations>
                        <s:SciChartSurface.XAxis>
                            <s:NumericAxis/>
                        </s:SciChartSurface.XAxis>
                        <s:SciChartSurface.YAxis>
                            <s:NumericAxis/>
                        </s:SciChartSurface.YAxis>
                    </s:SciChartSurface>
                </TabItem>
            </TabControl.Items>
            </TabControl>
    </Grid>
</Window>

Result is below.

enter image description here

Can you share a sample to reproduce please?

Best regards,
Andrew

  • Chris Kirkman
    Will do. Let me put one together and I’ll get it to you in a bit.
  • Chris Kirkman
    At what point does the SciChart decide it will fallback? I’ve put together a test app that adds 5 series onto a chart (which is within a UserControl) using binding. I have a button that allows the user to add “x” number of tabs. It never fails. In my actual application (not the test app) the 2nd time I add a control that has a SciChart on it I start getting “HighQualityRenderSurface” instead of DirectX. It’s really strange because the test app mimics my real app as best as I can without attaching it here (I can’t for proprietary and other 3rd party nugets reasons). Is there some sort of threshold with memory/processor that will cause a fallback? What’s unusual is that the memory/processor usage is not really different between my test app and my real app.
  • Andrew Burnett-Thompson
    Pretty much straight away. It will try to determine if DirectX is available in hardware. If this fails it’ll drop down. The only thing I can think of is a file lock or something. I can share the code of DirectXHelper which might help
  • Chris Kirkman
    Please see my latest comment at the bottom of this thread. I’ve narrowed it down to setting the RenderPriority of the chart. When I removed that line it rendered in DirectX every time. However not having that causes me another issue.
  • You must to post comments
0
0

Andrew see attached screenshot. I have my app and the test app running at the same time. I originally started my app, opened one tab which showed a SciChart with DirectX, then I closed that tab, opened the 2nd tab and it was not displayed in DirectX mode.

Then I opened my test app and added multiple tabs, all which worked as DirectX. It’s feeling more like I’m doing something wrong, but can’t figure out what.

I’m trying to add my test project but can’t add it here.

  • You must to post comments
0
0

Andrew. Through some more thorough troubleshooting I have narrowed it down to the following…


MyChart.RenderPriority = SciChart.Charting.Visuals.RenderPriority.Immediate;


In my application I have tabs that are added dynamically (as I’ve shown in previous screenshots). On each tab there are basically two main components, a DataGrid and a Chart. These are Xceed DataGridControl and SciChart.

I have a “SelectionChanged” event on my DataGrid that is fired each time I click on a row. Inside that event I am setting which items will be bound to the chart. I’m not interacting directly with the chart. I am simply changing the contents of the list of items bound to the chart. These are an…

 ObservableCollection<IRenderableSeriesViewModel>

My goal is that when item(s) are selected in my DataGrid they should also be displayed on the chart. This actually does work. The problem is that the items aren’t usually visible without double clicking on the chart to cause it zoom out. I’m guessing that setting the chart’s extents to a large enough value to show all my series would be a potential way to overcome this problem. This isn’t really a viable option for us however.

I overcome this by dispatching the message back to the UI thread to force SciChart to zoom out, using MyChart.ZoomExtents(). Even this is technically problematic; however, I wrote a function that behaves very similar to an old VB6 “DoEvents” method to ensure enough time has passed for the zooming out to occur. See here..

                // zoom chart to full view
                Dispatcher.Invoke(() =>
                {
                    Helper.DoEvents(TimeSpan.FromMilliseconds(50));

                    //MeasurementGraph.DoseChart.RenderPriority = SciChart.Charting.Visuals.RenderPriority.Immediate;
                    MeasurementGraph.DoseChart.ZoomExtents();

                    Helper.DoEvents(TimeSpan.FromMilliseconds(50));
                });

     /// <summary>
    /// We want the application to wait a few seconds before continuing
    /// exection.  This could be in the case of waiting long enough for
    /// a UI element to be drawn in the background of a synchronise 
    /// event
    /// </summary>
    /// <remarks>
    /// Useage:  You need to an event that takes time and you want
    ///          to wait long enough for that event to complete
    ///          before moving along.
    ///          
    /// 1. Make call to that thing, I.e. set the width of something
    /// 2. Call DoEvents(TmeSpan.FromMilliseconds(1000));
    /// </remarks>
    /// <param name="wait">How long?</param>
    public static void DoEvents(TimeSpan wait)
    {
        DateTime waitTime = DateTime.Now + wait;
        while (DateTime.Now < waitTime)
        {
            DispatcherFrame frame = new DispatcherFrame();
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
                new DispatcherOperationCallback(ExitFrame), frame);
            Dispatcher.PushFrame(frame);
        }
    }

    private static object ExitFrame(object f)
    {
        ((DispatcherFrame)f).Continue = false;

        return null;
    }

Our charts will be used to show both historical and real time data at the same time. So this is another wrinkle. In that case I also need the chart to constantly update its extents as data is added to the series. I’m hoping you have a work-around to auto-zoom based on the data that is being added real-time.

  • Andrew Burnett-Thompson
    Hi Chris, working week is over in the uK but you should email me to discuss your requirements in greater detail. I’d say that RenderPriority Immediate is a bad idea generally for performance but can help some edge cases. The zoom timing problem is know but we can help in another way using AutoRange. Email me Andrew at scichart.
  • Chris Kirkman
    Andrew, I just sent you a description of our requirements and how I’m currently implementing them. Thanks, Chris
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.

Try SciChart Today

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

Start TrialCase Studies