We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.

# Ticklines at 7 days interval and fixed at the beginning of each week in DateTimeAxis

Hi,

Thanks for great charting library.

I'd like to fix the DateTimeAxis intervals to always begin on Monday, so that ticklines would illustrate the beginning of the week in my 60 days chart. Is that possible?

DateTimeAxis(
intervalType: DateTimeIntervalType.days,
interval: 7,
maximum: last,
minimum: 60,
);

3 Replies

DD Dharanidharan Dharmasivam Syncfusion Team December 16, 2019 05:38 AM UTC

Hi Pasi,

Thanks for trying out our Flutter widgets and your feedback. Your requirement can be achieved by specifying the minimum range to the x-axis. We have prepared a sample in which we have found the first occurrence of Monday from the data source and specified that date to the minimum range for x-axis. Also, we have specified the interval as 7, so that the chart always shows the beginning of the week. You can change this based on your scenario, find the code snippet below to achieve this.

 @override    void initState() {      for (int i = 1; i < 29; i++) {        chartData.add(_ChartData(            DateTime(2019, 12, i), (min + random.nextInt(max - min)).toDouble()));        // Found the first day of the week        if (xMinimum == null &&            DateFormat('EEEE').format(DateTime(2019, 12, i)) == 'Monday')          xMinimum = DateTime(2019, 12, i);      }          }    SfCartesianChart(              primaryXAxis: DateTimeAxis(                // Set the range here                  minimum: xMinimum,                  interval: 7,                  intervalType: DateTimeIntervalType.days),              // Other configurations           ),

The sample can be found from the below link.

Thanks,
Dharani.

PA Pasi December 16, 2019 01:39 PM UTC

Great, thanks for your fast response and idea.
I'll look into it and check if it behaves correctly also when zooming and when the data range is wide e.g. > 365 days or so.

DD Dharanidharan Dharmasivam Syncfusion Team December 17, 2019 04:33 AM UTC

Hi Pasi,

Thanks for the revert. We will wait to hear from you.

Thanks,
Dharani.