javascript - Grouping Data with Flot Charts -
scenario: i'm plotting volume bar chart using flot js, per-minute data. example, 3 hours, have 3 x 60 data points being pulled database.
problem: since there have 6 hours worth of data points, , width of chart 250px, bars 1px wide each, without margins. wondering if there's grouping data option in flot charts tell average volume data per 15 minutes or 30 minutes.
$.plot('#flot-vol, [{ color: '#fff', bars: { show: true }, data: datav }], { grid: { show: false }, shadowsize: false });
in high charts there groupdata option wherein can group given data day / week / months. wondering if there's such feature in flot charts?
if need use mysql group data, how group data per 30 minutes if have following mysql statement? i'm pulling volume of latest date table named ticker.
select unix_timestamp(`timestamp`), `volume` `ticker` compid = 'symbol' , date(`timestamp`) = (select max(date(`timestamp`)) `ticker`)
update:
thanks ryley clarifying answer, in case wondering how group data through mysql, here is. mysql statement worked
select unix_timestamp(`timestamp`), avg(`volume`) `ticker` `compid` = 'symbol' , date(`timestamp`) = (select max(date(`timestamp`)) `ticker`) group (unix_timestamp(`timestamp`) div 30*60)
flot not aggregate data itself, you're on right track thinking doing mysql.
make query average data 30 minute segments:
select trunc(unix_timestamp(`timestamp`)/(30*60))*(30*60) time_chunk, avg(`volume`) `ticker` compid = 'symbol' , date(`timestamp`) = (select max(date(`timestamp`)) `ticker`) group time_chunk
i'm not mysql user, may not right, idea take timestamp , truncate 30 minute increments, average volume on 30 minutes.
Comments
Post a Comment