# Date intervals for graphs

**URL:** <https://www.ruby-forum.com/t/date-intervals-for-graphs/141229>\
**Category:** Ruby\
**Created:** [June 23, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/date-intervals-for-graphs/141229 "2008-06-23T21:27:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [June 23, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/date-intervals-for-graphs/141229/1 "2008-06-23T21:27:27Z")

</div>

Hi,

I’m in a position where I have to create dynamic date based Line graphs.  
By dynamic I mean the start and end dates are variable and the output  
should depend on the time period.

For example if the date interval is 7 days I would have to display 7  
points of data. If the date interval is 100 days I would have to display  
it by months since 100 points of data would be too much. It has to be  
grouped somehow.

Is there a library that does this automatically?

If not, what would be the best solution for such a problem?

I was thinking making 1 data point = 1 day. Then arbitrarily choose that  
I want to display a max amount of 15 points per graph. Get the data for  
those 15 points and plot the graph according to that.

What problems could appear with this version?

---

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [June 23, 2008, 11:49pm UTC](https://www.ruby-forum.com/t/date-intervals-for-graphs/141229/2 "2008-06-23T23:49:20Z")

</div>

On Jun 23, 2008, at 3:24 PM, Marcelo B. wrote:

> –  
> M.

gruff or GoogleCharts, perhaps?

The grouping part (and the criteria for going from discrete to  
“grouped” points) would be up to you.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [June 24, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/date-intervals-for-graphs/141229/3 "2008-06-24T16:20:30Z")

</div>

On Jun 23, 3:24 pm, Marcelo B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> M.

Why is 100 points too much? If your graph will be 200 pixels wide or  
more, you’ve got room for them.
