https://github.com/creadone/redraw
Prototyping tool for charts with c3js and Rails
https://github.com/creadone/redraw
c3js charts d3js gem ruby-on-rails
Last synced: about 2 months ago
JSON representation
Prototyping tool for charts with c3js and Rails
- Host: GitHub
- URL: https://github.com/creadone/redraw
- Owner: creadone
- Created: 2019-05-21T21:18:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-22T21:42:43.000Z (about 7 years ago)
- Last Synced: 2025-07-20T06:41:07.774Z (11 months ago)
- Topics: c3js, charts, d3js, gem, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 127 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Redraw
Redraw is a prototyping tool for create custom charts with [C3.js](http://c3js.org) and Rails. C3.js is the very flexible library based on D3.js for create the charts with [many options](https://github.com/c3js/c3/blob/master/src/config.js) for fine tuning result.
While you creating each chart you need try the many variations until you reach the final result, it's a bit tiring. This Gem allow work with the chart configuration as usual Ruby class containing hash-like DSL for save you time.
Currently project status is a **proof-of-concept** and not completed yet. Described below is worked but will change and can break existing functionality, use only in sandbox.
## Install
Add to Gemfile and then `bundle install`
```
gem 'redraw', git: 'git@github.com:creadone/redraw.git'
```
In `application.js` add:
```
//= require d3.min
//= require c3.min
```
## Quick Start
Make directory for the charts store. You can use any but most easy way to add it inside `/app` like `/app/charts`, in development Spring will be reload code on each change without editing Rails autoload path. Then for create the first chart put empty config file `/app/charts/line_chart.rb` and paste code below:
```Ruby
Redraw::Chart.new("LineChart").build do
bindto 'container_name'
data do
columns [
['data1', 30, 200, 100, 400, 150, 250],
['data1', 50, 20, 10, 40, 15, 25]
]
end
end
```
Now you can render chart in views:
```ERB
<%= redraw_chart 'LineChart' %>
```
## Todo
- [ ] Expose any config variables for the passing data from view
- [ ] Allow inline javascript like `format: d3.format('$,')`
- [ ] Writing javascript and css in config directly
- [ ] Caching config and delivering them through assets pipeline
- [ ] Adding tests after API completed
- [ ] Chart inheritance (may be)
- [ ] Baking charts into static files or building stand-alone widget (may be)
- [ ] Flexible config for interacting with D3 (may be)
- [ ] Get rid of Rails dependency (may be)