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

1
0

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 .

Version
1.0
  • You must to post comments
0
0

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][2] 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 https://www.scichart.com/android-mountain-chart-example for full imports
 
import java.util.Collections;
import java.util.Date;
 
public class MountainChartFragment extends ExampleBaseFragment {
    @Bind(R.id.chart)
    SciChartSurface surface;
 
    @Override
    protected int getLayoutId() {
        return R.layout.example_single_chart_fragment;
    }
 
    @Override
    protected void initExample() {
        UpdateSuspender.using(surface, new Runnable() {
            @Override
            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))
                        .build();
 
                // Declares the DateAxis
                final IAxis yRightAxis = sciChartBuilder.newNumericAxis()
                        .withGrowBy(new DoubleRange(0.1d, 0.1d))
                        .build();
 
                final IRenderableSeries rs1 = sciChartBuilder.newMountainSeries()
                        .withDataSeries(dataSeries)
                        .withXAxisId(xBottomAxis.getAxisId())
                        .withYAxisId(yRightAxis.getAxisId())
                        .withStrokeStyle(0xAAFFC9A8)
                        .withAreaFillLinearGradientColors(0xAAFF8D42,0x88090E11)
                        .build();
 
                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,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.