sleek_charts 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +4 -0
- data/app/assets/javascripts/donut-tip.js +29 -26
- data/example/bar-tip.png +0 -0
- data/example/donut-tip.png +0 -0
- data/lib/sleek_charts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56c911ae5c2a47cd89b40898c520aee39c70a3f1
|
4
|
+
data.tar.gz: 9e29110b452d946e469cdf2d9b84208bd8260702
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d194157ff6349e2c7a415105ec791871176fddc7bc0bba1b3ac33bd73d7441c59559b8bd1cafee38617e71e9f6e454e5e9eeac250508b7104e2dd1f939bc515f
|
7
|
+
data.tar.gz: 0bb71c5e0253faaa41eb7b7e514faa886406872087142baa08c8a67fa4268494d323763179147095216f43c3bade83a3ab17472b0f9829f66e34c39a92baffcd
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# SleekCharts
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/sleek_charts.png)](http://badge.fury.io/rb/sleek_charts) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gouravtiwari/sleek_charts/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
2
3
|
|
3
4
|
Provides Bar and Donut charts with consitent tooltip for Rails applications.
|
5
|
+
This gem uses [d3](http://d3js.org) and [d3-tip](https://github.com/Caged/d3-tip) libraries.
|
4
6
|
|
5
7
|
## Supports Rails 3.1+
|
6
8
|
|
@@ -56,3 +58,5 @@ or add donut chart to any element, e.g.
|
|
56
58
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
59
|
4. Push to the branch (`git push origin my-new-feature`)
|
58
60
|
5. Create new Pull Request
|
61
|
+
|
62
|
+
|
@@ -17,6 +17,7 @@
|
|
17
17
|
// tipValue: tipValue, for each bar, default is 'value'
|
18
18
|
// tipText: tipText which you want to display with 'label' and 'value', default is ''
|
19
19
|
// totalLabel: totalLabel to add a label for sum e.g. ' Views'
|
20
|
+
// legend: default set to true to show legends
|
20
21
|
|
21
22
|
function mergeConfigOptions(defaults,options){
|
22
23
|
var mergedConfig = {};
|
@@ -41,7 +42,8 @@ function donutTip(options){
|
|
41
42
|
tipLabel: '',
|
42
43
|
tipValue: 'value',
|
43
44
|
tipText: '',
|
44
|
-
totalLabel: ''
|
45
|
+
totalLabel: '',
|
46
|
+
legend: true
|
45
47
|
};
|
46
48
|
|
47
49
|
var config = (options) ? mergeConfigOptions(defaults,options) : defaults;
|
@@ -132,30 +134,31 @@ function donutTip(options){
|
|
132
134
|
return config.color(i);
|
133
135
|
}) //set the color for each slice to be chosen from the color function defined above
|
134
136
|
.attr("d", arc); //this creates the actual SVG path using the associated data (pie) with the arc drawing function
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
137
|
+
if(config.legend){
|
138
|
+
var legend = d3.select(config.selector).append("svg")
|
139
|
+
.attr("class", "legend")
|
140
|
+
.attr("width", config.outerRadius)
|
141
|
+
.attr("height", config.outerRadius * 2)
|
142
|
+
.selectAll("g")
|
143
|
+
.data(data)
|
144
|
+
.enter().append("g")
|
145
|
+
.attr("transform", function (d, i) {
|
146
|
+
return "translate(0," + i * 20 + ")";
|
147
|
+
});
|
148
|
+
|
149
|
+
legend.append("rect")
|
150
|
+
.attr("width", 18)
|
151
|
+
.attr("height", 18)
|
152
|
+
.style("fill", function (d, i) {
|
153
|
+
return config.color(i);
|
154
|
+
});
|
155
|
+
|
156
|
+
legend.append("text")
|
157
|
+
.attr("x", 24)
|
158
|
+
.attr("y", 9)
|
159
|
+
.attr("dy", ".35em")
|
160
|
+
.text(function (d) {
|
161
|
+
return d[config.xDomain];
|
160
162
|
});
|
163
|
+
}
|
161
164
|
}
|
data/example/bar-tip.png
CHANGED
Binary file
|
data/example/donut-tip.png
CHANGED
Binary file
|
data/lib/sleek_charts/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sleek_charts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gourav Tiwari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|