2

I have my graph working well and it plots the 11 points I need on it just as it should. However, I'm interested in specifically the first 3 points as soon as the plot appears. I was wondering if there's a way to have the chart zoom in automatically to the first 3 points plotted rather than having a full scale view of the chart when the process is complete. Here's the xaml:

<SciChart:SciChartSurface x:Name="sciChart" 
                                              Grid.Row="6"
                                              SciChart:RenderSurfaceBase.RenderSurfaceType="Abt.Controls.SciChart.Rendering.HighQualityRasterizer.HighQualityRenderSurface" 
                                              SciChart:ThemeManager.Theme="BlackSteel" 
                                              Margin="-23,-2,-8,-18" Grid.ColumnSpan="6" Loaded="sciChart_Loaded">

                <!--  Declare RenderableSeries  -->
                <SciChart:SciChartSurface.RenderableSeries>
                    <SciChart:FastLineRenderableSeries SeriesColor="LightBlue" StrokeThickness="2">
                        <SciChart:FastLineRenderableSeries.PointMarker>
                            <SciChart:EllipsePointMarker Width="9" Height="9" Stroke="LightBlue" Fill="#990077FF" StrokeThickness="2"/>
                        </SciChart:FastLineRenderableSeries.PointMarker>
                    </SciChart:FastLineRenderableSeries>
                </SciChart:SciChartSurface.RenderableSeries>

                <!--  Declare Axes  -->
                <SciChart:SciChartSurface.XAxis>
                    <SciChart:TimeSpanAxis AxisTitle="Time" GrowBy="0.1, 0.1" DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="True" DrawMinorTicks="True" />
                </SciChart:SciChartSurface.XAxis>

                <SciChart:SciChartSurface.YAxis>
                    <SciChart:NumericAxis  AxisAlignment="Left" AxisTitle=" % in Profit" GrowBy="0.1, 0.1" DrawMajorGridLines="True" DrawMinorGridLines="True" DrawMajorTicks="True" DrawMinorTicks="True"/>
                </SciChart:SciChartSurface.YAxis>

Is it possible to do this with Scichart's charts?

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178
kknaguib
  • 749
  • 4
  • 12
  • 33

1 Answers1

3

Yes there is, you can manipulate the XAxis.VisibleRange directly on the SciChartSurface. To do this, simply use some code like this

// Create your Data Series
var xyDataSeries = new XyDataSeries<TimeSpan, double>();

// Append some values
xyDataSeries.Append(TimeSpan.FromSeconds(0), 0);
xyDataSeries.Append(TimeSpan.FromSeconds(1), 1);
xyDataSeries.Append(TimeSpan.FromSeconds(2), 2);
// ... 
xyDataSeries.Append(TimeSpan.FromSeconds(11), 11); 

// Set the XyDataSeries on the RenderableSeries
// Assumes chart is created as per your XAML above
sciChart.RenderableSeries[0].DataSeries = xyDataSeries;   

// Zoom XAxis to fit first three points
var xRange = new TimeSpanRange(xyDataSeries.XValues[0], xyDataSeries.XValues[2]);
sciChart.XAxis.VisibleRange = xRange;

// Zoom to fit in Y direction
sciChart.ZoomExtentsY(); 

Hope this helps!

Disclosure: I am the MD and owner of SciChart WPF Charts

Dr. Andrew Burnett-Thompson
  • 20,980
  • 8
  • 88
  • 178