SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Answered
1
0

I cannot figure out how to setup SciChartSurface so that it would be initialized right away and IsSizeValidForDrawing returned true.

Now I have the special case for the first call to the view with SciChartSurface and I start working with it after receiving SizeChanged event. In this event handler and afterwards IsSizeValidForDrawing gets true and later on all my requests to the view are OK. It’s quite inconvenient.

When does SciChartSurface get resized? What makes it resize?
Which moment does IsSizeValidForDrawing get true?
What should I do to make the size valid after instantiating or receiving first bunch of data ?
How can I make it progmammatically?

This is my xaml:

        <s:SciChartSurface.RenderableSeries>
            <s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False" />
            <s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False"  />
            <s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False" />
            <s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False" />
            <s:FastLineRenderableSeries XAxisId="XAxis1" YAxisId="YAxis1" AntiAliasing="False"/>
            <s:FastLineRenderableSeries XAxisId="XAxis2" YAxisId="YAxis2" AntiAliasing="False"/>
        </s:SciChartSurface.RenderableSeries>

        <s:SciChartSurface.XAxes>
            <s:NumericAxis Id="XAxis1" />
            <s:NumericAxis Id="XAxis2" />
        </s:SciChartSurface.XAxes>

        <s:SciChartSurface.YAxes>
            <s:NumericAxis Id="YAxis1"  />
            <s:NumericAxis Id="YAxis2" />
        </s:SciChartSurface.YAxes>
    </s:SciChartSurface>

    <Grid Grid.Row="1" x:Name="myOverviews">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <s:SciChartOverview  Grid.Row="0" 
                    XAxisId="XAxis1"
                    ParentSurface="{Binding ElementName=mySurface}"
                    DataSeries="{Binding ElementName=mySurface, Path=RenderableSeries[4].DataSeries}"
                    SelectedRange="{Binding ElementName=mySurface, Path=XAxes[0].VisibleRange, Mode=TwoWay}"
                    Visibility ="Collapsed"
                    s:ThemeManager.Theme="BlackSteel">
        </s:SciChartOverview>

        <s:SciChartOverview Grid.Row="1" 
                    XAxisId="XAxis2"
                    ParentSurface="{Binding ElementName=mySurface}"
                    DataSeries="{Binding ElementName=mySurface, Path=RenderableSeries[4].DataSeries}"
                    SelectedRange="{Binding ElementName=mySurface, Path=XAxes[1].VisibleRange, Mode=TwoWay}"
                    Visibility ="Collapsed"
                    s:ThemeManager.Theme="BlackSteel">
        </s:SciChartOverview>
    </Grid>

All visibilities besides SciChartSurface are “Collapsed”

SciChart version 3.1.0.5077

Thank you

  • You must to post comments
Good Answer
1
0

Andrew’s comment helped to understand and solve this problem, which was in instantiating my UserControl dynamically in code behind, without knowing its size. I put the control into XAML, allowing WPF to calculate and set size and problem with RenderSurface, which was unable to draw was gone.

  • You must to post comments
0
0

RenderSurfaceBase.IsSizeValidForDrawing returns true if ActualWidth and ActualHeight are greater than 0, and are not NaN.

Why do you need this? This flag is used internally inside SciChart to prevent drawing to a bitmap of size 0,0.

  • You must to post comments
0
0

Without RenderSurfaceBase.IsSizeValidForDrawingset, FastLineRenderableSeries.DataSeries.Append() doesn’t do anything.

I have to take into account this behavior and run the following sequence in my program:

  1. Create view
  2. Set new data sources
  3. (skip this for the first time, dataseries cannot be added as RenderSurfaceBase.IsSizeValidForDrawing == false) Start drawing
  4. Receive size changed, RenderSurfaceBase.IsSizeValidForDrawing == true, start actual drawing
  5. Set new data sources
  6. Start drawing
  7. Set new data sources
  8. Start drawing

This workflow is very cumbersome. How can I avoid step 4 and modify step 3?

  • Andrew
    I'm sorry, I have no idea what you're trying to achieve. IsSizeValidForDrawing simply stops scichart from rendering if the size is 0,0. This only occurs if the SciChartSurface has not yet loaded (e.g. it has not yet been displayed in the visual tree). This is normal operation and should not affect DataSeries.Append() in any way. Perhaps you could try to explain the problem a bit more clearly, what you are doing and why, and share a code sample of where you are stuck. We will be happy to help.
  • You must to post comments
0
0

I’m trying to achieve SciChartSurface being renderable after instantiating. In my app, I host SciChartSurface in UserControl, which is the part of another UserControl, which is the part of a docking window.

When being instantiating SciChartSurface doesn’t know its own size. Sizes set somewhere down the lifetime of the app and it;s unknown when this size change exactly happens before first render happens. What can I do about this?

  • Andrew
    This is a WPF limitation, nothing to do with SciChart. UserControls do not know their own size until a.) you set the size, or b.) the UserControl has been displayed on the screen. Please see http://stackoverflow.com/a/1695518/303612 for details
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.