SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
SciChart Android ships with ~90 Android Chart Examples which you can browse, play with, view the source-code and even export each SciChart Android Chart Example to a stand-alone Android Studio project. All of this is possible with the new and improved SciChart Android Examples Suite, which ships as part of our Android Charts SDK.
The Realtime Ticking Stock Charts example showcases real-time ticking stock charts. In the source-code you will see that we use the OhlcDataSeries.append() and OhlcDataSeries.update() methods to add new data to the chart when a timer ticks. Also, the VisibleRange on the X Axis is updated manually via the IRange.setMinMaxDouble() method. The VisibleRange on the Y Axis is adjusted automatically as new data comes due to Autoranging.
Example Usage
– Press the START button to start the real-time update or the PAUSE button to stop it.
– You can freely Pan the chart in horizontal direction even when it’s being updated.
– The X Axis can be dragged to scale the chart in horizontal direction.
– Double-tapping restores zoom level to the extents of the data.
– The Legend can be used to hide or show chart series.
The full source code for the Android Realtime Ticking Stock Charts example is included below (Scroll down!).
Did you know you can also view the source code from one of the following sources as well?
<?xml version="1.0" encoding="utf-8"?><!--*************************************************************************--><!-- SCICHART® Copyright SciChart Ltd. 2011-2017. All rights reserved. --><!-- --><!-- Web: http://www.scichart.com --><!-- Support: support@scichart.com --><!-- Sales: sales@scichart.com --><!-- --><!-- example_real_time_ticking_stock_chart_fragment.xml is part of the SCICHART® Examples. Permission is hereby granted --><!-- to modify, create derivative works, distribute and publish any part of this source --><!-- code whether for commercial, private or personal use. --><!-- --><!-- The SCICHART® examples are distributed in the hope that they will be useful, but --><!-- without any warranty. It is provided "AS IS" without warranty of any kind, either --><!-- expressed or implied. --><!--*************************************************************************-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.scichart.charting.visuals.SciChartSurface
android:id="@+id/chart"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.scichart.charting.visuals.SciChartSurface
android:id="@+id/overview"
android:layout_width="fill_parent"
android:layout_height="75dp" />
</LinearLayout>
<!--*************************************************************************-->
<!-- SCICHART® Copyright SciChart Ltd. 2011-2017. All rights reserved. -->
<!-- -->
<!-- Web: http://www.scichart.com -->
<!-- Support: support@scichart.com -->
<!-- Sales: sales@scichart.com -->
<!-- -->
<!-- Realtime_Ticking_Stock_Charts.xml is part of the SCICHART® Examples. Permission is hereby granted -->
<!-- to modify, create derivative works, distribute and publish any part of this source -->
<!-- code whether for commercial, private or personal use. -->
<!-- -->
<!-- The SCICHART® examples are distributed in the hope that they will be useful, but -->
<!-- without any warranty. It is provided "AS IS" without warranty of any kind, either -->
<!-- expressed or implied. -->
<!--*************************************************************************-->
<ExampleDefinition>
<Title>Realtime Ticking Stock Charts</Title>
<IconPath>ic_candles_feature</IconPath>
<Description>
Creates a real-time example with two series.
</Description>
<CodeFiles>
<string>res/layout/example_real_time_ticking_stock_chart_fragment.xml.txt</string>
<string>java/com/scichart/examples/fragments/CreateRealTimeTickingStockChartFragment.java.txt</string>
</CodeFiles>
<Features>
<Features>Candlesticks</Features>
</Features>
<IsVisible>true</IsVisible>
</ExampleDefinition>