I’m trying to create a histogram in flot, where the bars are organized by day.
I cannot find a way to merge values into 1 bar per day.
__
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There might be things to your question that are flot-specific, in which case I might have missed out on them. But if you’ve just got a javascript data structure with dates, and want to aggregate them into full days, you could do something like this.
Assume the following data source:
You can then write a function like this one to parse your data structure into a new format:
It’ll give you the following result:
What it does is to create a hash with what is represented in the output as
dateStringfor a key, and it iterates over the source collection to populate this hash with arrays for each hash key. After that, it iterates all the keys in the hash, and creates an array of objects containing the result of the hashed group.