I'm currently working on an Angular project where I have to display some data in a graph. I'm using echarts for that through it's NGXecharts implementation.
My data comes from a backend app which scans a file system every 5 minutes and counts how many new files where added. So I have a scan status saved in db every 5 minutes with
scan date : epoch timestamp, number of new files : number
We can easily imagine that after a year this makes a lot of records and data to be displayed. The graph gets very loaded with all these small samples.
My echart is a simple graph with xAxis type='time' an actual values on y.
What I want to do, but can't figure out how, is to catch the time window (start: date, end: date) whenever a user zooms (In/Out). With this and properly configured thresholds, I would be able to call my backend API to get more or less granularity in my dataset.
For Instance if the graph is very zoomed out showing several years, I would query my api asking for monthly aggregated data. If the window displays a full month, I would query daily aggregated data , etc.
I know that echarts has a dataZoom event that works but gives data values (the values of the y axis) and not the time values (min/max) of the x-axis.
{
type: 'datazoom',
// percentage of zoom start position, 0 - 100
start: number
// percentage of zoom finish position, 0 - 100
end: number
// data value of zoom start position; only exists in zoom event of triggered by toolbar
startValue?: number
// data value of zoom finish position; only exists in zoom event of triggered by toolbar
endValue?: number
}
Is there any way to get the time window on a zoom event? I know that some other librairies like Vis.js/Graph2D does this very well but it's lacking some other important features from echarts that I need.
Thanks a lot for you help.