https://github.com/Absolventa/iruby-chartkick
Minimalistic wrapper around chartkick for using it within iruby
https://github.com/Absolventa/iruby-chartkick
chartkick data-science iruby rubydatascience visualization
Last synced: 6 months ago
JSON representation
Minimalistic wrapper around chartkick for using it within iruby
- Host: GitHub
- URL: https://github.com/Absolventa/iruby-chartkick
- Owner: Absolventa
- License: mit
- Created: 2019-10-29T21:00:52.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T20:29:16.000Z (7 months ago)
- Last Synced: 2024-11-09T22:49:41.037Z (6 months ago)
- Topics: chartkick, data-science, iruby, rubydatascience, visualization
- Language: Ruby
- Size: 852 KB
- Stars: 15
- Watchers: 7
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- data-science-with-ruby - iruby-chartkick
README
# iruby-chartkick [](https://github.com/Absolventa/iruby-chartkick/actions/workflows/build.yml)
You like writing [Ruby within Juypter](https://github.com/SciRuby/iruby/) notebooks? Awesome, you're not alone - we do so, too ☀️ Since we also fell in love with the handy charting API of [ankane/chartkick](https://github.com/ankane/chartkick), we wrote this little gem bringing them together.
`iruby-chartkick` was made for easy plug-n-play plotting data using the awesomeness of chartkick within IRuby-backed Jupyter notebooks.
### Installation
gem install iruby-chartkick
### Usage
You can either include the module `IRuby::Chartkick` and use the wrapper methods, like `line_chart`:
```ruby
include IRuby::Chartkick
data = {
2019 => 1,
2020 => 122,
2021 => 34
}
line_chart(data)
```Or you use the chart wrapper classes directly:
```ruby
include IRuby::Chartkick
data = {
2019 => 1,
2020 => 122,
2021 => 34
}IRuby::Chartkick::LineChart.new(data).plot
```### Examples:
```ruby
include IRuby::Chartkickdata = [
{
name: "Monkeys",
data: {
2010 => 20,
2011 => 190,
2012 => 188,
2013 => 230,
2014 => 422,
2015 => 56,
2016 => 299,
2019 => 100
}
},
{
name: "Pirates",
data: {
2010 => 20,
2011 => 90,
2012 => 488,
2013 => 430,
2014 => 122,
2015 => 6,
2016 => 399,
2019 => 500
}
}
]
```#### LineChart
```ruby
line_chart(data)
```
```ruby
line_chart(data, points: false)
```
```ruby
line_chart(data, points: false, width: "700px", min: 50, max: 300)
```
#### AreaChart
```ruby
area_chart(data)
```
#### ColumnChart
```ruby
column_chart(data)
```
#### BarChart
```ruby
bar_chart(data)
```
#### ScatterChart
```ruby
scatter_chart(data)
```
#### PieChart
```ruby
include IRuby::Chartkickdata = [
["Blueberry", 44],
["Strawberry", 23],
["Banana", 22],
["Apple", 21],
["Grape", 13]
]pie_chart(data)
```
