pi_charts 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3a9a437827f556323362cca2bde817aabfd143d
4
+ data.tar.gz: acdbecf4d591845751ad7c0d11578ab56845fbb0
5
+ SHA512:
6
+ metadata.gz: 989a5747d7d0b41498c44a301964b76244700f48d4a8e3540084b849257fd6c9c8420c604f526dba77fc26b21cdc5ef22ccbbce9a30c963ed9c8556105e96b1c
7
+ data.tar.gz: 492b564c24193fb94769059595dd9e0f63e7cbc794398c0eabe080f38294c9ee1db483bd25d00c30e7dbd201d4fa096470b81b7328d03eb3379690b23a48b447
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kgruber1@emich.edu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pi_charts.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Kent Gruber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Pi Charts
2
+
3
+ Pi Charts is a ruby gem to easily generate beautiful charts using [chartjs](http://www.chartjs.org/docs) 📈◕📊◔📉🍩
4
+
5
+ ⚠️ This gem is install in development. Things may change to be better in the future.
6
+
7
+ ## Usage
8
+
9
+ Pi Charts is a really good pair with something like [sinatra](http://www.sinatrarb.com/), for example:
10
+
11
+ ```ruby
12
+ require 'sinatra'
13
+ require 'pi_charts'
14
+
15
+ def bake_pie
16
+ chart = PiCharts::Pie.new
17
+ chart.add_dataset(label: "cats", data: 80)
18
+ chart.add_dataset(label: "dogs", data: 50)
19
+ chart.hover
20
+ chart.responsive
21
+ "<head>" + chart.cdn + "</head>" + "<body>" + chart.html(width: 60) + "</body>"
22
+ end
23
+
24
+ get('/serve_pie') { bake_pie }
25
+ ```
26
+ ## Screen Shots
27
+
28
+ ![fresh pie](http://i.imgur.com/6rjzOnT.png)
29
+
30
+ ![bar](http://i.imgur.com/h0afu2c.png)
31
+
32
+ ![line](http://i.imgur.com/xBPZPae.png)
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
37
+
38
+ ## Author
39
+
40
+ Kent 'picat' Gruber
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pi_charts"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Bar.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [ 3, 1, 3, 3 ])
13
+ chart.add_dataset(label: "dogs", data: [ 7, 3, 3, 1 ])
14
+
15
+ # neat 'lil configurations
16
+ chart.hover
17
+ chart.responsive
18
+
19
+ # generate html / js for chart
20
+ puts chart.html
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Bar.new
6
+
7
+ # add labels ( x values )
8
+ chart.add_labels(["January", "February", "March", "April", "May"])
9
+
10
+ # add datasets
11
+ chart.add_dataset(label: "cats", data: [ 3, 1, 3, 3 ])
12
+ chart.add_dataset(label: "dogs", data: [ 7, 3, 3, 1 ])
13
+
14
+ # neat 'lil configurations
15
+ chart.hover
16
+ chart.responsive
17
+
18
+ # hide legend
19
+ chart.legend(hidden: true)
20
+
21
+ # generate html / js for chart
22
+ puts chart.html
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Bar.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [ 3, 1, 3, 3 ])
13
+ chart.add_dataset(label: "dogs", data: [ 7, 3, 3, 1 ])
14
+
15
+ # stack'em up
16
+ chart.stack
17
+
18
+ # neat 'lil configurations
19
+ chart.hover
20
+ chart.responsive
21
+
22
+ # generate html / js for chart
23
+ puts chart.html
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+ require "pry"
4
+
5
+ binding.pry
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new doughnut chart
5
+ chart = PiCharts::Doughnut.new
6
+
7
+ # add datasets
8
+ chart.add_dataset(label: "cats", data: 80)
9
+ chart.add_dataset(label: "dogs", data: 20)
10
+
11
+ # make cats 90
12
+ chart.add_dataset(label: "cats", data: 10, add: true)
13
+
14
+ # make dogs 10, not adding
15
+ chart.add_dataset(label: "dogs", data: 10)
16
+
17
+ # make the cutout 70 percent
18
+ chart.cutout(70)
19
+
20
+ # neat 'lil configurations
21
+ chart.hover
22
+ chart.responsive
23
+
24
+ # generate html / js for chart
25
+ puts chart.html
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new doughnut chart
5
+ chart = PiCharts::Doughnut.new
6
+
7
+ # add datasets
8
+ chart.add_dataset(label: "cats", data: 80)
9
+ chart.add_dataset(label: "dogs", data: 20)
10
+
11
+ # make cats 90
12
+ chart.add_dataset(label: "cats", data: 10, add: true)
13
+
14
+ # make dogs 10, not adding
15
+ chart.add_dataset(label: "dogs", data: 10)
16
+
17
+ # make the cutout 60 percent
18
+ chart.cutout(60)
19
+
20
+ # hide legend
21
+ chart.legend(hidden: true)
22
+
23
+ # neat 'lil configurations
24
+ chart.hover
25
+ chart.responsive
26
+
27
+ # generate html / js for chart
28
+ puts chart.html
@@ -0,0 +1,20 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Line.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
13
+ chart.add_dataset(label: "dogs", data: [7, 3, 3, 1, 3])
14
+
15
+ # neat 'lil configurations
16
+ chart.hover
17
+ chart.responsive
18
+
19
+ # generate html / js for chart
20
+ puts chart.html
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Line.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
13
+ chart.add_dataset(label: "dogs", data: [7, 3, 3, 1, 3])
14
+
15
+ # border configuration
16
+ chart.border(dataset: "cats", color: chart.random_color, width: 2, dash: [5, 5])
17
+
18
+ # neat 'lil configurations
19
+ chart.hover
20
+ chart.responsive
21
+
22
+ # generate html / js for chart
23
+ puts chart.html
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Line.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
13
+ chart.add_dataset(label: "dogs", data: [7, 3, 3, 1, 3])
14
+
15
+ # hide legend
16
+ chart.legend(hidden: true)
17
+
18
+ # neat 'lil configurations
19
+ chart.hover
20
+ chart.responsive
21
+
22
+ # generate html / js for chart
23
+ puts chart.html
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Line.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
13
+ chart.add_dataset(label: "dogs", data: [7, 3, 3, 1, 3])
14
+
15
+ # no line for cats or dogs
16
+ chart.no_line("cats")
17
+ chart.no_line("dogs")
18
+
19
+ # neat 'lil configurations
20
+ chart.hover
21
+ chart.responsive
22
+
23
+ # generate html / js for chart
24
+ puts chart.html
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "pi_charts"
3
+
4
+ # create a new line chart
5
+ chart = PiCharts::Line.new
6
+
7
+ # add labels ( x values )
8
+
9
+ chart.add_labels(["January", "February", "March", "April", "May"])
10
+
11
+ # add datasets
12
+ chart.add_dataset(label: "cats", data: [3, 1, 3, 3, 7])
13
+ chart.add_dataset(label: "dogs", data: [7, 3, 3, 1, 3])
14
+
15
+ # tension configuration
16
+ chart.tension(dataset: "cats", ammount: 0)
17
+
18
+ # neat 'lil configurations
19
+ chart.hover
20
+ chart.responsive
21
+
22
+ # generate html / js for chart
23
+ puts chart.html