I'm designing a JavaScript chart that I want to be awesome and I need your help.
Let's say I have 5 million records with price data like this:
open high low close volume timeStart timeEnd timeDuration
10 20 5 15 500 1391895920860 1391895920920 60
So, I have 5 million records describing the price of something at the one minute resolution.
Now, I need to show a chart to the user representing all 5 million of these records. By default the chart is going to show 2 years of data at the one week interval. Two years of data at a one week interval is just 104 records. So, in order to generate my 104 weekly records I need to process all 5 million of my minute resolution records and group them into weeks.
Let's say the user zooms in and wants to see data grouped for every three days instead of the one week interval. I'm going to need to generate three day records which group the data from my one minute resolution data.
In fact, for each interval that I am going to allow the user to zoom into I need to summarize my minute resolution data ahead of time. To save load on the database, I am going to generate CSV "tiles" that the client can quickly pull down. Each tile will have 1,000 records in it.
Here are the resolutions ("zoom levels") I will support and the number of tiles I will need to generate ahead of time for two years of price data at the one minute resolution:
1 minute - 1440 tiles (estimated to be about 40 MB of data)
3 minute - 480 tiles
5 minute - 288 tiles
15 minute - 96 tiles
30 minute - 48 tiles
1 hour - 24 tiles
2 hours - 12 tiles
4 hours - 6 tiles
6 hours - 4 tiles
12 hours - 2 tiles
1 day - 1 tile
3 days - 1 tile
1 week - 1 tile
1 month - 1 tile
1 year - 1 tile
The idea here is that when the user first hits the chart, all I need to do is pull down the one week tile and it will have all 104 of my records. When they zoom into a section of the one week tile I will pull down the 3 day tile.
So here is where I need help. If the user zooms into the 12 hour tile from the 1 day zoom level, I need to intelligently know which of the 12 hour tiles I should grab. I think I need to have a naming scheme for my tiles that will allow the client to easily identify sub tiles for any parent tile.
Can anyone help me with a naming scheme for these tiles? I specifically need:
- A file naming scheme for all of my tiles I will generate
- An algorithm the chart will use to easily identify the correct child tile to zoom into or parent child to zoom out to
Would love to hear your thoughts and feedback!