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


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,

  • Abhishek Sadana
    Actually here we are adding static data in this , but i need to show only current time like as “hh:mm” on x-axis , or is there any way we can add string values on the x-axis as i can parse the current time in string format after that i’ll append in series.
  • Andrew
    I would think you can simply set the DateAxis.TextFormatting to allow the string to be formatted as hh:mm. Try calling dateAxis.setTextFormatting(“hh:mm”) with a Java date format string . For advanced string formatting there is a feature called LabelProvider which will allow strings on an axis. AxisBase.setLabelProvider(new CustomLabelProvider()) where CustomLabelProvider inherits LabelProviderBase
  • Sanjay John
    Scroll and update time on X axis and value on Y axis
  • Sanjay John
    Xaxis shows 5:30 constant no changes
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.