Pre loader

Time on X-axis On Android

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


Right now i’m using trial version but i’m looking forward to buy full version as to integrate the charts in my app . I am building an real time chart that update data according to time , which means simply i need Time on the x axis and numeric values on the y axis , but i’m not getting any hint how to get the time values on the x axis .

  • You must to post comments

Hi Abhishek,

Good question! SciChart’s Android Chart features a DateAxis which can be used to display date and time on the XAxis.

There is an example of use in the Android Mountain Chart example which has the following code to initialise a DateAxis and populate an XyDataSeries with Date data for X-Values.

package com.scichart.examples.fragments;
import ... // See for full imports
import java.util.Collections;
import java.util.Date;
public class MountainChartFragment extends ExampleBaseFragment {
    SciChartSurface surface;
    protected int getLayoutId() {
        return R.layout.example_single_chart_fragment;
    protected void initExample() {
        UpdateSuspender.using(surface, new Runnable() {
            public void run() {
                final PriceSeries priceData = DataManager.getInstance().getPriceData(getActivity());
                // Initialises an XyDataSeries with type TX=Date and TY=Double
                final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build();
                // Appends Date Data on X, and Double data on Y
                dataSeries.append(priceData.getDateData(), priceData.getCloseData());
                final IAxis xBottomAxis = sciChartBuilder.newDateAxis()
                        .withGrowBy(new DoubleRange(0.1d, 0.1d))
                // Declares the DateAxis
                final IAxis yRightAxis = sciChartBuilder.newNumericAxis()
                        .withGrowBy(new DoubleRange(0.1d, 0.1d))
                final IRenderableSeries rs1 = sciChartBuilder.newMountainSeries()
                Collections.addAll(surface.getXAxes(), xBottomAxis);
                Collections.addAll(surface.getYAxes(), yRightAxis);
                Collections.addAll(surface.getRenderableSeries(), rs1);
                Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build());

Please take a look and let me know if it helps!

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.