javascript - Changing granularity of amCharts data -


i have built serial chart using amcharts. workflow is:

  • the front end allows user add trendlines one-by-one.
  • for each trendline added, data being fetched mysql database (using php script) , returned amcharts in json format.

desired feature: - user should have ability choose different granularity. mysql db has data each minute. user may choose plot hourly average values, example.

question: - possible aggregation after minute-wise data has been fetched mysql , returned in json format? maybe javascript function can aggregate json data being returned php/mysql.

the reason not wish aggregation in mysql queries make aggregation switches faster. example, if front-end javascript aggregating minute-wise mysql data, switching hourly-average daily-average not require query mysql db again, minute-wise data available.

any ideas welcome.

thanks pranav

you have save json result in variable re-build json , pass rebuild amcharts. that, aggregation js. disadvantage when user wants see average trendline, have ask detailed server...

example have 10 different trendlines, each trendline has 4 granularity: day, month, year, century.

first method if user asks 5 trendlines granuarity year, ajax call json of 5 trendlines of day granuarity , construct month, year ans century, client-side, using js.

then if user asks 6 trenlines (and 5 user has aske dbefore), have make js enough smart in order call 1 trendline , add 5 get

second method or create complex mecanism enrich trendline data preicsion demand : if user asks 5 trendlines grabuarity month, month, can construct year , century not day because not needed.

then if user asks 6 trendlines of granuarity years, have make function smart json receive contains 1 trendline of year granuarity , build century trendline because other trendlines available in js.


Comments