Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

How to use "DateTimeAxisSpec" and "DateTimeExtents" in "TimeSeriesChart"? #68

Closed
dokinkon opened this issue Jun 13, 2018 · 5 comments
Closed

Comments

@dokinkon
Copy link

I have time series dataset which across 3 months. What I want to do is showing one day data at beginning and user can drag/pan this chart to view another time segment.
But I can't find any example to to this. After digging the source code, I found "DateTimeAxisSpec" and "DateTimeExtents" classes which looks helpfully. Does these classes is ready to use? Could you please provide a simple explanation of how to use?
Thanks

@lorrainekan
Copy link
Contributor

What you might want to do is

@sintylapse
Copy link

@lorrainekan DateTimeAxisSpec and DateTimeExtents just do not work as per #213 and #134

@sintylapse
Copy link

@dokinkon did you manage to get DateTimeAxisSpec and DateTimeExtents working? if not, please reopen the issue

@26shruti
Copy link

Not working

@bjornwilliam
Copy link

Posting a reply from a similar issue (#287) :
(add the viewport argument to his proposed workaround class). This workaround makes the datetime
viewport work as expected.

This is because of the autoViewport setting in the Axis class (charts_common/lib/src/chart/cartesian/axis/axis.dart). You have to set axis.autoViewport = false in the DateTimeAxisSpec.configure method. This also allows the PanAndZoomBehavior to operate correctly.

You're right. So, to fix that, the workaround is to create a class which extends DateTimeAxisSpec of charts_flutter and override the configure method like that :

class DateTimeAxisSpecWorkaround extends DateTimeAxisSpec {

  const DateTimeAxisSpecWorkaround ({
    RenderSpec<DateTime> renderSpec,
    DateTimeTickProviderSpec tickProviderSpec,
    DateTimeTickFormatterSpec tickFormatterSpec,
    bool showAxisLine,
  }) : super(
            renderSpec: renderSpec,
            tickProviderSpec: tickProviderSpec,
            tickFormatterSpec: tickFormatterSpec,
            showAxisLine: showAxisLine);

  @override
  configure(Axis<DateTime> axis, ChartContext context,
      GraphicsFactory graphicsFactory) {
    super.configure(axis, context, graphicsFactory);
    axis.autoViewport = false;
  }
}

Thank you so much. You saved my day !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants