Change granularity of a Trend dinamically


#1

Hi, I’m building an app in react and I’m including the toolkit library for data visualization, I’m using a trend chart to show the distribution of records over time and I’m just trying the dragFilter feature to select a time window and use it as a filter, but when the time window is small the chart doesn’t look good, how can I change the granularity of the trend group so that the selected time window looks better?


#2

Got it, but, do you want to calculate the granularity automatically according to the selected date ranges? or maybe do you want to specify the granularity yourself?.


#3

Actually, i want to use my custom configuration, to specify when to use MONTH, YEAR or other granularity.


#4

Got it, well, you can check the drillIn break points to define your own breakpoints, like this:

// Define the path for the group by
let drill = {
    'trendElementId': {
        'group1': {
            "YEAR": 3, // the time window should have at least 3 years
            "MONTH": 3, // the time window should have at least 3 months
            "DAY": 3, // the time window should have at least 3 days
            "HOUR": 5, // the time window should have at least 5 hours
            "MINUTE": 5, // the time window should have at least 5 minutes
        }
   }
}
cf.create().imanager().set('drill',drill).element('chart').execute()

#5

It was too easy, thanks, it works good