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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

149910 Dec 13,2019 01:31 PM UTC Dec 17,2019 04:33 AM UTC Flutter 3
loading
Tags: SfCartesianChart
Pasi
Asked On December 13, 2019 01:31 PM UTC

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,
);

Dharanidharan Dharmasivam [Syncfusion]
Replied On 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(201912, i), (min + random.nextInt(max - min)).toDouble())); 
      // Found the first day of the week 
      if (xMinimum == null && 
          DateFormat('EEEE').format(DateTime(201912, i)) == 'Monday') 
        xMinimum = DateTime(201912, 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. 


Pasi
Replied On 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.


Dharanidharan Dharmasivam [Syncfusion]
Replied On December 17, 2019 04:33 AM UTC

Hi Pasi, 

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

Thanks, 
Dharani. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon