-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
59 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
### Cartesian Charts | ||
|
||
Example series used for cartesian charts: | ||
|
||
```erb | ||
<% series = [ | ||
{name: "Inactive", data: @inactive_properties}, | ||
{name: "Active", data: @active_properties} | ||
] %> | ||
``` | ||
To build the data, you can use gem [groupdate](https://github.com/ankane/groupdate). | ||
In my case, it was: | ||
|
||
```ruby | ||
@inactive_properties = Property.inactive.group_by_week(:created_at).count | ||
@active_properties = Property.active.group_by_week(:created_at).count | ||
``` | ||
|
||
and I'll get the data in this format: | ||
```ruby | ||
{ | ||
Sun, 29 Jul 2018=>1, | ||
Sun, 05 Aug 2018=>6, | ||
.. | ||
} | ||
``` | ||
PS: `Property` can be any model you have and `inactive` and `active` | ||
are just some normal ActiveRecord scopes. Keep scrolling down to see | ||
accepted data formats. | ||
|
||
Example options used for cartesian charts: | ||
|
||
```erb | ||
<% options = { | ||
title: 'Properties Growth', | ||
subtitle: 'Grouped Per Week', | ||
xtitle: 'Week', | ||
ytitle: 'Properties', | ||
stacked: true | ||
} %> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters