chartkick 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chartkick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/app/assets/javascripts/chartkick.js +83 -20
- data/lib/chartkick/helper.rb +4 -0
- data/lib/chartkick/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: 00b03d10b24d6e36edf3061bdd594b83b831776f
|
4
|
+
data.tar.gz: eb2175cda000c9ed560f9b28dc08fd3eb9fd5b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 133267fc6a6a015495905656bac3be481ad205ed6aa81a5b7bdd68523617b798a72f3e2aac5f62834f62382c63d0462a28f1b1b934239db955cf6abfbd5f3999
|
7
|
+
data.tar.gz: c7ebf3c44d41a69f099e5a46cd81f21ae501b99c7a5660d4e3a082ef87f01d7cbc9efd7fe393a8f1499b85458197ce4d76d2d1b7b52b9084bcebe4f3be96d718
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Chartkick.js
|
3
3
|
* Create beautiful Javascript charts with minimal code
|
4
4
|
* https://github.com/ankane/chartkick.js
|
5
|
-
* v1.2.
|
5
|
+
* v1.2.2
|
6
6
|
* MIT License
|
7
7
|
*/
|
8
8
|
|
@@ -13,8 +13,6 @@
|
|
13
13
|
|
14
14
|
var Chartkick, ISO8601_PATTERN, DECIMAL_SEPARATOR, adapters = [];
|
15
15
|
|
16
|
-
var $ = window.jQuery || window.Zepto || window.$;
|
17
|
-
|
18
16
|
// helpers
|
19
17
|
|
20
18
|
function isArray(variable) {
|
@@ -154,6 +152,7 @@
|
|
154
152
|
}
|
155
153
|
|
156
154
|
function getJSON(element, url, success) {
|
155
|
+
var $ = window.jQuery || window.Zepto || window.$;
|
157
156
|
$.ajax({
|
158
157
|
dataType: "json",
|
159
158
|
url: url,
|
@@ -401,17 +400,37 @@
|
|
401
400
|
var GoogleChartsAdapter = new function () {
|
402
401
|
var google = window.google;
|
403
402
|
|
404
|
-
|
405
|
-
var
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
403
|
+
var loaded = {};
|
404
|
+
var callbacks = [];
|
405
|
+
|
406
|
+
var runCallbacks = function() {
|
407
|
+
var cb, call;
|
408
|
+
for (var i = 0; i < callbacks.length; i++) {
|
409
|
+
cb = callbacks[i];
|
410
|
+
call = (cb.pack == "corechart" && isFunction(google.visualization.LineChart)) || (cb.pack == "timeline" && isFunction(google.visualization.Timeline))
|
411
|
+
if (call) {
|
412
|
+
cb.callback();
|
413
|
+
callbacks.splice(i, 1);
|
414
|
+
i--;
|
415
|
+
}
|
416
|
+
}
|
417
|
+
};
|
418
|
+
|
419
|
+
google.setOnLoadCallback(runCallbacks);
|
420
|
+
|
421
|
+
var waitForLoaded = function (pack, callback) {
|
422
|
+
if (!callback) {
|
423
|
+
callback = pack;
|
424
|
+
pack = "corechart";
|
425
|
+
}
|
426
|
+
|
427
|
+
callbacks.push({pack: pack, callback: callback});
|
410
428
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
429
|
+
if (loaded[pack]) {
|
430
|
+
runCallbacks();
|
431
|
+
} else {
|
432
|
+
loaded[pack] = true;
|
433
|
+
google.load("visualization", "1.0", {"packages": [pack]});
|
415
434
|
}
|
416
435
|
};
|
417
436
|
|
@@ -627,7 +646,33 @@
|
|
627
646
|
});
|
628
647
|
});
|
629
648
|
};
|
649
|
+
|
650
|
+
this.renderTimeline = function (chart) {
|
651
|
+
waitForLoaded("timeline", function () {
|
652
|
+
var chartOptions = {
|
653
|
+
legend: "none"
|
654
|
+
};
|
655
|
+
|
656
|
+
if (chart.options.colors) {
|
657
|
+
chartOptions.colorAxis.colors = chart.options.colors;
|
658
|
+
}
|
659
|
+
var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});
|
660
|
+
|
661
|
+
var data = new google.visualization.DataTable();
|
662
|
+
data.addColumn({type: "string", id: "Name"});
|
663
|
+
data.addColumn({type: "date", id: "Start"});
|
664
|
+
data.addColumn({type: "date", id: "End"});
|
665
|
+
data.addRows(chart.data);
|
666
|
+
|
667
|
+
chart.chart = new google.visualization.Timeline(chart.element);
|
668
|
+
|
669
|
+
resize(function () {
|
670
|
+
chart.chart.draw(data, options);
|
671
|
+
});
|
672
|
+
});
|
673
|
+
};
|
630
674
|
};
|
675
|
+
|
631
676
|
adapters.push(GoogleChartsAdapter);
|
632
677
|
}
|
633
678
|
|
@@ -636,7 +681,7 @@
|
|
636
681
|
// to get the name of the chart class
|
637
682
|
function renderChart(chartType, chart) {
|
638
683
|
var i, adapter, fnName;
|
639
|
-
fnName = "render" + chartType
|
684
|
+
fnName = "render" + chartType;
|
640
685
|
|
641
686
|
for (i = 0; i < adapters.length; i++) {
|
642
687
|
adapter = adapters[i];
|
@@ -689,34 +734,49 @@
|
|
689
734
|
return perfectData;
|
690
735
|
}
|
691
736
|
|
737
|
+
function processTime(data)
|
738
|
+
{
|
739
|
+
var i;
|
740
|
+
for (i = 0; i < data.length; i++) {
|
741
|
+
data[i][1] = toDate(data[i][1]);
|
742
|
+
data[i][2] = toDate(data[i][2]);
|
743
|
+
}
|
744
|
+
return data;
|
745
|
+
}
|
746
|
+
|
692
747
|
function processLineData(chart) {
|
693
748
|
chart.data = processSeries(chart.data, chart.options, true);
|
694
|
-
renderChart("
|
749
|
+
renderChart("LineChart", chart);
|
695
750
|
}
|
696
751
|
|
697
752
|
function processColumnData(chart) {
|
698
753
|
chart.data = processSeries(chart.data, chart.options, false);
|
699
|
-
renderChart("
|
754
|
+
renderChart("ColumnChart", chart);
|
700
755
|
}
|
701
756
|
|
702
757
|
function processPieData(chart) {
|
703
758
|
chart.data = processSimple(chart.data);
|
704
|
-
renderChart("
|
759
|
+
renderChart("PieChart", chart);
|
705
760
|
}
|
706
761
|
|
707
762
|
function processBarData(chart) {
|
708
763
|
chart.data = processSeries(chart.data, chart.options, false);
|
709
|
-
renderChart("
|
764
|
+
renderChart("BarChart", chart);
|
710
765
|
}
|
711
766
|
|
712
767
|
function processAreaData(chart) {
|
713
768
|
chart.data = processSeries(chart.data, chart.options, true);
|
714
|
-
renderChart("
|
769
|
+
renderChart("AreaChart", chart);
|
715
770
|
}
|
716
771
|
|
717
772
|
function processGeoData(chart) {
|
718
773
|
chart.data = processSimple(chart.data);
|
719
|
-
renderChart("
|
774
|
+
renderChart("GeoChart", chart);
|
775
|
+
}
|
776
|
+
|
777
|
+
function processTimelineData(chart) {
|
778
|
+
chart.data = processTime(chart.data);
|
779
|
+
renderChart("Timeline", chart);
|
720
780
|
}
|
721
781
|
|
722
782
|
function setElement(chart, element, dataSource, opts, callback) {
|
@@ -751,6 +811,9 @@
|
|
751
811
|
GeoChart: function (element, dataSource, opts) {
|
752
812
|
setElement(this, element, dataSource, opts, processGeoData);
|
753
813
|
},
|
814
|
+
Timeline: function (element, dataSource, opts) {
|
815
|
+
setElement(this, element, dataSource, opts, processTimelineData);
|
816
|
+
},
|
754
817
|
charts: {}
|
755
818
|
};
|
756
819
|
|
data/lib/chartkick/helper.rb
CHANGED
@@ -28,6 +28,10 @@ module Chartkick
|
|
28
28
|
chartkick_chart "GeoChart", data_source, options
|
29
29
|
end
|
30
30
|
|
31
|
+
def timeline(data_source, options = {})
|
32
|
+
chartkick_chart "Timeline", data_source, options
|
33
|
+
end
|
34
|
+
|
31
35
|
private
|
32
36
|
|
33
37
|
def chartkick_chart(klass, data_source, options, &block)
|
data/lib/chartkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chartkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|