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

1
0

I want some specific behavior out of my X and Y axes. Right now I have custom code which modifies the ranges for the axes to get the behavior I want. It would be nice to just do this by setting options on the axes.

For my Y axis I want to use the AutoRange feature but the default seems a little crowded. Instead of it ranging to the min and max of the data series I want it to show a little room on the top and bottom.

For the X axis I want to show exactly the most recent hour of data.

Thanks for any help.

  • You must to post comments
1
0

HI dlee,

You can use the AxisBase.GrowBy property to achieve this. This will add a fractional padding above/below the axis (on X or Y axis). For an example, please see here:

http://http://www.scichart.com/Abt.Controls.SciChart.SL.ExampleTestPage.html#/Abt.Controls.SciChart.Example;component/Examples/IWantTo/CreateSimpleChart/LineChartExampleView.xaml

    <!-- Create the chart surface -->
    <SciChart:SciChartSurface Name="sciChart" SciChart:ThemeManager.Theme="ExpressionDark">

        <!-- Declare RenderableSeries -->
        <SciChart:SciChartSurface.RenderableSeries>
            <SciChart:FastLineRenderableSeries SeriesColor="#FF4083B7" StrokeThickness="2"/>
        </SciChart:SciChartSurface.RenderableSeries>

        <!-- Create an X Axis with Growby -->
        <SciChart:SciChartSurface.XAxis>
            <SciChart:NumericAxis>
                <SciChart:NumericAxis.GrowBy>
                    <SciChart:DoubleRange Min="0.1" Max="0.1"/>
                </SciChart:NumericAxis.GrowBy>
            </SciChart:NumericAxis>
        </SciChart:SciChartSurface.XAxis>

        <!-- Create a Y Axis with Growby -->
        <SciChart:SciChartSurface.YAxis>
            <SciChart:NumericAxis>
                <SciChart:NumericAxis.GrowBy>
                    <SciChart:DoubleRange Min="0.1" Max="0.1"/>
                </SciChart:NumericAxis.GrowBy>
            </SciChart:NumericAxis>
        </SciChart:SciChartSurface.YAxis>

    </SciChart:SciChartSurface>

which results in this output:

Images
  • dlee
    Thanks! This certainly does everything I need it to for the Y axis. But I don't see how I can use it to show only the most recent hour of data for the X axis. I am using the chart in real time so the series are receiving constant updates. The series is configured to only hold enough data points to show an hour's worth of data. The only problem I have is when the chart has been running for less than one hour as using Autorange shows only the range I have data for. Is this possible to do without updating the X axis programatically?
  • Andrew
    Hello dlee,Are you using the DateTimeAxis or CategoryDateTimeAxis? If the DateTimeAxis, you will want to turn AutoRange off and set the XAxis.VisibleRange manually on each data-append. This is easy to do in the SciChartSurface.Rendered event. This will allow you override the VisibleRange immediately after the chart re-draws.Hope this helps!If you
  • dlee
    Thank you for your response Andrew. This is very similar to what I am doing currently. Except I am doing a RaisePropertyChanged on my RenderableSeries collection on a timer to update the X axis. I assume the rendered event is called as a byproduct of this.By your response I'm guessing that currently there is no way to set an axis range the way I want to without setting up some kind of timer and updating the axis through the program. Some kind of way to set a fixed window size would be a nice feature to have.Thanks again!
  • Shubha K
    Hello Andrew,I have a CategoryDateTimeAxis as my XAxis. There is a total of about 300 data points and setting VisibleRange of the axis between 0 and 100 using IndexRange. We are displaying the data using CandleStickSeries. We want some spacing between the last candle on the extreme right and the y axis which is set to Alignment.Right.I have tried to use Axis.GrowBy = new DoubleRange(0.1, 0.1). This does not seem to have any effect. I dont see any padding added between the last candle and the Y-Axis.Is there something different that needs to be done to achieve this?On a general note, setting MinorDelta, MajorDelta has been a challenge for CategoryDatetime axis. Please advise. Thank you!Copying the code here..Dim datetimeaxis = New CategoryDateTimeAxis() datetimeaxis.VisibleRange = New IndexRange(0, 200) datetimeaxis.DrawMajorBands = False datetimeaxis.DrawMinorGridLines = False datetimeaxis.DrawMajorGridLines = False datetimeaxis.Padding = New Thickness(2) datetimeaxis.GrowBy = New DoubleRange(0.02, 0.02)datetimeaxis.Scrollbar = scrollbar m_chart.XAxis = datetimeaxis
  • Andrew
    GrowBy is used in our examples with CategoryDateTimeAxis to create padding on the right. Please see https://www.scichart.com/wpf-chart-example-realtime-ticking-stock-charts/ which sets XAxis.GrowBy to new DoubleRange(0, 0.1)
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.